/* @00458e5c file=? name=FUN_00458e5c */

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

void __cdecl FUN_00458e5c(int param_1)

{
  int iVar1;
  undefined4 *puVar2;
  float local_9c [5];
  float local_88;
  float local_74;
  float local_6c [5];
  float local_58;
  float local_44;
  float local_3c [5];
  float local_28;
  float local_14;
  float local_c;
  float local_8;
  
  local_8 = *(float *)(*(int *)(param_1 + 0x10) + 0x80);
  iVar1 = *(int *)(param_1 + 0x1c);
  if (iVar1 == 0) {
    if (*(int *)(*(int *)(param_1 + 0x2c) + 0x14) == *(int *)(param_1 + 0x20)) {
      *(undefined4 *)(param_1 + 0x1c) = 1;
      *(float *)(param_1 + 0x28) = local_8;
      local_c = local_8 - *(float *)(param_1 + 0x28);
      if (local_c < _DAT_004590cc) {
        local_c = 0.05;
      }
      puVar2 = (undefined4 *)FUN_0048a630(*(int *)(param_1 + 0x34));
      FUN_0040aadc(local_3c);
      local_3c[0] = local_c;
      local_28 = local_c;
      local_14 = local_c;
      FUN_0040b0ac((int)local_3c,3,*(undefined4 **)(param_1 + 0x3c));
      FUN_0040beb0(puVar2,local_3c);
      FUN_0048ac30(*(int *)(param_1 + 0x30),1);
      FUN_0048d5d4(*(undefined4 **)(param_1 + 0x30));
      FUN_0045fbf4(*(int *)(param_1 + 0x10),*(undefined4 *)(param_1 + 0x34));
      FUN_0045a744(*(int *)(param_1 + 0x10),param_1);
    }
  }
  else if (iVar1 == 1) {
    local_c = local_8 - *(float *)(param_1 + 0x28);
    if (local_c < _DAT_004590cc) {
      local_c = 0.05;
    }
    if (_DAT_004590d0 <= local_c) {
      local_c = 1.0;
      *(undefined4 *)(param_1 + 0x1c) = 2;
    }
    puVar2 = (undefined4 *)FUN_0048a630(*(int *)(param_1 + 0x34));
    FUN_0040aadc(local_6c);
    local_6c[0] = local_c;
    local_58 = local_c;
    local_44 = local_c;
    FUN_0040b0ac((int)local_6c,3,*(undefined4 **)(param_1 + 0x3c));
    FUN_0040beb0(puVar2,local_6c);
    FUN_0045fbf4(*(int *)(param_1 + 0x10),*(undefined4 *)(param_1 + 0x34));
  }
  else if (iVar1 == 2) {
    if (_DAT_004590d4 <= local_8 - *(float *)(param_1 + 0x28)) {
      *(undefined4 *)(param_1 + 0x1c) = 3;
      *(float *)(param_1 + 0x28) = local_8 + _DAT_004590d0;
    }
  }
  else if (iVar1 == 3) {
    local_c = *(float *)(param_1 + 0x28) - local_8;
    if (local_c < _DAT_004590cc) {
      local_c = 0.05;
      FUN_0048ac30(*(int *)(param_1 + 0x30),0);
      FUN_0048d5d4(*(undefined4 **)(param_1 + 0x30));
      *(undefined4 *)(param_1 + 0x1c) = 0;
      FUN_0045a764(*(int *)(param_1 + 0x10),param_1);
    }
    puVar2 = (undefined4 *)FUN_0048a630(*(int *)(param_1 + 0x34));
    FUN_0040aadc(local_9c);
    local_9c[0] = local_c;
    local_88 = local_c;
    local_74 = local_c;
    FUN_0040b0ac((int)local_9c,3,*(undefined4 **)(param_1 + 0x3c));
    FUN_0040beb0(puVar2,local_9c);
    FUN_0045fbf4(*(int *)(param_1 + 0x10),*(undefined4 *)(param_1 + 0x34));
  }
  return;
}



/* @004590d8 file=? name=FUN_004590d8 */

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

{
  float *pfVar1;
  undefined4 *puVar2;
  int iVar3;
  float *pfVar4;
  float *pfVar5;
  float local_94 [12];
  float local_64 [12];
  float local_34 [12];
  
  FUN_004536b4(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9);
  *param_1 = &PTR_FUN_004f1628;
  param_1[0x1b] = param_10;
  param_1[0x1c] = param_11;
  param_1[0x1f] = 0;
  param_1[0x1d] = param_12;
  param_1[0x1e] = param_13;
  param_1[0x20] = param_14;
  param_1[0x21] = 0;
  puVar2 = (undefined4 *)FUN_0048a630(param_1[0xb]);
  FUN_0040aadc(local_34);
  pfVar1 = (float *)param_1[0x1e];
  pfVar4 = local_34;
  pfVar5 = local_64;
  for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
    *pfVar5 = *pfVar4;
    pfVar4 = pfVar4 + 1;
    pfVar5 = pfVar5 + 1;
  }
  FUN_0040b374(local_34,local_64,pfVar1);
  pfVar1 = (float *)param_1[0x1d];
  pfVar4 = local_34;
  pfVar5 = local_94;
  for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
    *pfVar5 = *pfVar4;
    pfVar4 = pfVar4 + 1;
    pfVar5 = pfVar5 + 1;
  }
  FUN_0040b3e8(local_34,local_94,pfVar1);
  FUN_0040beb0(puVar2,local_34);
  FUN_0048d3e8((undefined4 *)param_1[0xb]);
  FUN_0048ac30(param_1[0xc],param_1[0x1f]);
  FUN_0048d5d4((undefined4 *)param_1[0xc]);
  (**(code **)(*(int *)(param_1[0x1b] + 0x2c) + 4))(param_1[0x1b] + 0x2c,param_1);
  return param_1;
}



/* @004591f8 file=? name=FUN_004591f8 */

void __cdecl FUN_004591f8(int *param_1,byte param_2)

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



/* @00459224 file=? name=FUN_00459224 */

undefined4 __cdecl FUN_00459224(int param_1)

{
  FUN_004537c4(param_1);
  return 1;
}



/* @00459238 file=? name=FUN_00459238 */

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

void __cdecl FUN_00459238(int param_1)

{
  float *pfVar1;
  undefined4 *puVar2;
  int iVar3;
  float *pfVar4;
  float *pfVar5;
  float local_b4 [12];
  float local_84 [12];
  float local_54 [4];
  float local_44 [12];
  undefined4 local_14;
  undefined4 local_10;
  int local_c;
  undefined4 local_8;
  
  if (*(int *)(*(int *)(param_1 + 0x6c) + 0x14) == *(int *)(param_1 + 0x70)) {
    if (*(int *)(param_1 + 0x7c) == 0) {
      *(undefined4 *)(param_1 + 0x7c) = 1;
      FUN_0048ac30(*(int *)(param_1 + 0x30),1);
      FUN_0048d5d4(*(undefined4 **)(param_1 + 0x30));
      FUN_0045a744(*(int *)(param_1 + 0x10),param_1);
    }
    *(float *)(param_1 + 0x84) = *(float *)(param_1 + 0x80) + *(float *)(param_1 + 0x84);
    if (_DAT_004593bc < *(float *)(param_1 + 0x84)) {
      *(float *)(param_1 + 0x84) = *(float *)(param_1 + 0x84) - _DAT_004593bc;
    }
    local_14 = *(undefined4 *)(param_1 + 0x84);
    local_c = 2;
    local_10 = local_14;
    local_8 = local_14;
    puVar2 = (undefined4 *)FUN_0048a630(*(int *)(param_1 + 0x2c));
    FUN_0040aadc(local_44);
    FUN_0040998c(local_54,&local_c);
    FUN_0040adec(local_44,local_54);
    pfVar1 = *(float **)(param_1 + 0x78);
    pfVar4 = local_44;
    pfVar5 = local_84;
    for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
      *pfVar5 = *pfVar4;
      pfVar4 = pfVar4 + 1;
      pfVar5 = pfVar5 + 1;
    }
    FUN_0040b374(local_44,local_84,pfVar1);
    pfVar1 = *(float **)(param_1 + 0x74);
    pfVar4 = local_44;
    pfVar5 = local_b4;
    for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
      *pfVar5 = *pfVar4;
      pfVar4 = pfVar4 + 1;
      pfVar5 = pfVar5 + 1;
    }
    FUN_0040b3e8(local_44,local_b4,pfVar1);
    FUN_0040beb0(puVar2,local_44);
    FUN_0045fbf4(*(int *)(param_1 + 0x10),*(undefined4 *)(param_1 + 0x2c));
  }
  else if (*(int *)(param_1 + 0x7c) != 0) {
    *(undefined4 *)(param_1 + 0x7c) = 0;
    FUN_0048ac30(*(int *)(param_1 + 0x30),0);
    FUN_0048d5d4(*(undefined4 **)(param_1 + 0x30));
    FUN_0045a764(*(int *)(param_1 + 0x10),param_1);
  }
  FUN_004537d8();
  return;
}



/* @004593c0 file=? name=FUN_004593c0 */

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

{
  float *pfVar1;
  undefined4 *puVar2;
  int iVar3;
  float *pfVar4;
  float *pfVar5;
  float local_94 [12];
  float local_64 [12];
  float local_34 [12];
  
  FUN_004536b4(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9);
  *param_1 = &PTR_FUN_004f1610;
  param_1[0x1b] = param_10;
  param_1[0x1c] = param_11;
  param_1[0x1f] = 0;
  param_1[0x1d] = param_12;
  param_1[0x1e] = param_13;
  puVar2 = (undefined4 *)FUN_0048a630(param_1[0xb]);
  FUN_0040aadc(local_34);
  pfVar1 = (float *)param_1[0x1e];
  pfVar4 = local_34;
  pfVar5 = local_64;
  for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
    *pfVar5 = *pfVar4;
    pfVar4 = pfVar4 + 1;
    pfVar5 = pfVar5 + 1;
  }
  FUN_0040b374(local_34,local_64,pfVar1);
  pfVar1 = (float *)param_1[0x1d];
  pfVar4 = local_34;
  pfVar5 = local_94;
  for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
    *pfVar5 = *pfVar4;
    pfVar4 = pfVar4 + 1;
    pfVar5 = pfVar5 + 1;
  }
  FUN_0040b3e8(local_34,local_94,pfVar1);
  FUN_0040beb0(puVar2,local_34);
  FUN_0048d3e8((undefined4 *)param_1[0xb]);
  FUN_0048ac30(param_1[0xc],param_1[0x1f]);
  FUN_0048d5d4((undefined4 *)param_1[0xc]);
  (**(code **)(*(int *)(param_1[0x1b] + 0x2c) + 4))(param_1[0x1b] + 0x2c,param_1);
  return param_1;
}



/* @004594cc file=? name=FUN_004594cc */

void __cdecl FUN_004594cc(int *param_1,byte param_2)

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



/* @004594f8 file=? name=FUN_004594f8 */

undefined4 __cdecl FUN_004594f8(int param_1)

{
  FUN_004537c4(param_1);
  return 1;
}



/* @0045950c file=? name=FUN_0045950c */

void __cdecl FUN_0045950c(int param_1)

{
  float *pfVar1;
  undefined4 *puVar2;
  int iVar3;
  float *pfVar4;
  float *pfVar5;
  float local_94 [12];
  float local_64 [12];
  float local_34 [12];
  
  if (*(int *)(*(int *)(param_1 + 0x6c) + 0x14) == *(int *)(param_1 + 0x70)) {
    if (*(int *)(param_1 + 0x7c) == 0) {
      *(undefined4 *)(param_1 + 0x7c) = 1;
      FUN_0048ac30(*(int *)(param_1 + 0x30),1);
      FUN_0048d5d4(*(undefined4 **)(param_1 + 0x30));
      FUN_0045a744(*(int *)(param_1 + 0x10),param_1);
    }
    puVar2 = (undefined4 *)FUN_0048a630(*(int *)(param_1 + 0x2c));
    FUN_0040aadc(local_34);
    pfVar1 = *(float **)(param_1 + 0x78);
    pfVar4 = local_34;
    pfVar5 = local_64;
    for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
      *pfVar5 = *pfVar4;
      pfVar4 = pfVar4 + 1;
      pfVar5 = pfVar5 + 1;
    }
    FUN_0040b374(local_34,local_64,pfVar1);
    pfVar1 = *(float **)(param_1 + 0x74);
    pfVar4 = local_34;
    pfVar5 = local_94;
    for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
      *pfVar5 = *pfVar4;
      pfVar4 = pfVar4 + 1;
      pfVar5 = pfVar5 + 1;
    }
    FUN_0040b3e8(local_34,local_94,pfVar1);
    FUN_0040beb0(puVar2,local_34);
    FUN_0045fbf4(*(int *)(param_1 + 0x10),*(undefined4 *)(param_1 + 0x2c));
  }
  else if (*(int *)(param_1 + 0x7c) != 0) {
    *(undefined4 *)(param_1 + 0x7c) = 0;
    FUN_0048ac30(*(int *)(param_1 + 0x30),0);
    FUN_0048d5d4(*(undefined4 **)(param_1 + 0x30));
    FUN_0045a764(*(int *)(param_1 + 0x10),param_1);
  }
  FUN_004537d8();
  return;
}



/* @0045961f file=? name=FUN_0045961f */

undefined4 __cdecl FUN_0045961f(float *param_1,float *param_2,float param_3)

{
  float10 fVar1;
  
  fVar1 = FUN_004dcd00((double)(*param_1 - *param_2));
  if ((fVar1 <= (float10)param_3) &&
     (fVar1 = FUN_004dcd00((double)(param_1[1] - param_2[1])), fVar1 <= (float10)param_3)) {
    return 1;
  }
  return 0;
}



/* @004596a6 file=? name=FUN_004596a6 */

void FUN_004596a6(void)

{
  return;
}



/* @00459eb8 file=? name=FUN_00459eb8 */

char * __cdecl FUN_00459eb8(char *param_1)

{
  char cVar1;
  undefined4 *puVar2;
  char *pcVar3;
  uint uVar4;
  int iVar5;
  uint uVar6;
  char *pcVar7;
  char *pcVar8;
  
  puVar2 = *(undefined4 **)(DAT_004f1aac + 4);
  while( true ) {
    if (puVar2 == (undefined4 *)0x0) {
      return param_1;
    }
    pcVar7 = (char *)(puVar2 + 2);
    if (((pcVar7 != (char *)0x0) && (*pcVar7 != '\0')) &&
       (pcVar3 = FUN_004d4c78(param_1,pcVar7), pcVar3 != (char *)0x0)) break;
    puVar2 = (undefined4 *)*puVar2;
  }
  pcVar8 = (char *)puVar2[1];
  DAT_00522b9c = 0;
  uVar4 = (int)pcVar3 - (int)param_1;
  for (; *pcVar8 == '<'; pcVar8 = pcVar8 + 1) {
    uVar4 = uVar4 - 1;
  }
  if (0 < (int)uVar4) {
    FUN_004d4a94(&DAT_00522b9c,param_1,uVar4);
  }
  iVar5 = FUN_004d4a78(pcVar7);
  pcVar3 = pcVar3 + iVar5;
  uVar4 = FUN_004d4a78(pcVar8);
  pcVar7 = pcVar8 + (uVar4 - 1);
  while ((uVar4 != 0 && (*pcVar7 == '>'))) {
    uVar4 = uVar4 - 1;
    pcVar7 = pcVar7 + -1;
    if (*pcVar3 != '\0') {
      pcVar3 = pcVar3 + 1;
    }
  }
  if (0 < (int)uVar4) {
    FUN_004d4a94(&DAT_00522b9c,pcVar8,uVar4);
  }
  FUN_004d49b8(&DAT_00522b9c,pcVar3);
  uVar4 = 0xffffffff;
  pcVar7 = &DAT_00522b9c;
  do {
    pcVar3 = pcVar7;
    if (uVar4 == 0) break;
    uVar4 = uVar4 - 1;
    pcVar3 = pcVar7 + 1;
    cVar1 = *pcVar7;
    pcVar7 = pcVar3;
  } while (cVar1 != '\0');
  uVar4 = ~uVar4;
  pcVar7 = pcVar3 + -uVar4;
  pcVar3 = param_1;
  for (uVar6 = uVar4 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
    *(undefined4 *)pcVar3 = *(undefined4 *)pcVar7;
    pcVar7 = pcVar7 + 4;
    pcVar3 = pcVar3 + 4;
  }
  for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
    *pcVar3 = *pcVar7;
    pcVar7 = pcVar7 + 1;
    pcVar3 = pcVar3 + 1;
  }
  return param_1;
}



/* @00459fb4 file=? name=FUN_00459fb4 */

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

{
  char cVar1;
  int iVar2;
  char *pcVar3;
  uint uVar4;
  uint uVar5;
  char *pcVar6;
  
  uVar4 = 0xffffffff;
  pcVar3 = param_2;
  do {
    pcVar6 = pcVar3;
    if (uVar4 == 0) break;
    uVar4 = uVar4 - 1;
    pcVar6 = pcVar3 + 1;
    cVar1 = *pcVar3;
    pcVar3 = pcVar6;
  } while (cVar1 != '\0');
  uVar4 = ~uVar4;
  pcVar3 = pcVar6 + -uVar4;
  pcVar6 = param_1;
  for (uVar5 = uVar4 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {
    *(undefined4 *)pcVar6 = *(undefined4 *)pcVar3;
    pcVar3 = pcVar3 + 4;
    pcVar6 = pcVar6 + 4;
  }
  for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
    *pcVar6 = *pcVar3;
    pcVar3 = pcVar3 + 1;
    pcVar6 = pcVar6 + 1;
  }
  iVar2 = FUN_004d4a78(param_2);
  pcVar3 = param_1 + iVar2;
  while (pcVar3 = pcVar3 + 1, pcVar3 < param_1 + 0xf) {
    *pcVar3 = '\0';
  }
  *(undefined4 *)(param_1 + 0x10) = param_3;
  *(undefined4 *)(param_1 + 0x14) = param_4;
  *(undefined4 *)(param_1 + 0x18) = param_5;
  *(undefined4 *)(param_1 + 0x1c) = param_6;
  return param_1;
}



/* @0045a01c file=? name=FUN_0045a01c */

void __cdecl FUN_0045a01c(int *param_1,byte param_2)

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



/* @0045a038 file=? name=FUN_0045a038 */

undefined4 FUN_0045a038(void)

{
  return 1;
}



/* @0045a044 file=? name=FUN_0045a044 */

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

{
  FUN_00415e90(param_1,1);
  *param_1 = &PTR_FUN_004f3358;
  param_1[3] = param_2;
  param_1[4] = param_3;
  return param_1;
}



/* @0045a070 file=? name=FUN_0045a070 */

void __cdecl FUN_0045a070(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f3358;
    if (param_1[4] != 0) {
      FUN_0045a01c((int *)param_1[3],3);
    }
    FUN_00415ed8(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0045a0b0 file=? name=FUN_0045a0b0 */

undefined4 FUN_0045a0b0(void)

{
  return 1;
}



/* @0045a0c4 file=? name=FUN_0045a0c4 */

int __cdecl FUN_0045a0c4(int *param_1,int param_2)

{
  int iVar1;
  undefined4 *puVar2;
  int *piVar3;
  int iVar4;
  
  iVar1 = **(int **)(param_2 + 0x3c);
  iVar4 = 0;
  piVar3 = *(int **)(param_2 + 0x3c) + 1;
  if (0 < iVar1) {
    do {
      puVar2 = (undefined4 *)FUN_00402298(0x14);
      if (puVar2 == (undefined4 *)0x0) {
        puVar2 = (undefined4 *)0x0;
      }
      else {
        puVar2 = FUN_0045a044(puVar2,piVar3,0);
      }
      (**(code **)(*param_1 + 4))(param_1,puVar2);
      iVar4 = iVar4 + 1;
      piVar3 = piVar3 + 8;
    } while (iVar4 < iVar1);
  }
  return iVar1;
}



/* @0045a134 file=? name=FUN_0045a134 */

void __cdecl FUN_0045a134(int param_1)

{
  undefined4 *puVar1;
  int local_10 [3];
  
  FUN_004614b8(local_10,param_1);
  while( true ) {
    puVar1 = (undefined4 *)(**(code **)(local_10[0] + 0x28))(local_10);
    if (puVar1 == (undefined4 *)0x0) break;
    if (puVar1 != (undefined4 *)0x0) {
      (**(code **)*puVar1)(puVar1,3);
    }
  }
  FUN_00461515(local_10,2);
  return;
}



/* @0045a180 file=? name=FUN_0045a180 */

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

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

{
  int *piVar1;
  char *pcVar2;
  undefined4 *puVar3;
  undefined4 uVar4;
  int iVar5;
  float10 fVar6;
  undefined4 local_d0 [32];
  char local_50;
  float local_1c;
  float local_18;
  float local_14;
  undefined4 local_10;
  undefined4 local_c;
  undefined4 local_8;
  
  FUN_004368b8(param_1,param_2,param_3,param_4,param_5,param_6);
  *param_1 = &PTR_FUN_004f330c;
  FUN_0040aadc(param_1 + 0x14);
  FUN_004612dd(param_1 + 0xdf,0);
  FUN_00461328(param_1 + 0xe4,0,0);
  FUN_0046140e(param_1 + 0xe9,0,0);
  FUN_0041c42c(param_1 + 0xef,0);
  param_1[0x2c] = 0;
  param_1[0x2d] = 0;
  param_1[0x2f] = 0;
  param_1[0x2b] = 1;
  param_1[0x32] = 0;
  param_1[0x33] = 0;
  param_1[0x34] = 0;
  param_1[0x35] = 0;
  param_1[0x36] = 0;
  param_1[0x37] = 0;
  param_1[0x39] = 0;
  param_1[0x38] = 0;
  param_1[0x3a] = 0;
  param_1[0x3b] = 0;
  param_1[0x3c] = 0;
  param_1[0x3e] = 0;
  param_1[0x3d] = 0;
  param_1[0x3f] = 0;
  param_1[0x40] = 0;
  param_1[0x41] = 0;
  param_1[0x42] = 0;
  param_1[0x43] = 0;
  param_1[0x44] = 0;
  param_1[0x45] = 0;
  param_1[0x46] = 0x41f00000;
  param_1[0x49] = 0;
  param_1[0x4a] = 0;
  param_1[0x4b] = 0;
  param_1[0x4c] = 0;
  param_1[0xdb] = 0;
  param_1[0xdc] = 0;
  param_1[0xdd] = 0;
  param_1[0xde] = 0;
  param_1[0xb2] = 0;
  param_1[0x2e] = 0;
  param_1[0xf4] = 0;
  param_1[0xf6] = 0;
  param_1[0xf5] = 0;
  param_1[0xf7] = 0;
  FUN_0040ab28(param_1 + 0x14,&DAT_004e107c);
  piVar1 = (int *)FUN_00414b60();
  param_1[0x20] = (float)*piVar1 / DAT_0052140c;
  piVar1 = (int *)FUN_00402298(0x24);
  if (piVar1 == (int *)0x0) {
    DAT_004f1ab0 = (int *)0x0;
  }
  else {
    DAT_004f1ab0 = FUN_00401c18(piVar1,0x4f1e7a,2000000);
  }
  iVar5 = 0;
  puVar3 = param_1 + 0xb3;
  do {
    iVar5 = iVar5 + 1;
    *puVar3 = 0;
    puVar3 = puVar3 + 1;
  } while (iVar5 < 0x28);
  local_8 = 0;
  local_c = 0x41200000;
  local_10 = 0;
  local_14 = 0.0;
  local_18 = 0.0;
  local_1c = 0.0;
  local_50 = '\0';
  pcVar2 = (char *)FUN_004dee74(s_DPLARG_004f1e83);
  iVar5 = FUN_004dee74(s_L4EYES_004f1e8a);
  if (iVar5 != 0) {
    FUN_004d7f84(iVar5,(byte *)s__f__f__f__f__f__f__s_004f1e91);
    FUN_004d771c(s__f___f___f__f___f___f_004f1ea6);
    param_1[0x13] = 1;
    if (local_50 == 'r') {
      FUN_004dbb24(&DAT_00524e20,s_DPLRenderer__DPLRenderer_Eye_wil_004f1ebe,(char *)0x0);
      param_1[0x2c] = 1;
    }
  }
  if (pcVar2 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_DPLARG_must_be_set_for_the_Divis_004f1eff,(char *)0x0);
  }
  iVar5 = FUN_0046181c(pcVar2);
  if (iVar5 == 0) {
    FUN_004dbb24(&DAT_00524e20,s_DPLARG_is_bad__I_couldn_t_unders_004f1f34,(char *)0x0);
  }
  iVar5 = FUN_00461d14((int)local_d0,pcVar2,'~');
  FUN_0048d108(iVar5,local_d0);
  FUN_00497b9c(&DAT_004f1f67,FUN_00495048);
  FUN_00498d38(&DAT_004f1f6c,FUN_0049a1dc);
  FUN_00498d38(&DAT_004f1f71,FUN_00499ab0);
  FUN_00496634(&LAB_004596ac);
  FUN_00496604(&LAB_00459e64);
  puVar3 = FUN_004896cc();
  param_1[0x4b] = puVar3;
  puVar3 = FUN_004896cc();
  param_1[0x4a] = puVar3;
  uVar4 = FUN_004896f0();
  param_1[0x49] = uVar4;
  iVar5 = FUN_00489708();
  param_1[0x48] = iVar5;
  FUN_00491c90(iVar5,local_1c,2);
  FUN_00491c90(param_1[0x48],local_14,0);
  FUN_00491c90(param_1[0x48],local_18,1);
  FUN_00491c58(param_1[0x48],local_8,local_c,local_10);
  FUN_0048a714(param_1[0x48],param_1[0x4b]);
  FUN_0048b4ac(param_1[0x49],param_1[0x48]);
  FUN_0048a890(param_1[0x4b]);
  FUN_0048a890(param_1[0x4a]);
  FUN_0048b56c(param_1[0x49],0x3f800000,0x40000000);
  FUN_0048b608(param_1[0x49],0,0,0);
  FUN_0048b83c(0,0,0,DAT_004f3368,DAT_004f336c);
  fVar6 = (float10)FUN_004dd188(0x40000000,0x3fe0c152);
  FUN_0048b9d0(param_1[0x49],0xbf800000,0xbf800000,0x3f800000,0x3f800000,
               (float)((float10)_DAT_0045a720 / fVar6));
  FUN_0048b788(param_1[0x49],0);
  FUN_00489bd4(param_1[0x49]);
  FUN_0048b6b4(param_1[0x49],5,0,0,0,0x3c23d70a,0x3d4ccccd);
  FUN_0048d3e8((undefined4 *)param_1[0x48]);
  FUN_0048d42c((undefined4 *)param_1[0x49]);
  FUN_0048d4b0((undefined4 *)param_1[0x4b]);
  FUN_0048d4b0((undefined4 *)param_1[0x4a]);
  FUN_0048a1bc();
  puVar3 = (undefined4 *)FUN_00414b60();
  param_1[0x2a] = *puVar3;
  param_1[0x31] = 0;
  FUN_0045f784((int)param_1);
  param_1[0x28] = 0;
  return param_1;
}



/* @0045a724 file=? name=FUN_0045a724 */

undefined4 * FUN_0045a724(void)

{
  undefined4 *puVar1;
  
  puVar1 = FUN_004896cc();
  FUN_0048a890((int)puVar1);
  FUN_0048d4b0(puVar1);
  return puVar1;
}



/* @0045a744 file=? name=FUN_0045a744 */

void __cdecl FUN_0045a744(int param_1,undefined4 param_2)

{
  (**(code **)(*(int *)(param_1 + 0x3bc) + 4))(param_1 + 0x3bc,param_2);
  return;
}



/* @0045a764 file=? name=FUN_0045a764 */

void __cdecl FUN_0045a764(int param_1,int param_2)

{
  int local_14 [4];
  
  FUN_00415f30(local_14,param_2,0xffffffff);
  FUN_004161fc((int)local_14,param_1 + 0x3bc);
  FUN_00415f90(local_14,2);
  return;
}



/* @0045a7a8 file=? name=FUN_0045a7a8 */

void __cdecl FUN_0045a7a8(int param_1,undefined4 param_2)

{
  switch(param_2) {
  case 0:
    *(undefined4 *)(param_1 + 0xac) = 1;
    return;
  case 1:
    *(undefined4 *)(param_1 + 0xac) = 0;
    return;
  case 2:
    *(undefined4 *)(param_1 + 200) = *(undefined4 *)(param_1 + 0xdc);
    *(undefined4 *)(param_1 + 0xd0) = *(undefined4 *)(param_1 + 0xe4);
    *(undefined4 *)(param_1 + 0xcc) = *(undefined4 *)(param_1 + 0xe0);
    *(undefined4 *)(param_1 + 0xd4) = *(undefined4 *)(param_1 + 0xe8);
    *(undefined4 *)(param_1 + 0xd8) = *(undefined4 *)(param_1 + 0xec);
    if (*(int *)(param_1 + 0xac) != 0) {
      FUN_0048b6b4(*(int *)(param_1 + 0x124),5,*(undefined4 *)(param_1 + 200),
                   *(undefined4 *)(param_1 + 0xd0),*(undefined4 *)(param_1 + 0xcc),
                   *(undefined4 *)(param_1 + 0xd4),*(undefined4 *)(param_1 + 0xd8));
      FUN_0048d42c(*(undefined4 **)(param_1 + 0x124));
      return;
    }
    break;
  case 3:
    *(undefined4 *)(param_1 + 200) = *(undefined4 *)(param_1 + 0xf0);
    *(undefined4 *)(param_1 + 0xd0) = *(undefined4 *)(param_1 + 0xf8);
    *(undefined4 *)(param_1 + 0xcc) = *(undefined4 *)(param_1 + 0xf4);
    *(undefined4 *)(param_1 + 0xd4) = *(undefined4 *)(param_1 + 0xfc);
    *(undefined4 *)(param_1 + 0xd8) = *(undefined4 *)(param_1 + 0x100);
    if (*(int *)(param_1 + 0xac) != 0) {
      FUN_0048b6b4(*(int *)(param_1 + 0x124),5,*(undefined4 *)(param_1 + 200),
                   *(undefined4 *)(param_1 + 0xd0),*(undefined4 *)(param_1 + 0xcc),
                   *(undefined4 *)(param_1 + 0xd4),*(undefined4 *)(param_1 + 0xd8));
      FUN_0048d42c(*(undefined4 **)(param_1 + 0x124));
      return;
    }
    break;
  case 4:
    FUN_0048b56c(*(int *)(param_1 + 0x124),0x3e800000,0x44898000);
    FUN_0048b6b4(*(int *)(param_1 + 0x124),5,0x3ea3d70a,0x3e99999a,0x3f266666,0x42c80000,0x44834000)
    ;
    FUN_0048d42c(*(undefined4 **)(param_1 + 0x124));
  }
  return;
}



/* @0045a954 file=? name=FUN_0045a954 */

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

{
  *param_2 = *(undefined4 *)(param_1 + 200);
  *param_3 = *(undefined4 *)(param_1 + 0xd0);
  *param_4 = *(undefined4 *)(param_1 + 0xcc);
  *param_5 = *(undefined4 *)(param_1 + 0xd4);
  *param_6 = *(undefined4 *)(param_1 + 0xd8);
  return;
}



/* @0045a994 file=munga_l4/l4video.cpp name=FUN_0045a994 */

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

{
  int iVar1;
  int iVar2;
  
  iVar1 = FUN_004904a0(param_2);
  if (iVar1 != 0) {
    FUN_0040385c(s_DPLRenderer__MarkDCSHiearchy_tri_004f1f76,
                 s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f1fc1,0x5c8);
  }
  FUN_00490490(param_2,param_3);
  iVar1 = 0;
  while( true ) {
    iVar2 = FUN_0048a2ec(param_2,iVar1);
    if (iVar2 == 0) break;
    FUN_0045a994(param_1,iVar2,param_3);
    iVar1 = iVar1 + 1;
  }
  return;
}



/* @0045a9f8 file=munga_l4/l4video.cpp name=FUN_0045a9f8 */

int __cdecl FUN_0045a9f8(undefined4 param_1,char *param_2)

{
  int *piVar1;
  int iVar2;
  char *pcVar3;
  char *pcVar4;
  undefined4 uVar5;
  undefined4 *puVar6;
  int iVar7;
  undefined4 local_108;
  undefined2 uStack_104;
  undefined1 uStack_102;
  int local_8;
  
  local_108 = DAT_004f1fe2;
  uStack_104 = DAT_004f1fe6;
  uStack_102 = DAT_004f1fe8;
  FUN_004d49b8((char *)&local_108,param_2);
  piVar1 = FUN_004d6f54((LPCSTR)&local_108,&DAT_004f1fe9);
  if (piVar1 == (int *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_Could_not_open_pfx_file_004f1fec,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,(char *)&local_108,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_effects_using_it_will_fail_004f2005,(char *)0x0);
    iVar2 = 0;
  }
  else {
    iVar2 = FUN_00402298(0x104);
    if (iVar2 == 0) {
      FUN_0040385c(s_ran_out_of_RAM_trying_to_read_a_p_004f2022,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f204c,0x5f8);
    }
    pcVar3 = (char *)FUN_004d6c20(&local_108,0xff,piVar1);
    iVar7 = 0;
    pcVar4 = pcVar3;
    do {
      if (*pcVar4 == '\n') {
        *pcVar4 = '\0';
      }
      iVar7 = iVar7 + 1;
      pcVar4 = pcVar4 + 1;
    } while (iVar7 < 0xff);
    uVar5 = FUN_00497730(pcVar3,0,&local_8);
    *(undefined4 *)(iVar2 + 0x100) = uVar5;
    puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
    local_8 = FUN_004d7f84(puVar6,(byte *)s__x__d__f__f_004f206d);
    if (local_8 < 4) {
      FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f207a,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f2084,(char *)0x0);
      iVar2 = 0;
    }
    else {
      puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
      local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f__f__f_004f209d);
      if (local_8 < 4) {
        FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f20aa,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f20b4,(char *)0x0);
        iVar2 = 0;
      }
      else {
        puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
        local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f__f__f__f__f_004f20cd);
        if (local_8 < 6) {
          FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f20e0,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f20ea,(char *)0x0);
          iVar2 = 0;
        }
        else {
          puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
          local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f__f__f__f__f_004f2103);
          if (local_8 < 6) {
            FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f2116,(char *)0x0);
            FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
            FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f2120,(char *)0x0);
            iVar2 = 0;
          }
          else {
            puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
            local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f__f__f__f__f_004f2139);
            if (local_8 < 6) {
              FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f214c,(char *)0x0);
              FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
              FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f2156,(char *)0x0);
              iVar2 = 0;
            }
            else {
              puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
              local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f_004f216f);
              if (local_8 < 2) {
                FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f2176,(char *)0x0);
                FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
                FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f2180,(char *)0x0);
                iVar2 = 0;
              }
              else {
                puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
                local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f__f__f__f__f__f__f_004f2199);
                if (local_8 < 8) {
                  FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f21b2,(char *)0x0);
                  FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
                  FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f21bc,(char *)0x0);
                  iVar2 = 0;
                }
                else {
                  puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
                  local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f__f__f__f__f__f__f_004f21d5);
                  if (local_8 < 8) {
                    FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f21ee,(char *)0x0);
                    FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
                    FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f21f8,(char *)0x0);
                    iVar2 = 0;
                  }
                  else {
                    puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
                    local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f__f__f__f__f__f__f_004f2211);
                    if (local_8 < 8) {
                      FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f222a,(char *)0x0);
                      FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
                      FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f2234,(char *)0x0);
                      iVar2 = 0;
                    }
                    else {
                      puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
                      local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f__f__f__f__f__f__f_004f224d);
                      if (local_8 < 8) {
                        FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f2266,(char *)0x0);
                        FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
                        FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f2270,(char *)0x0);
                        iVar2 = 0;
                      }
                      else {
                        puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
                        local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f_004f2289);
                        if (local_8 < 2) {
                          FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f2290,(char *)0x0);
                          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
                          FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f229a,(char *)0x0);
                          iVar2 = 0;
                        }
                        else {
                          puVar6 = FUN_004d6c20(&local_108,0xff,piVar1);
                          local_8 = FUN_004d7f84(puVar6,(byte *)s__f__f_004f22b3);
                          if (local_8 < 2) {
                            FUN_004dbb24(&DAT_00524e20,s_pfx_file_004f22ba,(char *)0x0);
                            FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
                            FUN_004dbb24(&DAT_00524e20,s_did_not_read_correctly_004f22c4,(char *)0x0
                                        );
                            iVar2 = 0;
                          }
                          else {
                            FUN_004d6b08(piVar1);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  return iVar2;
}



/* @0045b1b8 file=munga_l4/l4video.cpp name=FUN_0045b1b8 */

void FUN_0045b1b8(int param_1,undefined4 *param_2,char *param_3,int param_4,int param_5)

{
  char *pcVar1;
  int iVar2;
  undefined4 *puVar3;
  undefined4 uVar4;
  undefined4 *puVar5;
  uint uVar6;
  char *pcVar7;
  int *piVar8;
  uint *puVar9;
  char *pcVar10;
  int *piVar11;
  bool bVar12;
  char *local_248;
  uint local_240 [2];
  char *local_238;
  uint local_230 [2];
  char *local_228;
  int local_220 [10];
  uint *local_1f8;
  int *local_1f4;
  int *local_1f0;
  uint *local_1ec;
  char *local_1e8;
  uint *local_1e4;
  int *local_1e0;
  char *local_1dc;
  uint *local_1d8;
  int *local_1d4;
  uint *local_1d0;
  uint *local_1cc;
  char *local_1c8;
  uint local_1c4;
  int *local_1c0;
  int *local_1bc;
  uint *local_1b8;
  uint *local_1b4;
  char *local_1b0;
  uint local_1ac;
  int *local_1a8;
  char *local_1a4;
  uint *local_1a0;
  int *local_19c;
  int *local_198;
  uint *local_194;
  char *local_190;
  int local_18c;
  int *local_188;
  int local_184;
  char *local_180;
  int *local_17c;
  uint local_178;
  int *local_174;
  int *local_170;
  int *local_16c;
  int *local_168;
  int *local_164;
  int *local_160;
  int *local_15c;
  int *local_158;
  uint *local_154;
  uint *local_150;
  char *local_14c;
  uint local_148;
  int *local_144;
  char *local_140;
  uint *local_13c;
  int local_138;
  uint local_134;
  uint *local_130;
  char *local_12c;
  uint *local_128;
  undefined4 *local_124;
  int *local_120;
  undefined4 *local_11c;
  int *local_118;
  uint *local_114;
  uint *local_110;
  int *local_10c;
  int local_108;
  char *local_104;
  char *local_100;
  int *local_fc;
  uint local_f8;
  char *local_f4;
  char *local_f0;
  int local_ec;
  undefined4 local_e8;
  undefined4 local_e4;
  float local_e0;
  float local_dc;
  undefined4 local_d8;
  undefined4 local_d4;
  undefined4 local_d0;
  float local_cc;
  float local_c8;
  float local_c4;
  float local_c0;
  int local_bc;
  int local_b8;
  int local_b4;
  uint local_b0;
  int local_ac;
  char *local_a8;
  int *local_a4;
  uint local_a0;
  int *local_9c;
  uint local_98;
  char *local_94;
  char *local_90;
  char *local_8c;
  char *local_88;
  char *local_84;
  char *local_80;
  char *local_7c;
  char *local_78;
  float local_74;
  char *local_70;
  char *local_6c;
  char *local_68;
  char *local_64;
  int local_60;
  char *local_5c;
  char *local_58;
  char *local_54;
  char *local_50;
  char *local_4c;
  char *local_48;
  char *local_44;
  char *local_40;
  char *local_3c;
  char *local_38;
  int *local_34;
  int *local_30;
  int *local_2c;
  int *local_28;
  int *local_24;
  int *local_20;
  float local_1c;
  float local_18;
  float local_14;
  undefined4 local_10;
  undefined4 local_c;
  undefined4 local_8;
  
  if (param_5 != 0) {
    local_44 = param_3;
    FUN_004dbb24(&DAT_00524e20,s_DPLReadINIPage_processing_004f22dd,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,local_44,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f22f8,(char *)0x0);
  }
  local_34 = FUN_00404720((int)param_2,param_3,s_objectpath_004f22fa);
  if (local_34 != (int *)0x0) {
    for (puVar3 = (undefined4 *)local_34[1]; puVar3 != (undefined4 *)0x0;
        puVar3 = (undefined4 *)*puVar3) {
      FUN_00497b18((char *)puVar3[1],1);
      if (param_5 != 0) {
        local_48 = (char *)FUN_00497b88();
        FUN_004dbb24(&DAT_00524e20,s_objectpath___004f2305,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_48,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,&DAT_004f2312,(char *)0x0);
        FUN_004d9c38(&DAT_00524e20);
      }
    }
    if (local_34 != (int *)0x0) {
      (**(code **)*local_34)(local_34,3);
    }
  }
  local_34 = FUN_00404720((int)param_2,param_3,s_texmappath_004f2314);
  if (local_34 != (int *)0x0) {
    for (puVar3 = (undefined4 *)local_34[1]; puVar3 != (undefined4 *)0x0;
        puVar3 = (undefined4 *)*puVar3) {
      FUN_00498cb4((char *)puVar3[1],1);
      if (param_5 != 0) {
        local_4c = (char *)FUN_00498d24();
        FUN_004dbb24(&DAT_00524e20,s_texmappath___004f231f,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_4c,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,&DAT_004f232c,(char *)0x0);
        FUN_004d9c38(&DAT_00524e20);
      }
    }
    if (local_34 != (int *)0x0) {
      (**(code **)*local_34)(local_34,3);
    }
  }
  local_34 = FUN_00404720((int)param_2,param_3,s_materialpath_004f232e);
  if (local_34 != (int *)0x0) {
    for (puVar3 = (undefined4 *)local_34[1]; puVar3 != (undefined4 *)0x0;
        puVar3 = (undefined4 *)*puVar3) {
      FUN_004978a0((char *)puVar3[1],1);
      if (param_5 != 0) {
        local_50 = (char *)FUN_00497910();
        FUN_004dbb24(&DAT_00524e20,s_materialpath___004f233b,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_50,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,&DAT_004f234a,(char *)0x0);
        FUN_004d9c38(&DAT_00524e20);
      }
    }
    if (local_34 != (int *)0x0) {
      (**(code **)*local_34)(local_34,3);
    }
  }
  iVar2 = FUN_00404088((int)param_2,param_3,s_priorityobjectpath_004f234c,&local_3c);
  if ((iVar2 != 0) && (FUN_00497b18(local_3c,0), param_5 != 0)) {
    local_54 = local_3c;
    FUN_004dbb24(&DAT_00524e20,s_priorityobjectpath___004f235f,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f2374,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  iVar2 = FUN_00404088((int)param_2,param_3,s_prioritytexmappath_004f2376,&local_3c);
  if ((iVar2 != 0) && (FUN_00498cb4(local_3c,0), param_5 != 0)) {
    local_58 = local_3c;
    FUN_004dbb24(&DAT_00524e20,s_prioritytexmappath___004f2389,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,local_58,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f239e,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  iVar2 = FUN_00404088((int)param_2,param_3,s_prioritymaterialpath_004f23a0,&local_3c);
  if ((iVar2 != 0) && (FUN_004978a0(local_3c,0), param_5 != 0)) {
    local_5c = local_3c;
    FUN_004dbb24(&DAT_00524e20,s_prioritymaterialpath___004f23b5,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,local_5c,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f23cc,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  local_20 = FUN_00404720((int)param_2,param_3,s_cache_004f23ce);
  if (local_20 != (int *)0x0) {
    for (puVar3 = (undefined4 *)local_20[1]; puVar3 != (undefined4 *)0x0;
        puVar3 = (undefined4 *)*puVar3) {
      local_60 = FUN_00498448((char *)puVar3[1],0);
      if (local_60 == 0) {
        local_64 = (char *)puVar3[1];
        FUN_004dbb24(&DAT_00524e20,s_Unable_to_cache_004f23d4,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_64,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,&DAT_004f23e5,(char *)0x0);
      }
      else if (param_5 != 0) {
        local_68 = (char *)puVar3[1];
        FUN_004dbb24(&DAT_00524e20,s_Caching_004f23e7,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_68,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,&DAT_004f23f0,(char *)0x0);
      }
    }
    if (local_20 != (int *)0x0) {
      (**(code **)*local_20)(local_20,3);
    }
  }
  iVar2 = FUN_00404088((int)param_2,param_3,&DAT_004f23f2,&local_3c);
  if (iVar2 != 0) {
    FUN_004d7f84(local_3c,(byte *)s__f__f_004f23f7);
    FUN_0048b56c(*(int *)(param_1 + 0x124),*(undefined4 *)(param_1 + 0x104),
                 *(undefined4 *)(param_1 + 0x108));
    if (param_5 != 0) {
      local_6c = local_3c;
      FUN_004dbb24(&DAT_00524e20,s_Clip_Range_004f23fd,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_6c,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,&DAT_004f2409,(char *)0x0);
    }
  }
  iVar2 = FUN_00404088((int)param_2,param_3,s_backgnd_004f240b,&local_3c);
  if (iVar2 != 0) {
    FUN_004d7f84(local_3c,(byte *)s__f__f__f_004f2413);
    FUN_0048b608(*(int *)(param_1 + 0x124),*(undefined4 *)(param_1 + 0x10c),
                 *(undefined4 *)(param_1 + 0x110),*(undefined4 *)(param_1 + 0x114));
    if (param_5 != 0) {
      local_70 = local_3c;
      FUN_004dbb24(&DAT_00524e20,s_Background_Color_004f241c,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_70,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,&DAT_004f242e,(char *)0x0);
    }
  }
  iVar2 = FUN_00404088((int)param_2,param_3,s_viewangle_004f2430,&local_3c);
  if (iVar2 != 0) {
    FUN_004d7f84(local_3c,&DAT_004f243a);
    FUN_0048b83c(0,0,0,DAT_004f3368,DAT_004f336c);
    local_74 = *(float *)(param_1 + 0x118);
    FUN_00460770(param_1,local_74);
    FUN_0048b788(*(int *)(param_1 + 0x124),0);
    if (param_5 != 0) {
      local_78 = local_3c;
      FUN_004dbb24(&DAT_00524e20,s_View_Angle_004f243d,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_78,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,&DAT_004f2449,(char *)0x0);
    }
  }
  iVar2 = FUN_00404088((int)param_2,param_3,&DAT_004f244b,&local_3c);
  if (iVar2 != 0) {
    FUN_004d7f84(local_3c,(byte *)s__f__f__f__f__f_004f244f);
    *(undefined4 *)(param_1 + 0xdc) = *(undefined4 *)(param_1 + 200);
    *(undefined4 *)(param_1 + 0xe4) = *(undefined4 *)(param_1 + 0xd0);
    *(undefined4 *)(param_1 + 0xe0) = *(undefined4 *)(param_1 + 0xcc);
    *(undefined4 *)(param_1 + 0xe8) = *(undefined4 *)(param_1 + 0xd4);
    *(undefined4 *)(param_1 + 0xec) = *(undefined4 *)(param_1 + 0xd8);
    *(undefined4 *)(param_1 + 0xf0) = *(undefined4 *)(param_1 + 200);
    *(undefined4 *)(param_1 + 0xf8) = *(undefined4 *)(param_1 + 0xd0);
    *(undefined4 *)(param_1 + 0xf4) = *(undefined4 *)(param_1 + 0xcc);
    *(undefined4 *)(param_1 + 0xfc) = *(undefined4 *)(param_1 + 0xd4);
    *(undefined4 *)(param_1 + 0x100) = *(undefined4 *)(param_1 + 0xd8);
    FUN_0048b6b4(*(int *)(param_1 + 0x124),5,0,0,0,0x3c23d70a,0x3d4ccccd);
    if (param_5 != 0) {
      local_7c = local_3c;
      FUN_004dbb24(&DAT_00524e20,&DAT_004f245e,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_7c,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,&DAT_004f2463,(char *)0x0);
    }
  }
  iVar2 = FUN_00404088((int)param_2,param_3,s_nosearchlightfog_004f2465,&local_3c);
  if ((iVar2 != 0) && (FUN_004d7f84(local_3c,(byte *)s__f__f__f__f__f_004f2476), param_5 != 0)) {
    local_80 = local_3c;
    FUN_004dbb24(&DAT_00524e20,s_nosearchlightfog_004f2485,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,local_80,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f2497,(char *)0x0);
  }
  iVar2 = FUN_00404088((int)param_2,param_3,s_ambient_004f2499,&local_3c);
  if (iVar2 != 0) {
    FUN_004d7f84(local_3c,(byte *)s__f__f__f_004f24a1);
    puVar3 = FUN_0048973c();
    *(undefined4 **)(param_1 + 0x3d0) = puVar3;
    FUN_0048b1e0(*(int *)(param_1 + 0x3d0),2);
    FUN_0048b26c(*(int *)(param_1 + 0x3d0),local_8,local_c,local_10);
    FUN_0048d478(*(undefined4 **)(param_1 + 0x3d0));
    if (param_5 != 0) {
      local_84 = local_3c;
      FUN_004dbb24(&DAT_00524e20,s_Ambient_Light_004f24ab,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_84,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,&DAT_004f24ba,(char *)0x0);
    }
  }
  local_24 = FUN_00404720((int)param_2,param_3,s_light_004f24bc);
  if (local_24 != (int *)0x0) {
    iVar2 = FUN_00403b60((int)local_24);
    if (iVar2 != 0) {
      if (*(int *)(param_1 + 0x3dc) != 0) {
        FUN_0040385c(s_All_lights_must_be_defined_on_a_s_004f24c2,
                     s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f24f9,0x81c);
      }
      iVar2 = FUN_00403b60((int)local_24);
      *(int *)(param_1 + 0x3dc) = iVar2;
      if (*(int *)(param_1 + 0x3dc) != 0) {
        uVar4 = FUN_004022b0(*(int *)(param_1 + 0x3dc) << 2);
        *(undefined4 *)(param_1 + 0x3d8) = uVar4;
        uVar4 = FUN_004022b0(*(int *)(param_1 + 0x3dc) << 2);
        *(undefined4 *)(param_1 + 0x3d4) = uVar4;
      }
      iVar2 = 0;
      for (puVar3 = (undefined4 *)local_24[1]; puVar3 != (undefined4 *)0x0;
          puVar3 = (undefined4 *)*puVar3) {
        FUN_004d7f84(puVar3[1],(byte *)s__f__f__f__f__f__f_004f251a);
        if (param_5 != 0) {
          local_88 = (char *)puVar3[1];
          FUN_004dbb24(&DAT_00524e20,s_Light_004f252c,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,local_88,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,&DAT_004f2533,(char *)0x0);
        }
        puVar5 = FUN_0048973c();
        *(undefined4 **)(*(int *)(param_1 + 0x3d4) + iVar2 * 4) = puVar5;
        uVar4 = FUN_00489708();
        *(undefined4 *)(*(int *)(param_1 + 0x3d8) + iVar2 * 4) = uVar4;
        FUN_00489ba8(*(int *)(*(int *)(param_1 + 0x3d8) + iVar2 * 4));
        FUN_0048b1e0(*(int *)(*(int *)(param_1 + 0x3d4) + iVar2 * 4),3);
        FUN_0048b26c(*(int *)(*(int *)(param_1 + 0x3d4) + iVar2 * 4),local_8,local_c,local_10);
        FUN_0048b134(*(int *)(*(int *)(param_1 + 0x3d4) + iVar2 * 4),
                     *(int *)(*(int *)(param_1 + 0x3d8) + iVar2 * 4));
        FUN_00491c90(*(int *)(*(int *)(param_1 + 0x3d8) + iVar2 * 4),local_1c,2);
        FUN_00491c90(*(int *)(*(int *)(param_1 + 0x3d8) + iVar2 * 4),local_14,0);
        FUN_00491c90(*(int *)(*(int *)(param_1 + 0x3d8) + iVar2 * 4),local_18,1);
        FUN_0048d478(*(undefined4 **)(*(int *)(param_1 + 0x3d4) + iVar2 * 4));
        FUN_0048d3e8(*(undefined4 **)(*(int *)(param_1 + 0x3d8) + iVar2 * 4));
        iVar2 = iVar2 + 1;
      }
    }
    if (local_24 != (int *)0x0) {
      (**(code **)*local_24)(local_24,3);
    }
  }
  local_28 = FUN_00404720((int)param_2,param_3,&DAT_004f2535);
  if (local_28 != (int *)0x0) {
    for (puVar3 = (undefined4 *)local_28[1]; puVar3 != (undefined4 *)0x0;
        puVar3 = (undefined4 *)*puVar3) {
      local_90 = (char *)(puVar3 + 3);
      uVar6 = FUN_004dd1e0(local_90);
      local_8c = (char *)puVar3[1];
      if (param_5 != 0) {
        local_98 = uVar6;
        local_94 = local_8c;
        FUN_004dbb24(&DAT_00524e20,&DAT_004f253a,(char *)0x0);
        local_9c = FUN_004db78c(&DAT_00524e20,local_98);
        FUN_004dbb24(local_9c,&DAT_004f253f,(char *)0x0);
        FUN_004dbb24(local_9c,local_94,(char *)0x0);
        FUN_004dbb24(local_9c,&DAT_004f2541,(char *)0x0);
      }
      if (((int)uVar6 < 0) || (0x27 < (int)uVar6)) {
        FUN_0040385c(s_PSFX_id_number_was_not_in_the_al_004f2543,
                     s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f256f,0x86d);
      }
      if (*(int *)(param_1 + 0x2cc + uVar6 * 4) != 0) {
        local_a0 = uVar6;
        FUN_004dbb24(&DAT_00524e20,s_psfx__004f2590,(char *)0x0);
        local_a4 = FUN_004db78c(&DAT_00524e20,local_a0);
        FUN_004dbb24(local_a4,s_already_existed_from_an_earlier_p_004f2596,(char *)0x0);
        FUN_004022d0(*(int **)(param_1 + 0x2cc + uVar6 * 4));
      }
      iVar2 = FUN_0045a9f8(param_1,local_8c);
      *(int *)(param_1 + 0x2cc + uVar6 * 4) = iVar2;
    }
    if (local_28 != (int *)0x0) {
      (**(code **)*local_28)(local_28,3);
    }
  }
  local_2c = FUN_00404720((int)param_2,param_3,s_specialfx_004f25cc);
  if (local_2c != (int *)0x0) {
    for (puVar3 = (undefined4 *)local_2c[1]; puVar3 != (undefined4 *)0x0;
        puVar3 = (undefined4 *)*puVar3) {
      local_f0 = (char *)((int)puVar3 + 0x11);
      local_b0 = FUN_004dd1e0(local_f0);
      pcVar7 = (char *)puVar3[1];
      if (param_5 != 0) {
        local_f8 = local_b0;
        local_f4 = pcVar7;
        FUN_004dbb24(&DAT_00524e20,s_specialfx_004f25d6,(char *)0x0);
        local_fc = FUN_004db78c(&DAT_00524e20,local_f8);
        FUN_004dbb24(local_fc,&DAT_004f25e0,(char *)0x0);
        FUN_004dbb24(local_fc,local_f4,(char *)0x0);
        FUN_004dbb24(local_fc,&DAT_004f25e2,(char *)0x0);
      }
      FUN_004040d8((int)param_2,pcVar7,&DAT_004f25e4,&local_b4);
      FUN_00404118((int)param_2,pcVar7,&DAT_004f25e9,&local_c0);
      FUN_00404118((int)param_2,pcVar7,s_velocity_004f25ee,&local_c4);
      FUN_00404118((int)param_2,pcVar7,s_v_bias_004f25f7,&local_c8);
      FUN_00404118((int)param_2,pcVar7,s_y_off_004f25fe,&local_cc);
      FUN_00404118((int)param_2,pcVar7,s_variance_004f2604,&local_dc);
      FUN_00404118((int)param_2,pcVar7,s_gravity_004f260d,&local_e0);
      FUN_004040d8((int)param_2,pcVar7,s_count_004f2615,&local_b8);
      FUN_004040d8((int)param_2,pcVar7,s_repeats_004f261b,&local_bc);
      FUN_00404088((int)param_2,pcVar7,&DAT_004f2623,&local_3c);
      FUN_004d7f84(local_3c,(byte *)s__f__f__f_004f2628);
      FUN_00404088((int)param_2,pcVar7,&DAT_004f2631,&local_3c);
      FUN_004d7f84(local_3c,(byte *)s__f__f_004f2636);
      FUN_00404088((int)param_2,pcVar7,s_texture_004f263c,&local_3c);
      local_a8 = local_3c;
      local_ec = FUN_00497730(local_3c,0,&local_ac);
      if (local_ec == 0) {
        local_100 = local_a8;
        FUN_004dbb24(&DAT_00524e20,s_couldn_t_find_texture_004f2644,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_100,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_for_an_effect_004f265b,(char *)0x0);
      }
      FUN_00490210(local_b0,local_ec,local_b4,local_c0,local_c4,local_c8,local_cc,local_d0,local_d4,
                   local_d8,local_dc,local_e0,local_e4,local_e8,local_b8,local_bc,3);
    }
    if (local_2c != (int *)0x0) {
      (**(code **)*local_2c)(local_2c,3);
    }
  }
  local_30 = FUN_00404720((int)param_2,param_3,s_include_004f266b);
  if (local_30 != (int *)0x0) {
    for (puVar3 = (undefined4 *)local_30[1]; puVar3 != (undefined4 *)0x0;
        puVar3 = (undefined4 *)*puVar3) {
      local_38 = (char *)puVar3[1];
      FUN_0045b1b8(param_1,param_2,local_38,param_4,param_5);
      if (param_5 != 0) {
        local_104 = param_3;
        FUN_004dbb24(&DAT_00524e20,s_DPLReadINIPage_returned_to_004f2673,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_104,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,&DAT_004f268f,(char *)0x0);
      }
    }
    if (local_30 != (int *)0x0) {
      (**(code **)*local_30)(local_30,3);
    }
  }
  iVar2 = FUN_00404088((int)param_2,param_3,s_compare_004f2691,&local_40);
  if (iVar2 != 0) {
    piVar11 = FUN_004de998(local_220,4,10,1,FUN_00461280);
    local_114 = (uint *)FUN_00402298(0x10);
    if (local_114 == (uint *)0x0) {
      local_110 = (uint *)0x0;
    }
    else {
      local_110 = FUN_00402460(local_114,&DAT_004f2699);
    }
    local_110[3] = local_110[3] + 1;
    local_11c = (undefined4 *)FUN_00402298(0x10);
    if (local_11c == (undefined4 *)0x0) {
      local_118 = (int *)0x0;
    }
    else {
      local_118 = (int *)FUN_004023f4(local_11c);
    }
    local_118[3] = local_118[3] + 1;
    local_124 = (undefined4 *)FUN_00402298(0x10);
    if (local_124 == (undefined4 *)0x0) {
      local_120 = (int *)0x0;
    }
    else {
      local_120 = (int *)FUN_004023f4(local_124);
    }
    local_120[3] = local_120[3] + 1;
    local_12c = local_40;
    local_130 = (uint *)FUN_00402298(0x10);
    if (local_130 == (uint *)0x0) {
      local_128 = (uint *)0x0;
    }
    else {
      local_128 = FUN_00402460(local_130,local_12c);
    }
    local_128[3] = local_128[3] + 1;
    local_138 = *(int *)(DAT_004efc94 + 0x68);
    if (param_5 != 0) {
      FUN_004dbb24(&DAT_00524e20,s_compare___004f269b,(char *)0x0);
      local_13c = local_128;
      local_140 = (char *)local_128[2];
      FUN_004dbb24(&DAT_00524e20,local_140,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,&DAT_004f26a6,(char *)0x0);
    }
    local_134 = 0;
    while( true ) {
      local_148 = local_134;
      FUN_00402838(local_230,local_128,local_134,&DAT_004f26a8);
      local_14c = local_228;
      puVar9 = (uint *)FUN_00402298(0x10);
      if (puVar9 == (uint *)0x0) {
        local_150 = (uint *)0x0;
      }
      else {
        local_150 = FUN_00402460(puVar9,local_14c);
      }
      local_150[3] = local_150[3] + 1;
      FUN_004024d8((int *)local_230,2);
      FUN_00402a4c((int *)&local_144,(int *)&local_120,(int *)&local_150);
      uVar6 = (uint)(local_144[2] != 0);
      piVar8 = local_144 + 3;
      *piVar8 = *piVar8 + -1;
      if (*piVar8 == 0) {
        FUN_004024d8(local_144,3);
      }
      local_154 = local_150;
      puVar9 = local_150 + 3;
      *puVar9 = *puVar9 - 1;
      if (*puVar9 == 0) {
        FUN_004024d8((int *)local_150,3);
      }
      if (uVar6 == 0) break;
      pcVar7 = (char *)local_120[2];
      pcVar10 = s_location_004f26aa;
      do {
        if (*pcVar7 != *pcVar10) goto LAB_0045c510;
        bVar12 = true;
        if (*pcVar7 == '\0') break;
        pcVar1 = pcVar7 + 1;
        if (*pcVar1 != pcVar10[1]) goto LAB_0045c510;
        pcVar7 = pcVar7 + 2;
        pcVar10 = pcVar10 + 2;
        bVar12 = *pcVar1 == '\0';
      } while (!bVar12);
      if (bVar12) {
        iVar2 = FUN_00406fd4(local_138,*(int *)(param_4 + 4));
        FUN_00402a98((int *)&local_158,local_220 + local_134,(char *)(iVar2 + 0xc));
        local_15c = local_158;
        piVar8 = local_158 + 3;
        *piVar8 = *piVar8 + -1;
        if (*piVar8 == 0) {
          FUN_004024d8(local_158,3);
        }
      }
      else {
LAB_0045c510:
        pcVar10 = &DAT_004f26b3;
        pcVar7 = (char *)local_120[2];
        do {
          if (*pcVar7 != *pcVar10) goto LAB_0045c595;
          bVar12 = true;
          if (*pcVar7 == '\0') break;
          pcVar1 = pcVar7 + 1;
          if (*pcVar1 != pcVar10[1]) goto LAB_0045c595;
          pcVar7 = pcVar7 + 2;
          pcVar10 = pcVar10 + 2;
          bVar12 = *pcVar1 == '\0';
        } while (!bVar12);
        if (bVar12) {
          FUN_00402a98((int *)&local_160,local_220 + local_134,*(char **)(param_4 + 0x30));
          local_164 = local_160;
          piVar8 = local_160 + 3;
          *piVar8 = *piVar8 + -1;
          if (*piVar8 == 0) {
            FUN_004024d8(local_160,3);
          }
        }
        else {
LAB_0045c595:
          pcVar10 = s_weather_004f26b8;
          pcVar7 = (char *)local_120[2];
          do {
            if (*pcVar7 != *pcVar10) goto LAB_0045c61a;
            bVar12 = true;
            if (*pcVar7 == '\0') break;
            pcVar1 = pcVar7 + 1;
            if (*pcVar1 != pcVar10[1]) goto LAB_0045c61a;
            pcVar7 = pcVar7 + 2;
            pcVar10 = pcVar10 + 2;
            bVar12 = *pcVar1 == '\0';
          } while (!bVar12);
          if (bVar12) {
            FUN_00402a98((int *)&local_168,local_220 + local_134,*(char **)(param_4 + 0x34));
            local_16c = local_168;
            piVar8 = local_168 + 3;
            *piVar8 = *piVar8 + -1;
            if (*piVar8 == 0) {
              FUN_004024d8(local_168,3);
            }
          }
          else {
LAB_0045c61a:
            pcVar10 = s_scenario_004f26c0;
            pcVar7 = (char *)local_120[2];
            do {
              if (*pcVar7 != *pcVar10) goto LAB_0045c69f;
              bVar12 = true;
              if (*pcVar7 == '\0') break;
              pcVar1 = pcVar7 + 1;
              if (*pcVar1 != pcVar10[1]) goto LAB_0045c69f;
              pcVar7 = pcVar7 + 2;
              pcVar10 = pcVar10 + 2;
              bVar12 = *pcVar1 == '\0';
            } while (!bVar12);
            if (bVar12) {
              FUN_00402a98((int *)&local_170,local_220 + local_134,*(char **)(param_4 + 0x38));
              local_174 = local_170;
              piVar8 = local_170 + 3;
              *piVar8 = *piVar8 + -1;
              if (*piVar8 == 0) {
                FUN_004024d8(local_170,3);
              }
            }
            else {
LAB_0045c69f:
              local_178 = local_134;
              FUN_004dbb24(&DAT_00524e20,s_Mission_variable_004f26c9,(char *)0x0);
              piVar8 = FUN_004db78c(&DAT_00524e20,local_178);
              FUN_004dbb24(piVar8,&DAT_004f26db,(char *)0x0);
              local_17c = local_120;
              local_180 = (char *)local_120[2];
              FUN_004dbb24(piVar8,local_180,(char *)0x0);
              FUN_004dbb24(piVar8,s_IS_AN_UNKNOWN_MISSION_VARIABLE_004f26de,(char *)0x0);
            }
          }
        }
      }
      local_134 = local_134 + 1;
    }
    if (param_5 != 0) {
      FUN_004dbb24(&DAT_00524e20,s_comparing_to__004f26ff,(char *)0x0);
      local_184 = 0;
      if (0 < (int)local_134) {
        do {
          local_188 = local_220 + local_184;
          local_18c = *local_188;
          local_190 = *(char **)(local_18c + 8);
          FUN_004dbb24(&DAT_00524e20,local_190,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,&DAT_004f270e,(char *)0x0);
          local_184 = local_184 + 1;
        } while (local_184 < (int)local_134);
      }
      FUN_004dbb24(&DAT_00524e20,&DAT_004f2711,(char *)0x0);
    }
    local_10c = FUN_00404720((int)param_2,param_3,s_branch_004f2713);
    for (puVar3 = (undefined4 *)local_10c[1]; puVar3 != (undefined4 *)0x0;
        puVar3 = (undefined4 *)*puVar3) {
      puVar5 = (undefined4 *)FUN_00402298(0x10);
      if (puVar5 == (undefined4 *)0x0) {
        local_194 = (uint *)0x0;
      }
      else {
        local_194 = (uint *)FUN_004023f4(puVar5);
      }
      local_194[3] = local_194[3] + 1;
      puVar5 = (undefined4 *)FUN_00402298(0x10);
      if (puVar5 == (undefined4 *)0x0) {
        local_198 = (int *)0x0;
      }
      else {
        local_198 = (int *)FUN_004023f4(puVar5);
      }
      local_198[3] = local_198[3] + 1;
      FUN_00402a98((int *)&local_19c,(int *)&local_194,(char *)puVar3[1]);
      piVar8 = local_19c + 3;
      *piVar8 = *piVar8 + -1;
      if (*piVar8 == 0) {
        FUN_004024d8(local_19c,3);
      }
      if (param_5 != 0) {
        FUN_004dbb24(&DAT_00524e20,s_branch___004f271a,(char *)0x0);
        local_1a0 = local_194;
        local_1a4 = (char *)local_194[2];
        FUN_004dbb24(&DAT_00524e20,local_1a4,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,&DAT_004f2724,(char *)0x0);
      }
      local_108 = 1;
      uVar6 = 0;
      if (0 < (int)local_134) {
        do {
          local_1ac = uVar6;
          FUN_00402838(local_240,local_194,uVar6,&DAT_004f2726);
          local_1b0 = local_238;
          local_1b8 = (uint *)FUN_00402298(0x10);
          if (local_1b8 == (uint *)0x0) {
            local_1b4 = (uint *)0x0;
          }
          else {
            local_1b4 = FUN_00402460(local_1b8,local_1b0);
          }
          local_1b4[3] = local_1b4[3] + 1;
          FUN_004024d8((int *)local_240,2);
          FUN_00402a4c((int *)&local_1a8,(int *)&local_198,(int *)&local_1b4);
          piVar8 = local_1a8 + 3;
          *piVar8 = *piVar8 + -1;
          if (*piVar8 == 0) {
            FUN_004024d8(local_1a8,3);
          }
          puVar9 = local_1b4 + 3;
          *puVar9 = *puVar9 - 1;
          if (*puVar9 == 0) {
            FUN_004024d8((int *)local_1b4,3);
          }
          local_1bc = local_220 + uVar6;
          iVar2 = FUN_004027d8((int)local_198,*local_1bc);
          if ((iVar2 != 0) && (iVar2 = FUN_004027d8((int)local_198,(int)local_110), iVar2 != 0)) {
            local_108 = 0;
            break;
          }
          uVar6 = uVar6 + 1;
        } while ((int)uVar6 < (int)local_134);
      }
      if (local_108 != 0) {
        local_1c4 = uVar6;
        FUN_00402838((uint *)&stack0xfffffdb0,local_194,uVar6,&DAT_004f2728);
        local_1c8 = local_248;
        local_1d0 = (uint *)FUN_00402298(0x10);
        if (local_1d0 == (uint *)0x0) {
          local_1cc = (uint *)0x0;
        }
        else {
          local_1cc = FUN_00402460(local_1d0,local_1c8);
        }
        local_1cc[3] = local_1cc[3] + 1;
        FUN_004024d8((int *)&stack0xfffffdb0,2);
        FUN_00402a4c((int *)&local_1c0,(int *)&local_198,(int *)&local_1cc);
        local_1d4 = local_1c0;
        piVar8 = local_1c0 + 3;
        *piVar8 = *piVar8 + -1;
        if (*piVar8 == 0) {
          FUN_004024d8(local_1c0,3);
        }
        local_1d8 = local_1cc;
        puVar9 = local_1cc + 3;
        *puVar9 = *puVar9 - 1;
        if (*puVar9 == 0) {
          FUN_004024d8((int *)local_1cc,3);
        }
        FUN_0045b1b8((int)piVar11,param_2,(char *)local_198[2],param_4,param_5);
        if (param_5 != 0) {
          local_1dc = param_3;
          FUN_004dbb24(&DAT_00524e20,s_DPLReadINIPage_returned_to_004f272a,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,local_1dc,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,&DAT_004f2746,(char *)0x0);
        }
        local_1e0 = local_198;
        piVar11 = local_198 + 3;
        *piVar11 = *piVar11 + -1;
        if (*piVar11 == 0) {
          FUN_004024d8(local_198,3);
        }
        local_1e4 = local_194;
        puVar9 = local_194 + 3;
        *puVar9 = *puVar9 - 1;
        if (*puVar9 == 0) {
          FUN_004024d8((int *)local_194,3);
        }
        break;
      }
      piVar8 = local_198 + 3;
      *piVar8 = *piVar8 + -1;
      if (*piVar8 == 0) {
        FUN_004024d8(local_198,3);
      }
      puVar9 = local_194 + 3;
      *puVar9 = *puVar9 - 1;
      if (*puVar9 == 0) {
        FUN_004024d8((int *)local_194,3);
      }
    }
    if (local_10c != (int *)0x0) {
      (**(code **)*local_10c)(local_10c,3);
    }
    if (local_108 == 0) {
      local_1e8 = (char *)*param_2;
      FUN_004dbb24(&DAT_00524e20,s_BRANCH_ERROR_IN___004f2748,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_1e8,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s___NO_MATCH_FOUND___004f275a,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
    }
    local_1ec = local_128;
    puVar9 = local_128 + 3;
    *puVar9 = *puVar9 - 1;
    if (*puVar9 == 0) {
      FUN_004024d8((int *)local_128,3);
    }
    local_1f0 = local_120;
    piVar11 = local_120 + 3;
    *piVar11 = *piVar11 + -1;
    if (*piVar11 == 0) {
      FUN_004024d8(local_120,3);
    }
    local_1f4 = local_118;
    piVar11 = local_118 + 3;
    *piVar11 = *piVar11 + -1;
    if (*piVar11 == 0) {
      FUN_004024d8(local_118,3);
    }
    local_1f8 = local_110;
    puVar9 = local_110 + 3;
    *puVar9 = *puVar9 - 1;
    if (*puVar9 == 0) {
      FUN_004024d8((int *)local_110,3);
    }
    FUN_004de8d4(local_220,4,10,1,FUN_004612b0);
  }
  return;
}



/* @0045ce5c file=? name=FUN_0045ce5c */

void __cdecl FUN_0045ce5c(int param_1,int param_2)

{
  char *pcVar1;
  int *piVar2;
  int iVar3;
  int extraout_var;
  int iVar4;
  
  pcVar1 = (char *)FUN_004dee74(s_L4DPLCFG_004f276d);
  iVar4 = extraout_var;
  if (pcVar1 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_L4DPLCFG_not_defined__using_dpld_004f2776,(char *)0x0);
    pcVar1 = s_dpldflt_ini_004f27a0;
  }
  piVar2 = (int *)FUN_00402298(0x20);
  if (piVar2 == (int *)0x0) {
    piVar2 = (int *)0x0;
  }
  else {
    piVar2 = FUN_00403e84(piVar2,pcVar1,1);
  }
  if ((*(byte *)(piVar2 + 7) & 2) == 0) {
    iVar3 = piVar2[3];
  }
  else {
    iVar3 = piVar2[4];
  }
  if (iVar3 == 0) {
    FUN_004dbb24(&DAT_00524e20,s_Renderer_config_notation_file_004f27ac,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,pcVar1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_was_empty__can_t_continue_004f27cb,(char *)0x0);
  }
  iVar3 = FUN_00403f84((int)piVar2,&DAT_004f27e6);
  if (iVar3 == 0) {
    iVar3 = FUN_00404190((int)piVar2,s_dpl_config_004f27fb,s_debug_004f2806,
                         (undefined4 *)&stack0xfffffff8);
    if (iVar3 == 0) {
      iVar4 = 0;
    }
    pcVar1 = (char *)*piVar2;
    FUN_004dbb24(&DAT_00524e20,s_READING_OLD_FORMAT_INI_FILE___004f280c,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,pcVar1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_____hope_this_works_004f282a,(char *)0x0);
    FUN_00497b4c(s___video_004f283f,(char *)0x0,(char *)0x0);
    FUN_00498ce8(s___video_004f2847,(char *)0x0,(char *)0x0);
    FUN_004978d4(s___video_004f284f,(char *)0x0,(char *)0x0);
    FUN_0045b1b8(param_1,piVar2,s_dpl_config_004f2857,param_2,iVar4);
  }
  else {
    iVar3 = FUN_00404190((int)piVar2,&DAT_004f27eb,s_debug_004f27f0,(undefined4 *)&stack0xfffffff8);
    if (iVar3 == 0) {
      iVar4 = 0;
    }
    FUN_0045b1b8(param_1,piVar2,&DAT_004f27f6,param_2,iVar4);
  }
  if (iVar4 != 0) {
    pcVar1 = (char *)FUN_00497b88();
    FUN_004dbb24(&DAT_00524e20,s_ObjectFilePath___004f2862,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,pcVar1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f2875,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    pcVar1 = (char *)FUN_00498d24();
    FUN_004dbb24(&DAT_00524e20,s_TexmapFilePath___004f2877,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,pcVar1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f288a,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    pcVar1 = (char *)FUN_00497910();
    FUN_004dbb24(&DAT_00524e20,s_MaterialFilePath___004f288c,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,pcVar1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f289f,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  FUN_00403ecc(piVar2,3);
  FUN_0048d42c(*(undefined4 **)(param_1 + 0x124));
  return;
}



/* @0045d0f4 file=? name=FUN_0045d0f4 */

void __cdecl FUN_0045d0f4(int *param_1,byte param_2)

{
  int *piVar1;
  int iVar2;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f330c;
    FUN_0045ff4c((undefined4 *)0x0,0,0,0);
    iVar2 = 0;
    piVar1 = param_1 + 0xb3;
    do {
      if ((int *)*piVar1 != (int *)0x0) {
        FUN_004022d0((int *)*piVar1);
        *piVar1 = 0;
      }
      iVar2 = iVar2 + 1;
      piVar1 = piVar1 + 1;
    } while (iVar2 < 0x28);
    if ((int *)param_1[0xf4] != (int *)0x0) {
      FUN_00489938((int *)param_1[0xf4]);
    }
    if ((param_1[0xf6] != 0) && (param_1[0xf5] != 0)) {
      for (iVar2 = 0; iVar2 < param_1[0xf7]; iVar2 = iVar2 + 1) {
        FUN_00489e58(*(int *)(param_1[0xf6] + iVar2 * 4));
        FUN_004898b8(*(int **)(param_1[0xf6] + iVar2 * 4));
      }
      FUN_004022e8((int *)param_1[0xf5]);
      FUN_004022e8((int *)param_1[0xf6]);
    }
    FUN_00401c70(DAT_004f1ab0,3);
    DAT_004f1ab0 = (int *)0x0;
    FUN_0041c44b(param_1 + 0xef,2);
    FUN_00461431(param_1 + 0xe9,2);
    FUN_0046134b(param_1 + 0xe4,2);
    FUN_004612fc(param_1 + 0xdf,2);
    FUN_004368f4(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0045d228 file=? name=FUN_0045d228 */

undefined4 __cdecl FUN_0045d228(int param_1)

{
  FUN_00436b00(param_1);
  return 1;
}



/* @0045d23c file=? name=FUN_0045d23c */

void __cdecl FUN_0045d23c(undefined4 param_1,byte *param_2)

{
  int iVar1;
  undefined4 *puVar2;
  int local_8;
  
  iVar1 = FUN_00497730(s_bmap_bmap1_tex_004f28a1,0,&local_8);
  if (iVar1 == 0) {
    FUN_004dbb24(&DAT_00524e20,s_WARNING__textures_for_player_nam_004f28b0,(char *)0x0);
  }
  else {
    puVar2 = (undefined4 *)FUN_0048c2f0(iVar1);
    if (puVar2 == (undefined4 *)0x0) {
      FUN_004dbb24(&DAT_00524e20,s_WARNING__texmap_for_player_names_004f28e0,(char *)0x0);
    }
    else {
      FUN_0048c460((int)puVar2,param_2,0x80,0x40);
      FUN_0048d5b0(puVar2);
    }
  }
  return;
}



/* @0045d2b4 file=? name=FUN_0045d2b4 */

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

{
  int iVar1;
  int iVar2;
  ushort *puVar3;
  uint local_10;
  uint local_c;
  int local_8;
  
  puVar3 = *(ushort **)(param_2 + 0x18);
  if ((param_3 & 1) != 0) {
    param_4 = param_4 + 0x1000;
  }
  switch(param_3) {
  case 1:
  case 2:
    local_c = 0xf000;
    local_10 = 0xffff0fff;
    break;
  case 3:
  case 4:
    local_c = 0xf00;
    local_10 = 0xfffff0ff;
    break;
  case 5:
  case 6:
    local_c = 0xf00000;
    local_10 = 0xff0fffff;
    break;
  case 7:
  case 8:
    local_c = 0xf0000;
    local_10 = 0xfff0ffff;
    break;
  case 9:
  case 10:
    local_c = 0xf0000000;
    local_10 = 0xfffffff;
    break;
  case 0xb:
  case 0xc:
    local_c = 0xf000000;
    local_10 = 0xf0ffffff;
  }
  iVar1 = 0xf;
  local_8 = 0;
  do {
    iVar2 = 0;
    do {
      if ((1 << ((byte)iVar1 & 0x1f) & (uint)*puVar3) == 0) {
        *param_4 = *param_4 & local_10;
      }
      else {
        *param_4 = *param_4 | local_c;
      }
      param_4 = param_4 + 1;
      iVar1 = iVar1 + -1;
      if (iVar1 < 0) {
        iVar1 = 0xf;
        puVar3 = puVar3 + 1;
      }
      iVar2 = iVar2 + 1;
    } while (iVar2 < 0x80);
    local_8 = local_8 + 1;
  } while (local_8 < 0x20);
  return;
}



/* @0045d3cc file=? name=FUN_0045d3cc */

void __cdecl FUN_0045d3cc(undefined4 param_1,int param_2)

{
  if ((param_2 != 0x68) && (param_2 != 0x6a)) {
    return;
  }
  FUN_00498448(s_flamebig_bgf_004f290e,0);
  FUN_00498448(s_thrdbr_bgf_004f291b,0);
  FUN_00498448(s_ldbr_bgf_004f2926,0);
  FUN_00498448(s_flamesml_bgf_004f292f,0);
  return;
}



/* @0045d41c file=munga_l4/l4video.cpp name=FUN_0045d41c */

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

{
  undefined4 *puVar1;
  int iVar2;
  undefined4 *puVar3;
  undefined4 local_39c;
  undefined4 local_398;
  undefined4 local_394;
  undefined4 local_390;
  undefined4 local_38c;
  undefined4 local_388;
  undefined4 local_384 [12];
  undefined4 local_354;
  undefined4 local_350;
  undefined4 local_34c;
  undefined4 local_348 [12];
  undefined4 local_318;
  undefined4 local_314;
  undefined4 local_310;
  undefined4 local_30c [12];
  undefined4 local_2dc;
  undefined4 local_2d8;
  undefined4 local_2d4;
  undefined4 local_2d0;
  undefined4 local_2cc;
  undefined4 local_2c8;
  float local_2c4 [18];
  undefined4 local_27c [12];
  undefined4 local_24c;
  undefined4 local_248;
  undefined4 local_244;
  undefined4 local_240;
  undefined4 local_23c;
  undefined4 local_238;
  undefined4 local_234;
  undefined4 local_230;
  undefined4 local_22c;
  undefined4 local_228;
  undefined4 local_224;
  undefined4 local_220;
  float local_21c [18];
  undefined4 local_1d4 [12];
  undefined4 local_1a4;
  undefined4 local_1a0;
  undefined4 local_19c;
  undefined4 local_198;
  undefined4 local_194;
  undefined4 local_190;
  undefined4 local_18c;
  undefined4 local_188;
  undefined4 local_184;
  undefined4 local_180;
  undefined4 local_17c;
  undefined4 local_178;
  undefined4 local_174 [12];
  undefined4 local_144;
  undefined4 local_140;
  undefined4 local_13c;
  undefined4 local_138;
  undefined4 local_134;
  undefined4 local_130;
  undefined4 *local_12c;
  undefined4 *local_128;
  undefined4 *local_124;
  undefined4 *local_120;
  int local_11c;
  undefined4 *local_118;
  int local_114;
  undefined4 *local_110;
  int local_10c;
  undefined4 *local_108;
  undefined4 *local_104;
  undefined4 *local_100;
  undefined4 *local_fc;
  undefined4 *local_f8;
  undefined4 *local_f4;
  undefined4 *local_f0;
  int local_ec;
  undefined4 *local_e8;
  undefined4 *local_e4;
  undefined4 *local_e0;
  int local_dc;
  undefined4 *local_d8;
  undefined4 *local_d4;
  undefined4 *local_d0;
  undefined4 *local_cc;
  undefined4 *local_c8;
  undefined4 *local_c4;
  undefined4 *local_c0;
  undefined4 *local_bc;
  int local_b8;
  int local_b4;
  int local_b0;
  undefined4 *local_ac;
  undefined4 *local_a8;
  undefined4 *local_a4;
  undefined4 *local_a0;
  int local_9c;
  int local_98;
  undefined4 *local_94;
  undefined4 *local_90;
  undefined4 *local_8c;
  undefined4 *local_88;
  undefined4 *local_84;
  undefined4 *local_80;
  undefined4 *local_7c;
  undefined4 *local_78;
  int local_74;
  undefined4 *local_70;
  undefined4 *local_6c;
  undefined4 *local_68;
  undefined4 *local_64;
  undefined4 *local_60;
  undefined4 *local_5c;
  undefined4 local_58;
  undefined4 local_54;
  undefined4 local_50;
  undefined4 *local_4c;
  undefined4 *local_48;
  int local_44;
  undefined4 *local_40;
  undefined4 *local_3c;
  undefined4 *local_38;
  undefined4 *local_34;
  undefined4 *local_30;
  undefined4 *local_2c;
  undefined4 local_28;
  undefined4 local_24;
  undefined4 local_20;
  undefined4 *local_1c;
  int local_18;
  undefined4 *local_14;
  undefined4 *local_10;
  undefined4 *local_c;
  int local_8;
  
  puVar1 = (undefined4 *)FUN_00402298(100);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_00453578(puVar1,param_2,1,0,*(undefined4 *)(param_1 + 300),1,0);
  }
  switch(param_5) {
  case 0:
    local_8 = FUN_00498448(s_shock_bgf_004f293c,0);
    local_138 = 0x40600000;
    local_134 = 0x40600000;
    local_130 = 0x40600000;
    local_144 = 0;
    local_140 = 0;
    local_13c = 0;
    FUN_0040aadc(local_174);
    local_10 = (undefined4 *)FUN_00402298(0xa8);
    if (local_10 == (undefined4 *)0x0) {
      local_c = (undefined4 *)0x0;
    }
    else {
      local_c = FUN_00455930(local_10,param_2,1,local_8,*(undefined4 *)(param_1 + 300),1,0,
                             puVar1[0xb],local_174,&local_138,&local_144,0,0);
    }
    puVar1 = (undefined4 *)FUN_00402298(0x48);
    if (puVar1 == (undefined4 *)0x0) {
      local_14 = (undefined4 *)0x0;
    }
    else {
      local_14 = FUN_00456610(puVar1,param_2,1,0x3f000000,1,(undefined4 *)0x0,0,0x3f800000,0);
    }
    iVar2 = FUN_00497730(s_btfx_firesmoke1_scr_tex_004f2946,0,&local_18);
    if (iVar2 == 0) {
      FUN_004dbb24(&DAT_00524e20,s_couldn_t_find_texture_btfx_fires_004f295e,(char *)0x0);
    }
    puVar1 = (undefined4 *)FUN_00402298(0xfc);
    if (puVar1 == (undefined4 *)0x0) {
      local_1c = (undefined4 *)0x0;
    }
    else {
      local_1c = FUN_00456cf0(puVar1,param_2,1,0x3f800000,0x3f800000,0x3f800000,0x3f800000,
                              0x3f800000,0x3f800000,0x3f800000,0x3f800000,0x3f800000,0,0,0,0,
                              0x40800000,0x3e4ccccd,0xbd4ccccd,iVar2,0.0,0,0x3f000000,0x3f000000,
                              0x3f000000,0x3f000000,0x3f000000,0x3f000000,0x3f000000,0x3f000000,
                              0x3f000000,0,0,0,0,0x3dcccccd,0x3dcccccd,0xbd4ccccd,0,local_14 + 0x11)
      ;
    }
    puVar1 = (undefined4 *)FUN_0048a38c(local_c[0xb],1);
    if (puVar1 == (undefined4 *)0x0) {
      FUN_0040385c(s_explosion_1_instance_came_back_n_004f299b,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f29c0,0xb58);
    }
    FUN_0048ae48((int)puVar1,local_1c[7]);
    FUN_0048d5d4(puVar1);
    break;
  case 1:
    local_8 = FUN_00498448(s_exp_bgf_004f29e1,0);
    local_180 = 0x3e19999a;
    local_17c = 0x3e19999a;
    local_178 = 0x3e19999a;
    local_18c = 0x3e3851ec;
    local_188 = 0x3e6147ae;
    local_184 = 0x3e3851ec;
    local_198 = 0;
    local_194 = 0;
    local_190 = 0;
    local_1a4 = 0;
    local_1a0 = 0;
    local_19c = 0;
    FUN_0040aadc(local_1d4);
    FUN_0040aadc(local_21c + 6);
    local_21c[3] = 0.0;
    local_21c[4] = 0.0;
    local_21c[5] = 0.0;
    local_20 = 0;
    local_24 = 0x3f800000;
    local_28 = 0;
    local_21c[0] = 0.0;
    local_21c[1] = 1.0;
    local_21c[2] = 0.0;
    FUN_0040ac6c(local_21c + 6,local_21c);
    FUN_0040b0ac((int)(local_21c + 6),3,local_21c + 3);
    local_30 = (undefined4 *)FUN_00402298(0xa8);
    if (local_30 == (undefined4 *)0x0) {
      local_2c = (undefined4 *)0x0;
    }
    else {
      local_2c = FUN_00455930(local_30,param_2,1,local_8,*(undefined4 *)(param_1 + 300),1,0,
                              puVar1[0xb],local_1d4,&local_180,&local_198,0,0);
    }
    local_38 = (undefined4 *)FUN_00402298(0xa8);
    if (local_38 == (undefined4 *)0x0) {
      local_34 = (undefined4 *)0x0;
    }
    else {
      local_34 = FUN_00455930(local_38,param_2,1,local_8,*(undefined4 *)(param_1 + 300),1,0,
                              puVar1[0xb],local_21c + 6,&local_18c,&local_1a4,0,0);
    }
    puVar1 = (undefined4 *)FUN_00402298(0x48);
    if (puVar1 == (undefined4 *)0x0) {
      local_3c = (undefined4 *)0x0;
    }
    else {
      local_3c = FUN_00456610(puVar1,param_2,1,0x40400000,1,(undefined4 *)0x0,0,0x3f800000,0);
    }
    puVar1 = (undefined4 *)FUN_00402298(0x48);
    if (puVar1 == (undefined4 *)0x0) {
      local_40 = (undefined4 *)0x0;
    }
    else {
      local_40 = FUN_00456610(puVar1,param_2,1,0x40000000,1,(undefined4 *)0x0,0,0x3f800000,0);
    }
    iVar2 = FUN_00497730(s_btfx_firesmoke1_scr_tex_004f29e9,0,&local_44);
    if (iVar2 == 0) {
      FUN_004dbb24(&DAT_00524e20,s_couldn_t_find_texture_btfx_fires_004f2a01,(char *)0x0);
    }
    puVar1 = (undefined4 *)FUN_00402298(0xfc);
    if (puVar1 == (undefined4 *)0x0) {
      local_48 = (undefined4 *)0x0;
    }
    else {
      local_48 = FUN_00456cf0(puVar1,param_2,1,0x3f666666,0,0,0x3f800000,0x3e4ccccd,0,0x3f800000,
                              0x3e4ccccd,0,0,0,0,0,0x41200000,0x3f19999a,0xbd4ccccd,iVar2,0.0,0,
                              0x3e99999a,0,0,0x3f000000,0,0,0x3e4ccccd,0,0,0,0,0,0,0x3e800000,
                              0x3e800000,0xbd4ccccd,0x41700000,local_3c + 0x11);
    }
    puVar1 = (undefined4 *)FUN_00402298(0xfc);
    if (puVar1 == (undefined4 *)0x0) {
      local_4c = (undefined4 *)0x0;
    }
    else {
      local_4c = FUN_00456cf0(puVar1,param_2,1,0x3f666666,0,0,0x3f800000,0x3f19999a,0x3e99999a,
                              0x3f800000,0x3ecccccd,0x3e4ccccd,0,0,0,0,0x41000000,0x3e4ccccd,
                              0xbd4ccccd,iVar2,0.0,0,0x3dcccccd,0,0,0,0,0,0x3dcccccd,0,0,0,0,0,0,
                              0x3e800000,0x3e800000,0xbd4ccccd,0x41700000,local_40 + 0x11);
    }
    puVar1 = (undefined4 *)FUN_0048a38c(local_2c[0xb],1);
    puVar3 = (undefined4 *)FUN_0048a38c(local_34[0xb],1);
    if (puVar1 == (undefined4 *)0x0) {
      FUN_0040385c(s_explosion_1_instance_came_back_n_004f2a3e,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f2a63,0xbe6);
    }
    if (puVar3 == (undefined4 *)0x0) {
      FUN_0040385c(s_explosion_2_instance_came_back_n_004f2a84,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f2aa9,0xbe8);
    }
    FUN_0048ae48((int)puVar1,local_48[7]);
    FUN_0048ae48((int)puVar3,local_4c[7]);
    FUN_0048d5d4(puVar1);
    FUN_0048d5d4(puVar3);
    break;
  case 2:
    local_8 = FUN_00498448(s_exp_bgf_004f2aca,0);
    local_228 = 0x3f800000;
    local_224 = 0x3e4ccccd;
    local_220 = 0x3f800000;
    local_234 = 0x3f400000;
    local_230 = 0x3f400000;
    local_22c = 0x3f400000;
    local_240 = 0xbbed9168;
    local_23c = 0xbb83126f;
    local_238 = 0xbbed9168;
    local_24c = 0xbc6368f1;
    local_248 = 0xbc6368f1;
    local_244 = 0xbc6368f1;
    FUN_0040aadc(local_27c);
    FUN_0040aadc(local_2c4 + 6);
    local_2c4[3] = 0.0;
    local_2c4[4] = 0.0;
    local_2c4[5] = 0.0;
    local_50 = 0;
    local_54 = 0x3f800000;
    local_58 = 0;
    local_2c4[0] = 0.0;
    local_2c4[1] = 1.0;
    local_2c4[2] = 0.0;
    FUN_0040ac6c(local_2c4 + 6,local_2c4);
    FUN_0040b0ac((int)(local_2c4 + 6),3,local_2c4 + 3);
    local_60 = (undefined4 *)FUN_00402298(0xa8);
    if (local_60 == (undefined4 *)0x0) {
      local_5c = (undefined4 *)0x0;
    }
    else {
      local_5c = FUN_00455930(local_60,param_2,1,local_8,*(undefined4 *)(param_1 + 300),1,0,
                              puVar1[0xb],local_27c,&local_228,&local_240,0,0);
    }
    local_68 = (undefined4 *)FUN_00402298(0xa8);
    if (local_68 == (undefined4 *)0x0) {
      local_64 = (undefined4 *)0x0;
    }
    else {
      local_64 = FUN_00455930(local_68,param_2,1,local_8,*(undefined4 *)(param_1 + 300),1,0,
                              puVar1[0xb],local_2c4 + 6,&local_234,&local_24c,0,0);
    }
    puVar1 = (undefined4 *)FUN_00402298(0x48);
    if (puVar1 == (undefined4 *)0x0) {
      local_6c = (undefined4 *)0x0;
    }
    else {
      local_6c = FUN_00456610(puVar1,param_2,1,0x40400000,1,(undefined4 *)0x0,0,0x3f800000,0);
    }
    puVar1 = (undefined4 *)FUN_00402298(0x48);
    if (puVar1 == (undefined4 *)0x0) {
      local_70 = (undefined4 *)0x0;
    }
    else {
      local_70 = FUN_00456610(puVar1,param_2,1,0x40000000,1,(undefined4 *)0x0,0,0x3f800000,0);
    }
    iVar2 = FUN_00497730(s_btfx_firesmoke1_scr_tex_004f2ad2,0,&local_74);
    if (iVar2 == 0) {
      FUN_004dbb24(&DAT_00524e20,s_couldn_t_find_texture_btfx_fires_004f2aea,(char *)0x0);
    }
    local_7c = (undefined4 *)FUN_00402298(0xfc);
    if (local_7c == (undefined4 *)0x0) {
      local_78 = (undefined4 *)0x0;
    }
    else {
      local_78 = FUN_00456cf0(local_7c,param_2,1,0x3f666666,0,0,0x3f800000,0x3e4ccccd,0,0x3f800000,
                              0x3e4ccccd,0,0,0,0,0,0x41000000,0x3e4ccccd,0xbd4ccccd,iVar2,0.0,0,
                              0x3e99999a,0,0,0x3f000000,0,0,0x3e4ccccd,0,0,0,0,0,0,0x3e800000,
                              0x3e800000,0xbd4ccccd,0x41700000,local_6c + 0x11);
    }
    local_84 = (undefined4 *)FUN_00402298(0xfc);
    if (local_84 == (undefined4 *)0x0) {
      local_80 = (undefined4 *)0x0;
    }
    else {
      local_80 = FUN_00456cf0(local_84,param_2,1,0x3f666666,0,0,0x3f800000,0x3f19999a,0x3ecccccd,
                              0x3f800000,0x3e99999a,0x3e4ccccd,0,0,0,0,0x41000000,0x3e4ccccd,
                              0xbd4ccccd,iVar2,0.0,0,0x3dcccccd,0,0,0,0,0,0,0,0,0,0,0,0,0x3e800000,
                              0x3e800000,0xbd4ccccd,0x41700000,local_70 + 0x11);
    }
    puVar1 = (undefined4 *)FUN_0048a38c(local_5c[0xb],1);
    puVar3 = (undefined4 *)FUN_0048a38c(local_64[0xb],1);
    if (puVar1 == (undefined4 *)0x0) {
      FUN_0040385c(s_explosion_1_instance_came_back_n_004f2b27,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f2b4c,0xc7b);
    }
    if (puVar3 == (undefined4 *)0x0) {
      FUN_0040385c(s_explosion_2_instance_came_back_n_004f2b6d,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f2b92,0xc7d);
    }
    FUN_0048ae48((int)puVar1,local_78[7]);
    FUN_0048ae48((int)puVar3,local_80[7]);
    FUN_0048d5d4(puVar1);
    FUN_0048d5d4(puVar3);
    break;
  case 3:
    local_8 = FUN_00498448(s_spk1_bgf_004f2bb3,0);
    local_2d0 = 0x3dcccccd;
    local_2cc = 0x3dcccccd;
    local_2c8 = 0x3dcccccd;
    local_2dc = 0;
    local_2d8 = 0;
    local_2d4 = 0;
    FUN_0040aadc(local_30c);
    local_8c = (undefined4 *)FUN_00402298(0xa8);
    if (local_8c == (undefined4 *)0x0) {
      local_88 = (undefined4 *)0x0;
    }
    else {
      local_88 = FUN_00455930(local_8c,param_2,1,local_8,*(undefined4 *)(param_1 + 300),1,0,
                              puVar1[0xb],local_30c,&local_2d0,&local_2dc,0xbe19999a,0);
    }
    local_94 = (undefined4 *)FUN_00402298(0x48);
    if (local_94 == (undefined4 *)0x0) {
      local_90 = (undefined4 *)0x0;
    }
    else {
      local_90 = FUN_00456610(local_94,param_2,1,0x3f000000,1,(undefined4 *)0x0,0,0x3f800000,0);
    }
    local_9c = FUN_00497730(s_btfx_firesmoke1_scr_tex_004f2bbc,0,&local_98);
    if (local_9c == 0) {
      FUN_004dbb24(&DAT_00524e20,s_couldn_t_find_texture_btfx_fires_004f2bd4,(char *)0x0);
    }
    local_a4 = (undefined4 *)FUN_00402298(0xfc);
    if (local_a4 == (undefined4 *)0x0) {
      local_a0 = (undefined4 *)0x0;
    }
    else {
      local_a0 = FUN_00456cf0(local_a4,param_2,1,0x3f800000,0x3f800000,0,0x3f800000,0x3f800000,0,
                              0x3f800000,0x3f800000,0,0,0,0,0,0x3f800000,0x3f800000,0x3f800000,
                              local_9c,0.0,2,0x3f666666,0,0,0x3f666666,0,0,0x3f666666,0,0,0,0,0,0,
                              0x3f800000,0x3f800000,0x3f800000,0,local_90 + 0x11);
    }
    puVar1 = (undefined4 *)FUN_0048a38c(local_88[0xb],1);
    if (puVar1 == (undefined4 *)0x0) {
      FUN_0040385c(s_explosion_1_instance_came_back_n_004f2c11,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f2c36,0xcd1);
    }
    FUN_0048ae48((int)puVar1,local_a0[7]);
    FUN_0048d5d4(puVar1);
    break;
  case 4:
    local_318 = 0;
    local_314 = 0;
    local_310 = 0;
    FUN_0040aadc(local_348);
    local_354 = 0;
    local_350 = 0x40c66666;
    local_34c = 0;
    FUN_0040aadc(local_384);
    FUN_0040b0ac((int)local_384,3,&local_354);
    local_ac = (undefined4 *)FUN_00402298(0x50);
    if (local_ac == (undefined4 *)0x0) {
      local_a8 = (undefined4 *)0x0;
    }
    else {
      local_a8 = FUN_0045848c(local_ac,param_2,*(int *)(param_1 + 300),0,1,0,local_384,puVar1[0xb]);
    }
    local_b0 = FUN_00498448(s_thrdbr_bgf_004f2c57,0);
    local_b4 = FUN_00498448(s_ldbr_bgf_004f2c62,0);
    local_b8 = FUN_00498448(s_flamesml_bgf_004f2c6b,0);
    local_c0 = (undefined4 *)FUN_00402298(0x30);
    if (local_c0 == (undefined4 *)0x0) {
      local_bc = (undefined4 *)0x0;
    }
    else {
      local_bc = FUN_004564a8(local_c0,param_2,1,0.55,0.0);
    }
    local_390 = 0xbf800000;
    local_38c = 0x40a00000;
    local_388 = 0xbf800000;
    local_c4 = (undefined4 *)FUN_00402298(0x38);
    if (local_c4 != (undefined4 *)0x0) {
      FUN_00456868(local_c4,param_2,1,local_bc + 0xb,0xf,local_a8[4],&local_390);
    }
    local_cc = (undefined4 *)FUN_00402298(0x30);
    if (local_cc == (undefined4 *)0x0) {
      local_c8 = (undefined4 *)0x0;
    }
    else {
      local_c8 = FUN_004564a8(local_cc,param_2,1,0.25,0.0);
    }
    local_d4 = (undefined4 *)FUN_00402298(0x50);
    if (local_d4 == (undefined4 *)0x0) {
      local_d0 = (undefined4 *)0x0;
    }
    else {
      local_d0 = FUN_0045848c(local_d4,param_2,*(int *)(param_1 + 300),local_b0,1,0,local_348,
                              puVar1[0xb]);
    }
    local_d8 = (undefined4 *)FUN_00402298(0x40);
    if (local_d8 != (undefined4 *)0x0) {
      FUN_0045635c(local_d8,param_2,1,local_d0[4],-0.025,local_c8 + 0xb);
    }
    local_dc = FUN_0048a38c(local_d0[4],1);
    local_e0 = (undefined4 *)FUN_00402298(0x2c);
    if (local_e0 != (undefined4 *)0x0) {
      FUN_0045612c(local_e0,param_2,1,local_dc,1,local_c8 + 0xb);
    }
    local_e8 = (undefined4 *)FUN_00402298(0x50);
    if (local_e8 == (undefined4 *)0x0) {
      local_e4 = (undefined4 *)0x0;
    }
    else {
      local_e4 = FUN_0045848c(local_e8,param_2,*(int *)(param_1 + 300),local_b4,1,0,local_348,
                              local_d0[4]);
    }
    local_ec = FUN_0048a38c(local_e4[4],1);
    local_f0 = (undefined4 *)FUN_00402298(0x2c);
    if (local_f0 != (undefined4 *)0x0) {
      FUN_0045612c(local_f0,param_2,1,local_ec,1,local_c8 + 0xb);
    }
    local_f8 = (undefined4 *)FUN_00402298(0x30);
    if (local_f8 == (undefined4 *)0x0) {
      local_f4 = (undefined4 *)0x0;
    }
    else {
      local_f4 = FUN_004564a8(local_f8,param_2,1,0.25,0.0);
    }
    local_fc = (undefined4 *)FUN_00402298(0x50);
    if (local_fc == (undefined4 *)0x0) {
      puVar1 = (undefined4 *)0x0;
    }
    else {
      puVar1 = FUN_0045848c(local_fc,param_2,*(int *)(param_1 + 300),0,1,0,local_348,puVar1[0xb]);
    }
    local_100 = (undefined4 *)FUN_00402298(0x40);
    if (local_100 != (undefined4 *)0x0) {
      FUN_0045635c(local_100,param_2,1,puVar1[4],-0.01,local_f4 + 0xb);
    }
    local_108 = (undefined4 *)FUN_00402298(0x50);
    if (local_108 == (undefined4 *)0x0) {
      local_104 = (undefined4 *)0x0;
    }
    else {
      local_104 = FUN_0045848c(local_108,param_2,*(int *)(param_1 + 300),local_b8,1,0,local_348,
                               puVar1[4]);
    }
    local_10c = FUN_0048a38c(local_104[4],1);
    local_110 = (undefined4 *)FUN_00402298(0x2c);
    if (local_110 != (undefined4 *)0x0) {
      FUN_0045612c(local_110,param_2,1,local_10c,1,local_f4 + 0xb);
    }
    local_114 = FUN_00498448(s_flamebig_bgf_004f2c78,0);
    local_118 = (undefined4 *)FUN_00402298(0x50);
    if (local_118 == (undefined4 *)0x0) {
      puVar1 = (undefined4 *)0x0;
    }
    else {
      puVar1 = FUN_0045848c(local_118,param_2,*(int *)(param_1 + 300),local_114,1,0,local_348,
                            puVar1[4]);
    }
    FUN_0048a674(puVar1[4],2);
    FUN_0048d3e8((undefined4 *)puVar1[4]);
    local_11c = FUN_0048a38c(puVar1[4],1);
    local_120 = (undefined4 *)FUN_00402298(0x2c);
    if (local_120 != (undefined4 *)0x0) {
      FUN_0045612c(local_120,param_2,1,local_11c,1,local_f4 + 0xb);
    }
    break;
  case 5:
    local_39c = 0;
    local_398 = 0;
    local_394 = 0;
    local_128 = (undefined4 *)FUN_00402298(0x30);
    if (local_128 == (undefined4 *)0x0) {
      local_124 = (undefined4 *)0x0;
    }
    else {
      local_124 = FUN_004564a8(local_128,param_2,1,0.15,0.0);
    }
    local_12c = (undefined4 *)FUN_00402298(0x38);
    if (local_12c != (undefined4 *)0x0) {
      FUN_00456868(local_12c,param_2,1,local_124 + 0xb,0xc,puVar1[0xb],&local_39c);
    }
    break;
  case 6:
    FUN_004dbb24(&DAT_00524e20,s_Explosion_effect_104_called__thi_004f2c85,(char *)0x0);
  }
  return;
}



/* @0045e744 file=? name=FUN_0045e744 */

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

{
  uint uVar1;
  undefined4 *puVar2;
  int iVar3;
  undefined4 *puVar4;
  undefined4 local_1e0 [12];
  undefined4 local_1b0 [12];
  undefined4 local_180 [12];
  int local_150 [3];
  int local_144 [4];
  uint local_134;
  undefined4 *local_130;
  undefined4 *local_12c;
  undefined4 *local_128;
  undefined4 *local_124;
  undefined4 *local_120;
  undefined4 *local_11c;
  undefined4 *local_118;
  undefined4 *local_114;
  undefined4 *local_110;
  char *local_10c;
  char *local_108;
  int local_104;
  undefined4 *local_100;
  undefined4 *local_fc;
  undefined4 local_f8;
  undefined4 local_f4;
  int local_f0;
  undefined4 *local_ec;
  undefined4 *local_e8;
  undefined4 *local_e4;
  undefined4 *local_e0;
  undefined4 *local_dc;
  undefined4 *local_d8;
  undefined4 *local_d4;
  undefined4 *local_d0;
  undefined4 *local_cc;
  undefined4 *local_c8;
  int local_c4;
  undefined4 *local_c0;
  int local_bc;
  int local_b8;
  int local_b4;
  int local_b0;
  int local_ac;
  int local_a8;
  int local_a4;
  int local_a0;
  undefined4 *local_9c;
  undefined4 *local_98;
  undefined4 *local_94;
  undefined4 *local_90;
  int local_8c;
  int local_88;
  int local_84;
  undefined4 *local_80;
  char *local_7c;
  undefined4 *local_78;
  char *local_74;
  int local_70;
  undefined4 *local_6c;
  undefined4 *local_68;
  int local_64;
  undefined4 *local_60;
  int local_5c;
  uint local_58;
  undefined4 *local_54;
  undefined4 *local_50;
  int local_4c;
  undefined4 *local_48;
  undefined4 *local_44;
  undefined4 *local_40;
  undefined4 *local_3c;
  undefined4 *local_38;
  char *local_34;
  char *local_30;
  int local_2c;
  undefined4 *local_28;
  undefined4 *local_24;
  undefined4 local_20;
  undefined4 local_1c;
  int local_18;
  undefined4 local_14;
  undefined4 *local_10;
  int local_c;
  char *local_8;
  
  FUN_00452cad(local_144,0);
  local_10 = (undefined4 *)0x0;
  DAT_004f1aa8 = param_2;
  if (param_3 != 0) {
    FUN_0045a0c4(local_144,param_3);
  }
  FUN_004614d7(local_150,(int)local_144);
  iVar3 = *(int *)(param_2 + 4);
  if (iVar3 < 0x47) {
    if (iVar3 == 0x46) {
      if ((*(uint *)(param_2 + 0x28) & 0xc) == 0) {
        local_84 = param_2;
        local_88 = param_2 + 0x220;
        local_8c = param_2 + 0x224;
        local_90 = (undefined4 *)FUN_00402298(0xbc);
        if (local_90 != (undefined4 *)0x0) {
          FUN_00454a70(local_90,param_2,1,local_88,local_8c);
        }
      }
    }
    else if (iVar3 < 0x33) {
      if ((iVar3 != 0x32) && (iVar3 != 0x30)) {
        if (iVar3 != 0x31) {
LAB_0045f121:
          puVar2 = &DAT_004e107c;
          puVar4 = local_1e0;
          for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
            *puVar4 = *puVar2;
            puVar2 = puVar2 + 1;
            puVar4 = puVar4 + 1;
          }
          if (param_3 == 0) {
            FUN_00436a48(param_1,param_2);
            DAT_004f1aa8 = 0;
            FUN_00461515(local_150,2);
            FUN_00452ccc(local_144,2);
            return;
          }
          if (param_4 == 1) {
            local_f4 = 1;
            local_f8 = 0;
          }
          else {
            local_f4 = 3;
            local_f8 = 0xffffffff;
          }
          local_104 = 1;
          (**(code **)(local_150[0] + 4))(local_150);
LAB_0045f52e:
          while (iVar3 = (**(code **)(local_150[0] + 0x28))(local_150), iVar3 != 0) {
            local_8 = *(char **)(iVar3 + 0xc);
            local_c = *(int *)(local_8 + 0x10);
            uVar1 = *(uint *)(local_8 + 0x14);
            if ((local_c == 2) || (local_c == 3)) {
              local_f0 = FUN_00498448(local_8,0);
              if (local_f0 == 0) goto code_r0x0045f253;
              goto LAB_0045f2a8;
            }
            local_108 = local_8;
            FUN_004dbb24(&DAT_00524e20,s_L4VIDEO_cpp_wrong_video_resource_004f2d43,(char *)0x0);
            FUN_004dbb24(&DAT_00524e20,local_108,(char *)0x0);
            FUN_004dbb24(&DAT_00524e20,&DAT_004f2d75,(char *)0x0);
          }
          goto LAB_0045f549;
        }
        (**(code **)(local_150[0] + 4))(local_150);
        while (iVar3 = (**(code **)(local_150[0] + 0x28))(local_150), iVar3 != 0) {
          local_7c = *(char **)(iVar3 + 0xc);
          iVar3 = FUN_004dd1e0(local_7c);
          if ((iVar3 < 100) || (999 < iVar3)) {
            local_80 = (undefined4 *)(param_2 + 0x100);
            FUN_004606d4(param_1,*local_80,*(undefined4 *)(param_2 + 0x104),
                         *(undefined4 *)(param_2 + 0x108),iVar3,0,0);
          }
          else {
            FUN_0045d41c(param_1,param_2,param_3,param_4,iVar3 + -100);
          }
        }
      }
    }
    else if (iVar3 == 0x3f) {
      local_6c = (undefined4 *)FUN_00402298(100);
      if (local_6c == (undefined4 *)0x0) {
        local_68 = (undefined4 *)0x0;
      }
      else {
        local_68 = FUN_00453578(local_6c,param_2,1,0,*(undefined4 *)(param_1 + 300),1,0);
      }
      local_70 = FUN_0041bfc0(param_2,s_SimulationState_004f2d33);
      (**(code **)(local_150[0] + 4))(local_150);
      while (iVar3 = (**(code **)(local_150[0] + 0x28))(local_150), iVar3 != 0) {
        local_74 = *(char **)(iVar3 + 0xc);
        local_64 = FUN_004dd1e0(local_74);
        local_78 = (undefined4 *)FUN_00402298(0x3c);
        if (local_78 != (undefined4 *)0x0) {
          FUN_004585f8(local_78,param_2,*(undefined4 *)(param_1 + 300),&DAT_004e0f80,local_68[0xb],
                       local_70,2,local_64,0.01);
        }
      }
    }
    else {
      if (iVar3 != 0x45) goto LAB_0045f121;
      if (param_4 == 1) {
        local_98 = (undefined4 *)FUN_00402298(100);
        if (local_98 == (undefined4 *)0x0) {
          local_94 = (undefined4 *)0x0;
        }
        else {
          local_94 = FUN_00453578(local_98,param_2,1,0,*(undefined4 *)(param_1 + 300),1,0);
        }
        local_9c = (undefined4 *)FUN_00402298(0x5c);
        if (local_9c != (undefined4 *)0x0) {
          FUN_004579a8(local_9c,param_2,*(int *)(param_1 + 300),&DAT_004e107c,local_94[0xb],
                       *(undefined4 **)(param_1 + 0x124),(undefined4 *)0x0);
        }
      }
    }
  }
  else {
    if (iVar3 < 0x5f) {
      if (iVar3 != 0x5e) {
        if (iVar3 == 0x54) goto LAB_0045f549;
        if (iVar3 != 0x56) goto LAB_0045f121;
      }
      puVar2 = &DAT_004e107c;
      puVar4 = local_180;
      for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {
        *puVar4 = *puVar2;
        puVar2 = puVar2 + 1;
        puVar4 = puVar4 + 1;
      }
      if (param_3 == 0) {
        FUN_00436a48(param_1,param_2);
        DAT_004f1aa8 = 0;
        FUN_00461515(local_150,2);
        FUN_00452ccc(local_144,2);
        return;
      }
      local_1c = 3;
      local_20 = 0xffffffff;
      local_2c = 1;
      (**(code **)(local_150[0] + 4))(local_150);
LAB_0045eb35:
      while (iVar3 = (**(code **)(local_150[0] + 0x28))(local_150), iVar3 != 0) {
        local_8 = *(char **)(iVar3 + 0xc);
        local_c = *(int *)(local_8 + 0x10);
        uVar1 = *(uint *)(local_8 + 0x14);
        if ((local_c == 2) || (local_c == 3)) {
          local_18 = FUN_00498448(local_8,0);
          if (local_18 == 0) goto code_r0x0045e91e;
          goto LAB_0045e96a;
        }
        local_30 = local_8;
        FUN_004dbb24(&DAT_00524e20,s_L4VIDEO_cpp_wrong_video_resource_004f2ccb,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_30,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,&DAT_004f2cfd,(char *)0x0);
      }
      goto LAB_0045f549;
    }
    if (iVar3 == 0x5f) {
      local_b8 = 0;
      (**(code **)(local_150[0] + 4))(local_150);
      while (iVar3 = (**(code **)(local_150[0] + 0x28))(local_150), iVar3 != 0) {
        local_8 = *(char **)(iVar3 + 0xc);
        switch(local_b8) {
        case 0:
          local_a0 = FUN_00498448(local_8,0);
          break;
        case 1:
          local_a4 = FUN_00498448(local_8,0);
          break;
        case 2:
          local_a8 = FUN_00498448(local_8,0);
          break;
        case 3:
          local_ac = FUN_00498448(local_8,0);
          break;
        case 4:
          local_b0 = FUN_00498448(local_8,0);
          break;
        case 5:
          local_b4 = FUN_00498448(local_8,0);
        }
        local_b8 = local_b8 + 1;
      }
      local_bc = **(int **)(param_2 + 0x128);
      local_c0 = (undefined4 *)(local_bc + 0xec);
      local_c4 = *(int *)(*(int *)(param_2 + 0x128) + 4);
      local_c8 = (undefined4 *)(local_c4 + 0xec);
      local_d0 = (undefined4 *)FUN_00402298(100);
      if (local_d0 == (undefined4 *)0x0) {
        local_cc = (undefined4 *)0x0;
      }
      else {
        local_cc = FUN_00453578(local_d0,param_2,0,local_a0,*(undefined4 *)(param_1 + 300),1,0);
      }
      local_10 = (undefined4 *)local_cc[0xb];
      FUN_0040aadc(local_1b0);
      local_d8 = (undefined4 *)FUN_00402298(100);
      if (local_d8 == (undefined4 *)0x0) {
        local_d4 = (undefined4 *)0x0;
      }
      else {
        local_d4 = FUN_00457bf4(local_d8,param_2,*(int *)(param_1 + 300),local_a4,1,0,local_1b0,
                                local_cc[0xb],local_c0);
      }
      local_e0 = (undefined4 *)FUN_00402298(100);
      if (local_e0 == (undefined4 *)0x0) {
        local_dc = (undefined4 *)0x0;
      }
      else {
        local_dc = FUN_00457bf4(local_e0,param_2,*(int *)(param_1 + 300),local_a8,1,0,local_1b0,
                                local_cc[0xb],local_c8);
      }
      local_e4 = (undefined4 *)FUN_00402298(0x30);
      if (local_e4 != (undefined4 *)0x0) {
        FUN_00453474(local_e4,param_2,0,local_ac,local_cc[0xb],1,0,1);
      }
      local_e8 = (undefined4 *)FUN_00402298(0x30);
      if (local_e8 != (undefined4 *)0x0) {
        FUN_00453474(local_e8,param_2,0,local_b0,local_d4[5],1,0,1);
      }
      local_ec = (undefined4 *)FUN_00402298(0x30);
      if (local_ec != (undefined4 *)0x0) {
        FUN_00453474(local_ec,param_2,0,local_b4,local_dc[5],1,0,1);
      }
    }
    else {
      if (iVar3 != 0x7d2) goto LAB_0045f121;
      (**(code **)(local_150[0] + 4))(local_150);
      iVar3 = (**(code **)(local_150[0] + 0x28))(local_150);
      local_8 = *(char **)(iVar3 + 0xc);
      local_5c = FUN_00498448(local_8,0);
      local_60 = (undefined4 *)FUN_00402298(0x50);
      if (local_60 != (undefined4 *)0x0) {
        FUN_00452e18(local_60,param_2,1,local_5c,*(int *)(param_1 + 300));
      }
    }
  }
LAB_0045f549:
  FUN_0045a134((int)local_144);
  DAT_004f1aa8 = 0;
  if (local_10 != (undefined4 *)0x0) {
    FUN_0045a994(param_1,(int)local_10,param_2);
  }
  FUN_00461515(local_150,2);
  FUN_00452ccc(local_144,2);
  return;
code_r0x0045e91e:
  local_34 = local_8;
  FUN_004dbb24(&DAT_00524e20,s_L4VIDEO_cpp_couldn_t_load_object_004f2cff,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,local_34,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,&DAT_004f2d21,(char *)0x0);
  if (local_2c != 0) {
LAB_0045e96a:
    if (local_2c == 0) {
      if ((uVar1 | 7) == 0) {
        local_48 = (undefined4 *)FUN_00402298(0x30);
        if (local_48 == (undefined4 *)0x0) {
          puVar2 = (undefined4 *)0x0;
        }
        else {
          puVar2 = FUN_00453474(local_48,param_2,0,local_18,local_24,local_1c,local_20,1);
        }
        local_28 = (undefined4 *)0x0;
        local_14 = puVar2[0xb];
      }
      else {
        local_44 = (undefined4 *)FUN_00402298(0x50);
        if (local_44 == (undefined4 *)0x0) {
          local_40 = (undefined4 *)0x0;
        }
        else {
          local_40 = FUN_0045848c(local_44,param_2,*(int *)(param_1 + 300),local_18,local_1c,
                                  local_20,local_180,local_24);
        }
        local_28 = (undefined4 *)local_40[4];
        local_14 = local_40[6];
      }
    }
    else {
      local_2c = 0;
      local_3c = (undefined4 *)FUN_00402298(100);
      if (local_3c == (undefined4 *)0x0) {
        local_38 = (undefined4 *)0x0;
      }
      else {
        local_38 = FUN_00453578(local_3c,param_2,0,local_18,*(undefined4 *)(param_1 + 300),local_1c,
                                local_20);
      }
      local_28 = (undefined4 *)local_38[0xb];
      local_14 = local_38[0xc];
      local_24 = local_28;
      local_10 = local_28;
    }
    local_4c = FUN_0041bfc0(param_2,s_SimulationState_004f2d23);
    if (local_c == 2) {
      local_50 = (undefined4 *)FUN_00402298(0x30);
      if (local_50 != (undefined4 *)0x0) {
        FUN_00456224(local_50,param_2,2,local_14,0,local_4c,1);
      }
    }
    else if ((local_c == 3) &&
            (local_54 = (undefined4 *)FUN_00402298(0x30), local_54 != (undefined4 *)0x0)) {
      FUN_00456224(local_54,param_2,2,local_14,1,local_4c,1);
    }
    if ((local_28 != (undefined4 *)0x0) && ((uVar1 & 7) != 0)) {
      local_58 = (uint)((uVar1 & 1) != 0);
      if ((uVar1 & 2) != 0) {
        local_58 = local_58 | 2;
      }
      if ((uVar1 & 4) != 0) {
        local_58 = local_58 | 4;
      }
      FUN_0048a674((int)local_28,local_58);
      FUN_0048d3e8(local_28);
    }
  }
  goto LAB_0045eb35;
code_r0x0045f253:
  local_10c = local_8;
  FUN_004dbb24(&DAT_00524e20,s_L4VIDEO_cpp_couldn_t_load_object_004f2d77,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,local_10c,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,&DAT_004f2d99,(char *)0x0);
  if (local_104 != 0) {
LAB_0045f2a8:
    if (local_104 == 0) {
      if ((uVar1 | 7) == 0) {
        local_130 = (undefined4 *)FUN_00402298(0x30);
        if (local_130 != (undefined4 *)0x0) {
          FUN_00453474(local_130,param_2,0,local_f0,local_fc,local_f4,local_f8,1);
        }
        local_100 = (undefined4 *)0x0;
      }
      else {
        local_12c = (undefined4 *)FUN_00402298(0x50);
        if (local_12c == (undefined4 *)0x0) {
          local_128 = (undefined4 *)0x0;
        }
        else {
          local_128 = FUN_0045848c(local_12c,param_2,*(int *)(param_1 + 300),local_f0,local_f4,
                                   local_f8,local_1e0,local_fc);
        }
        local_100 = (undefined4 *)local_128[4];
      }
    }
    else {
      local_104 = 0;
      iVar3 = FUN_0041a1a4(**(int **)(param_2 + 0xc),0x4e4518);
      if (iVar3 == 0) {
        local_11c = (undefined4 *)FUN_00402298(100);
        if (local_11c == (undefined4 *)0x0) {
          local_118 = (undefined4 *)0x0;
        }
        else {
          local_118 = FUN_00453578(local_11c,param_2,0,local_f0,*(undefined4 *)(param_1 + 300),
                                   local_f4,local_f8);
        }
        local_fc = (undefined4 *)local_118[0xb];
      }
      else {
        local_114 = (undefined4 *)FUN_00402298(100);
        if (local_114 == (undefined4 *)0x0) {
          local_110 = (undefined4 *)0x0;
        }
        else {
          local_110 = FUN_00453578(local_114,param_2,1,local_f0,*(undefined4 *)(param_1 + 300),
                                   local_f4,local_f8);
        }
        local_fc = (undefined4 *)local_110[0xb];
      }
      local_10 = local_fc;
      if (param_4 == 1) {
        local_120 = (undefined4 *)FUN_0041bfc0(param_2,s_EyepointRotation_004f2d9b);
        local_124 = (undefined4 *)FUN_00402298(0x5c);
        if (local_124 != (undefined4 *)0x0) {
          FUN_004579a8(local_124,param_2,*(int *)(param_1 + 300),&DAT_004e107c,local_fc,
                       *(undefined4 **)(param_1 + 0x124),local_120);
        }
      }
      local_100 = local_fc;
    }
    if ((local_100 != (undefined4 *)0x0) && ((uVar1 & 7) != 0)) {
      local_134 = (uint)((uVar1 & 1) != 0);
      if ((uVar1 & 2) != 0) {
        local_134 = local_134 | 2;
      }
      if ((uVar1 & 4) != 0) {
        local_134 = local_134 | 4;
      }
      FUN_0048a674((int)local_100,local_134);
      FUN_0048d3e8(local_100);
    }
  }
  goto LAB_0045f52e;
}



/* @0045f59c file=munga_l4/l4video.cpp name=FUN_0045f59c */

void __cdecl FUN_0045f59c(int param_1)

{
  int iVar1;
  float *pfVar2;
  int iVar3;
  uint *puVar4;
  float local_cc [12];
  float local_9c [12];
  float local_6c [12];
  float local_3c [12];
  uint *local_c;
  int local_8;
  
  FUN_0040aadc(local_3c);
  FUN_0040aadc(local_6c);
  FUN_0040aadc(local_9c);
  FUN_0040aadc(local_cc);
  iVar1 = FUN_00417ab4(param_1 + 0x40);
  pfVar2 = (float *)FUN_0041bfc0(iVar1,s_EyepointRotation_004f2dac);
  iVar3 = FUN_0041a1a4(**(int **)(iVar1 + 0xc),0x4e4afc);
  if (iVar3 == 0) {
    FUN_0040ab44(local_3c,(undefined4 *)(iVar1 + 0x100));
    if (pfVar2 == (float *)0x0) {
      FUN_0040bc54((float *)(param_1 + 0x50),local_3c);
    }
    else {
      FUN_0040bc54(local_6c,local_3c);
      FUN_0040ac6c(local_9c,pfVar2);
      FUN_0040bc54(local_cc,local_9c);
      FUN_0040b104((float *)(param_1 + 0x50),local_6c,local_cc);
    }
  }
  else {
    local_8 = iVar1;
    local_c = (uint *)FUN_00402298(0x10);
    if (local_c == (uint *)0x0) {
      puVar4 = (uint *)0x0;
    }
    else {
      puVar4 = FUN_00402460(local_c,s_siteeyepoint_004f2dbd);
    }
    puVar4[3] = puVar4[3] + 1;
    iVar1 = FUN_00424b60(local_8,(int *)puVar4);
    if (iVar1 == 0) {
      FUN_0040385c(s_DPLRenderer__SetupCull_jointed_m_004f2dca,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f2e04,5000);
    }
    if (pfVar2 == (float *)0x0) {
      FUN_0040385c(s_DPLRenderer__SetupCull_jointed_m_004f2e25,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f2e6d,0x138c);
    }
    FUN_00424da8(local_8,iVar1,local_3c);
    if (pfVar2 == (float *)0x0) {
      FUN_0040bc54((float *)(param_1 + 0x50),local_3c);
    }
    else {
      FUN_0040bc54(local_6c,local_3c);
      FUN_0040ac6c(local_9c,pfVar2);
      FUN_0040bc54(local_cc,local_9c);
      FUN_0040b104((float *)(param_1 + 0x50),local_6c,local_cc);
    }
  }
  return;
}



/* @0045f784 file=? name=FUN_0045f784 */

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

void __cdecl FUN_0045f784(int param_1)

{
  *(undefined4 *)(param_1 + 0x84) = 0;
  *(undefined4 *)(param_1 + 0x88) = 0;
  *(undefined4 *)(param_1 + 0x8c) = 0;
  *(undefined4 *)(param_1 + 0x90) = 0;
  *(undefined4 *)(param_1 + 0x98) = 0;
  *(undefined4 *)(param_1 + 0x94) = 56000;
  *(undefined4 *)(param_1 + 0x9c) = 0;
  *(float *)(param_1 + 0xa4) = *(float *)(param_1 + 0x80) + _DAT_0045f7d8;
  return;
}



/* @0045f7dc file=? name=FUN_0045f7dc */

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

void __cdecl FUN_0045f7dc(int param_1)

{
  int *piVar1;
  undefined4 uVar2;
  undefined2 uVar3;
  undefined2 uVar4;
  
  if (*(int *)(param_1 + 0x98) != 0) {
    uVar3 = (undefined2)*(undefined4 *)(param_1 + 0x98);
    uVar4 = (undefined2)((uint)*(undefined4 *)(param_1 + 0x98) >> 0x10);
    FUN_004dbb24(&DAT_00524e20,s_Frames_004f2e8e,(char *)0x0);
    piVar1 = FUN_004db880(&DAT_00524e20,CONCAT22(uVar4,uVar3));
    FUN_004dbb24(piVar1,&DAT_004f2e96,(char *)0x0);
    piVar1 = FUN_004db634(&DAT_00524e20,
                          (float10)(float)(((float10)*(uint *)(param_1 + 0x9c) /
                                           (float10)*(uint *)(param_1 + 0x98)) *
                                          (float10)_DAT_0045fa04));
    FUN_004dbb24(piVar1,s___of_the_frames_were_under_the_t_004f2e98,(char *)0x0);
    uVar2 = FUN_004dcd94();
    uVar3 = (undefined2)uVar2;
    uVar4 = (undefined2)((uint)uVar2 >> 0x10);
    FUN_004dbb24(&DAT_00524e20,s_Average_Cull_004f2eca,(char *)0x0);
    piVar1 = FUN_004db880(&DAT_00524e20,CONCAT22(uVar4,uVar3));
    FUN_004dbb24(piVar1,&DAT_004f2ed8,(char *)0x0);
    uVar2 = FUN_004dcd94();
    uVar3 = (undefined2)uVar2;
    uVar4 = (undefined2)((uint)uVar2 >> 0x10);
    FUN_004dbb24(&DAT_00524e20,s_Average_Draw_004f2eda,(char *)0x0);
    piVar1 = FUN_004db880(&DAT_00524e20,CONCAT22(uVar4,uVar3));
    FUN_004dbb24(piVar1,&DAT_004f2ee8,(char *)0x0);
    uVar2 = FUN_004dcd94();
    uVar3 = (undefined2)uVar2;
    uVar4 = (undefined2)((uint)uVar2 >> 0x10);
    FUN_004dbb24(&DAT_00524e20,s_Average_Pixel_Planes_004f2eea,(char *)0x0);
    piVar1 = FUN_004db880(&DAT_00524e20,CONCAT22(uVar4,uVar3));
    FUN_004dbb24(piVar1,&DAT_004f2f00,(char *)0x0);
    uVar2 = FUN_004dcd94();
    uVar3 = (undefined2)uVar2;
    uVar4 = (undefined2)((uint)uVar2 >> 0x10);
    FUN_004dbb24(&DAT_00524e20,s_Average_Frame_Time_004f2f02,(char *)0x0);
    piVar1 = FUN_004db880(&DAT_00524e20,CONCAT22(uVar4,uVar3));
    FUN_004dbb24(piVar1,&DAT_004f2f16,(char *)0x0);
  }
  return;
}



/* @0045fbf4 file=? name=FUN_0045fbf4 */

void __cdecl FUN_0045fbf4(int param_1,undefined4 param_2)

{
  int iVar1;
  
  if (*(int *)(param_1 + 0x2c8) == 100) {
    FUN_0045fc24(param_1);
  }
  iVar1 = *(int *)(param_1 + 0x2c8);
  *(int *)(param_1 + 0x2c8) = *(int *)(param_1 + 0x2c8) + 1;
  *(undefined4 *)(param_1 + 0x134 + iVar1 * 4) = param_2;
  return;
}



/* @0045fc24 file=? name=FUN_0045fc24 */

void __cdecl FUN_0045fc24(int param_1)

{
  if (*(int *)(param_1 + 0x2c8) != 0) {
    *(undefined4 *)(param_1 + 0x134 + *(int *)(param_1 + 0x2c8) * 4) = 0;
    FUN_0048ffa4((int *)(param_1 + 0x134));
    *(undefined4 *)(param_1 + 0x2c8) = 0;
  }
  return;
}



/* @0045fc58 file=? name=FUN_0045fc58 */

void __cdecl FUN_0045fc58(undefined4 param_1,int *param_2)

{
  uint uVar1;
  int *piVar2;
  
  uVar1 = FUN_00490380();
  FUN_004dbb24(param_2,s_Free_memory_in_card__004f2f18,(char *)0x0);
  piVar2 = FUN_004db78c(param_2,uVar1);
  FUN_004dbb24(piVar2,s_bytes__004f2f2f,(char *)0x0);
  FUN_004d9c38(piVar2);
  return;
}



/* @0045fca0 file=? name=FUN_0045fca0 */

void __cdecl FUN_0045fca0(int param_1,int *param_2)

{
  uint uVar1;
  uint uVar2;
  uint uVar3;
  uint uVar4;
  uint uVar5;
  int *piVar6;
  
  uVar1 = DAT_00524690;
  FUN_004dbb24(param_2,s_sect_time_004f2f37,(char *)0x0);
  piVar6 = FUN_004db78c(param_2,uVar1);
  FUN_004dbb24(piVar6,s_dcs_and_inst_not_available_004f2f42,(char *)0x0);
  FUN_004d9c38(piVar6);
  uVar5 = DAT_00524ae8;
  uVar4 = DAT_00524ae4;
  uVar3 = DAT_00524ae0;
  uVar2 = DAT_00524adc;
  uVar1 = DAT_00524ad8;
  FUN_004dbb24(param_2,s_cull_004f2f5e,(char *)0x0);
  piVar6 = FUN_004db78c(param_2,uVar1);
  FUN_004dbb24(piVar6,s_draw_004f2f64,(char *)0x0);
  piVar6 = FUN_004db78c(piVar6,uVar2);
  FUN_004dbb24(piVar6,s_frame_004f2f6b,(char *)0x0);
  piVar6 = FUN_004db78c(piVar6,uVar3);
  FUN_004dbb24(piVar6,s_pxpl_004f2f73,(char *)0x0);
  piVar6 = FUN_004db78c(piVar6,uVar4);
  FUN_004dbb24(piVar6,s_prims_004f2f7a,(char *)0x0);
  piVar6 = FUN_004db78c(piVar6,uVar5);
  FUN_004d9c38(piVar6);
  if (*(int *)(param_1 + 0xa0) == 0) {
    FUN_0045f784(param_1);
    *(undefined4 *)(param_1 + 0xa0) = 1;
  }
  else {
    FUN_0045f7dc(param_1);
  }
  return;
}



/* @0045fdd8 file=? name=FUN_0045fdd8 */

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

void FUN_0045fdd8(void)

{
  _DAT_004f1ab4 = _DAT_004f1ab4 ^ 1;
  if (_DAT_004f1ab4 != 0) {
    FUN_004dbb24(&DAT_00524e20,s_wireframe_ON_004f2f82,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    FUN_0048a544(1,1,(undefined4 *)0x0);
    return;
  }
  FUN_004dbb24(&DAT_00524e20,s_wireframe_OFF_004f2f8f,(char *)0x0);
  FUN_004d9c38(&DAT_00524e20);
  FUN_0048a544(1,2,(undefined4 *)0x0);
  return;
}



/* @0045fe44 file=? name=FUN_0045fe44 */

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

void FUN_0045fe44(void)

{
  undefined4 local_18;
  undefined4 local_14;
  undefined4 local_10;
  undefined4 local_c;
  
  local_10 = _DAT_0045fec4;
  local_14 = _DAT_0045fec4;
  local_18 = _DAT_0045fec4;
  _DAT_004f1ab8 = _DAT_004f1ab8 ^ 1;
  if (_DAT_004f1ab8 == 0) {
    FUN_004dbb24(&DAT_00524e20,s_pvision_OFF_004f2fa8,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    local_c = 0xfffffffe;
  }
  else {
    FUN_004dbb24(&DAT_00524e20,s_pvision_ON_004f2f9d,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    local_c = 0xffffffff;
  }
  FUN_0048d060(0,0,&local_18);
  return;
}



/* @0045fec8 file=? name=FUN_0045fec8 */

void __cdecl
FUN_0045fec8(undefined1 *param_1,int param_2,int param_3,int param_4,int param_5,int param_6)

{
  undefined2 uVar1;
  undefined2 uVar2;
  undefined2 uVar3;
  undefined2 *puVar4;
  int iVar5;
  undefined2 *puVar6;
  undefined2 *puVar7;
  int local_8;
  
  iVar5 = param_5 * param_6;
  local_8 = 0;
  puVar7 = (undefined2 *)(param_4 + iVar5 * 2);
  puVar4 = (undefined2 *)(param_3 + iVar5 * 2);
  puVar6 = (undefined2 *)(param_2 + iVar5 * 2);
  if (0 < param_6) {
    do {
      uVar1 = *puVar6;
      uVar2 = *puVar4;
      puVar4 = puVar4 + 1;
      uVar3 = *puVar7;
      puVar7 = puVar7 + 1;
      puVar6 = puVar6 + 1;
      *param_1 = (char)((ushort)uVar1 >> 8);
      param_1[1] = (char)((ushort)uVar2 >> 8);
      param_1[2] = (char)((ushort)uVar3 >> 8);
      param_1 = param_1 + 3;
      local_8 = local_8 + 1;
    } while (local_8 < param_6);
  }
  return;
}



/* @0045ff4c file=? name=FUN_0045ff4c */

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

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

{
  short *psVar1;
  undefined4 uVar2;
  short sVar3;
  int *piVar4;
  uint uVar5;
  int iVar6;
  uint uVar7;
  byte *pbVar8;
  char *pcVar9;
  int iVar10;
  byte local_84 [13];
  undefined1 local_77;
  undefined1 local_76;
  undefined1 local_75;
  undefined1 local_74;
  undefined1 local_73;
  char local_70 [64];
  undefined4 *local_30;
  float *local_2c;
  float *local_28;
  undefined4 local_24;
  float local_20;
  float local_1c;
  float local_18;
  float local_14;
  uint local_10;
  int local_c;
  uint local_8;
  
  if (param_1 == (undefined4 *)0x0) {
    if (DAT_004f1ac0 != (byte *)0x0) {
      FUN_004022d0((int *)DAT_004f1ac0);
    }
    if (DAT_004f1ac4 != (int *)0x0) {
      FUN_004022d0(DAT_004f1ac4);
    }
    if (DAT_004f1ac8 != (int *)0x0) {
      FUN_004022d0(DAT_004f1ac8);
    }
    if (DAT_004f1acc != (int *)0x0) {
      FUN_004022d0(DAT_004f1acc);
    }
  }
  else {
    if (DAT_004f1ad8 == '\0') {
      _DAT_004f1ad4 = _DAT_0046055c / (float)param_2;
      DAT_004f1ad8 = '\x01';
    }
    if (DAT_004f1ae0 == '\0') {
      _DAT_004f1adc = _DAT_0046055c / (float)param_3;
      DAT_004f1ae0 = '\x01';
    }
    if (DAT_004f1ae8 == '\0') {
      _DAT_004f1ae4 = _DAT_004f1ad4 * _DAT_00460560;
      DAT_004f1ae8 = '\x01';
    }
    if (DAT_004f1af0 == '\0') {
      _DAT_004f1aec = _DAT_004f1adc * _DAT_00460560;
      DAT_004f1af0 = '\x01';
    }
    if (DAT_004f1b0c == '\0') {
      DAT_004f1afc = -(_DAT_004f1ae4 + _DAT_004f1af4);
      DAT_004f1b0c = '\x01';
      _DAT_004f1b00 = _DAT_004f1ae4 - _DAT_004f1af4;
      _DAT_004f1b04 = _DAT_004f1af4 - _DAT_004f1ae4;
      _DAT_004f1b08 = _DAT_004f1af4 + _DAT_004f1ae4;
    }
    if (DAT_004f1b20 == '\0') {
      DAT_004f1b10 = _DAT_004f1aec - _DAT_004f1af8;
      DAT_004f1b20 = '\x01';
      _DAT_004f1b14 = _DAT_004f1aec + _DAT_004f1af8;
      _DAT_004f1b18 = -(_DAT_004f1af8 + _DAT_004f1aec);
      _DAT_004f1b1c = _DAT_004f1af8 - _DAT_004f1aec;
    }
    local_8 = 4;
    if (param_4 == 0) {
      local_8 = 1;
    }
    iVar6 = param_2 * param_3;
    if (param_4 == 0) {
      pcVar9 = s_False_004f2fd7;
    }
    else {
      pcVar9 = &DAT_004f2fd2;
    }
    FUN_004dbb24(&DAT_00524e20,s_Dump_frame_buffer__antialias__004f2fb4,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,pcVar9,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_____press_Esc_to_cancel__004f2fdd,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    if (DAT_004f1ac0 == (byte *)0x0) {
      DAT_004f1ac0 = (byte *)FUN_004022b0(0x1000);
      uVar5 = iVar6 * 2;
      DAT_004f1ac4 = (int *)FUN_004022b0(uVar5);
      DAT_004f1ac8 = (int *)FUN_004022b0(uVar5);
      DAT_004f1acc = (int *)FUN_004022b0(uVar5);
    }
    iVar10 = 0;
    local_c = 0;
    if (0 < iVar6) {
      do {
        *(undefined2 *)((int)DAT_004f1ac4 + iVar10 * 2) = 0;
        *(undefined2 *)((int)DAT_004f1ac8 + iVar10 * 2) = 0;
        *(undefined2 *)((int)DAT_004f1acc + iVar10 * 2) = 0;
        iVar10 = iVar10 + 1;
        local_c = local_c + 1;
      } while (iVar6 - local_c != 0 && local_c <= iVar6);
    }
    FUN_00490474();
    FUN_00490474();
    local_c = 0;
    local_30 = &DAT_004f1b24;
    local_2c = &DAT_004f1b10;
    local_28 = &DAT_004f1afc;
    if (0 < (int)local_8) {
      do {
        uVar5 = local_8;
        uVar7 = local_c + 1;
        FUN_004dbb24(&DAT_00524e20,s_pass_004f2ff6,(char *)0x0);
        piVar4 = FUN_004db78c(&DAT_00524e20,uVar7);
        FUN_004dbb24(piVar4,&DAT_004f2ffe,(char *)0x0);
        piVar4 = FUN_004db78c(piVar4,uVar5);
        FUN_004dbb24(piVar4,&DAT_004f3003,(char *)0x0);
        FUN_0048ba30((int)param_1,&local_14,&local_18,&local_1c,&local_20,&local_24);
        FUN_0048b9d0((int)param_1,local_14 + *local_28,local_18 + *local_2c,local_1c + *local_28,
                     local_20 + *local_2c,local_24);
        FUN_0048d42c(param_1);
        FUN_00490474();
        FUN_00490474();
        iVar6 = 0;
        uVar2 = *local_30;
        local_10 = 0;
        if (0 < param_3) {
          do {
            pbVar8 = DAT_004f1ac0;
            iVar10 = FUN_004d4888();
            if ((iVar10 != 0) && (uVar5 = FUN_004d4718(), uVar5 == 0x1b)) {
              piVar4 = FUN_004d9c38(&DAT_00524e20);
              FUN_004dbb24(piVar4,s_cancelled__004f3005,(char *)0x0);
              FUN_004d9c38(piVar4);
              return;
            }
            if ((local_10 & 0xf) == 0) {
              FUN_004dbb24(&DAT_00524e20,&DAT_004f3010,(char *)0x0);
            }
            FUN_0048cf38(param_1,(undefined4 *)pbVar8,0,local_10,param_2,1);
            iVar10 = 0;
            if (0 < param_2) {
              do {
                iVar10 = iVar10 + 1;
                sVar3 = (short)uVar2;
                psVar1 = (short *)((int)DAT_004f1ac4 + iVar6 * 2);
                *psVar1 = *psVar1 + (ushort)pbVar8[2] * sVar3;
                psVar1 = (short *)((int)DAT_004f1ac8 + iVar6 * 2);
                *psVar1 = *psVar1 + (ushort)pbVar8[1] * sVar3;
                psVar1 = (short *)((int)DAT_004f1acc + iVar6 * 2);
                *psVar1 = *psVar1 + (ushort)*pbVar8 * sVar3;
                iVar6 = iVar6 + 1;
                pbVar8 = pbVar8 + 4;
              } while (iVar10 < param_2);
            }
            local_10 = local_10 + 1;
          } while ((int)local_10 < param_3);
        }
        FUN_004d9c38(&DAT_00524e20);
        local_c = local_c + 1;
        local_30 = local_30 + 1;
        local_2c = local_2c + 1;
        local_28 = local_28 + 1;
      } while (local_c < (int)local_8);
    }
    FUN_004d7f10(local_70,s_dump_d_tga_004f3012);
    local_84[0] = 0;
    local_84[1] = 0;
    local_84[2] = 2;
    local_84[3] = 0;
    local_84[4] = 0;
    local_84[5] = 0;
    local_84[6] = 0;
    local_84[7] = 0;
    local_84[8] = 0;
    local_84[9] = 0;
    local_84[10] = 0;
    local_84[0xb] = 0;
    local_84[0xc] = (undefined1)param_2;
    local_77 = (undefined1)((uint)param_2 >> 8);
    local_76 = (undefined1)param_3;
    local_75 = (undefined1)((uint)param_3 >> 8);
    local_74 = 0x18;
    local_73 = 0;
    FUN_004dbb24(&DAT_00524e20,s_Writing_image_to_file___004f301d,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,local_70,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_________004f3035,(char *)0x0);
    piVar4 = FUN_004d6f54(local_70,&DAT_004f303e);
    FUN_004d7358(local_84,0x12,1,piVar4);
    local_10 = 0;
    if (0 < param_3) {
      do {
        FUN_0045fec8(DAT_004f1ac0,(int)DAT_004f1ac4,(int)DAT_004f1ac8,(int)DAT_004f1acc,
                     (param_3 + -1) - local_10,param_2);
        FUN_004d7358(DAT_004f1ac0,param_2 * 3,1,piVar4);
        local_10 = local_10 + 1;
      } while ((int)local_10 < param_3);
    }
    FUN_004d6b08(piVar4);
    FUN_004dbb24(&DAT_00524e20,s_done__004f3041,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    DAT_004f1abc = DAT_004f1abc + 1;
  }
  return;
}



/* @00460590 file=? name=FUN_00460590 */

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

undefined4 __cdecl FUN_00460590(int param_1)

{
  int iVar1;
  
  if ((*(int *)(param_1 + 0xb4) != 0) && (iVar1 = FUN_0048a184(), iVar1 != 0)) {
    FUN_0045fc24(param_1);
    FUN_0048a1bc();
    if (*(int *)(param_1 + 0xa0) != 0) {
      *(int *)(param_1 + 0x84) = *(int *)(param_1 + 0x84) + DAT_00524ad8;
      *(int *)(param_1 + 0x88) = *(int *)(param_1 + 0x88) + DAT_00524adc;
      *(int *)(param_1 + 0x8c) = *(int *)(param_1 + 0x8c) + DAT_00524ae4;
      *(int *)(param_1 + 0x90) = *(int *)(param_1 + 0x90) + DAT_00524ae0;
      *(int *)(param_1 + 0x98) = *(int *)(param_1 + 0x98) + 1;
      if (DAT_00524ae0 <= *(uint *)(param_1 + 0x94)) {
        *(int *)(param_1 + 0x9c) = *(int *)(param_1 + 0x9c) + 1;
      }
      if (*(float *)(param_1 + 0xa4) < *(float *)(param_1 + 0x80)) {
        FUN_0045f7dc(param_1);
        *(float *)(param_1 + 0xa4) = *(float *)(param_1 + 0x80) + _DAT_00460650;
      }
    }
    *(undefined4 *)(param_1 + 0xb4) = 0;
    return 1;
  }
  return 0;
}



/* @00460654 file=? name=FUN_00460654 */

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

{
  uint uVar1;
  int iVar2;
  uint *puVar3;
  uint *puVar4;
  uint local_108 [4];
  undefined4 local_f8;
  undefined4 local_f4;
  undefined4 local_f0;
  
  puVar3 = param_5;
  puVar4 = local_108;
  for (iVar2 = 0x41; iVar2 != 0; iVar2 = iVar2 + -1) {
    *puVar4 = *puVar3;
    puVar3 = puVar3 + 1;
    puVar4 = puVar4 + 1;
  }
  uVar1 = FUN_00460ae4(param_1);
  local_108[0] = uVar1 | *param_5 & 0xffff0000 | (param_7 & 0xff) << 0x10;
  local_f8 = param_2;
  local_f4 = param_3;
  local_f0 = param_4;
  FUN_0048d060(1,param_6,local_108);
  return;
}



/* @004606d4 file=munga_l4/l4video.cpp name=FUN_004606d4 */

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

{
  int iVar1;
  undefined4 local_18;
  undefined4 local_14;
  undefined4 local_10;
  int local_c;
  
  if (param_5 < 1000) {
    local_c = param_5;
    local_18 = param_2;
    local_14 = param_3;
    local_10 = param_4;
    FUN_0048d060(0,param_6,&local_18);
  }
  else {
    iVar1 = param_5 + -1000;
    if ((iVar1 < 0) || (0x27 < iVar1)) {
      FUN_0040385c(s_PSFX_id_number_was_not_in_the_al_004f3047,
                   s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f3073,0x174b);
    }
    FUN_00460654(param_1,param_2,param_3,param_4,*(uint **)(param_1 + 0x2cc + iVar1 * 4),param_6,
                 param_7);
  }
  return;
}



/* @00460770 file=? name=FUN_00460770 */

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

void __cdecl FUN_00460770(int param_1,float param_2)

{
  double dVar1;
  float10 fVar2;
  
  *(float *)(param_1 + 0x118) = param_2 * _DAT_00460814;
  dVar1 = (double)(*(float *)(param_1 + 0x118) * _DAT_00460818);
  fVar2 = (float10)FUN_004dd188(SUB84(dVar1,0),(int)((ulonglong)dVar1 >> 0x20));
  *(float *)(param_1 + 0x11c) = (float)fVar2;
  *(float *)(param_1 + 0xc0) = (float)DAT_004f336c / (float)DAT_004f3368;
  FUN_0048b9d0(*(int *)(param_1 + 0x124),0xbf800000,-*(float *)(param_1 + 0xc0),0x3f800000,
               *(undefined4 *)(param_1 + 0xc0),_DAT_0046081c / *(float *)(param_1 + 0x11c));
  FUN_0048d42c(*(undefined4 **)(param_1 + 0x124));
  return;
}



/* @00460840 file=? name=FUN_00460840 */

void __cdecl FUN_00460840(undefined4 param_1)

{
  int iVar1;
  int iVar2;
  int local_18 [3];
  undefined4 local_c;
  uint *local_8;
  
  local_8 = FUN_00460994();
  iVar1 = FUN_00403ad0(*(int *)(DAT_004efc94 + 0x24) + 0x18,s_Players_004f3094);
  FUN_00421414(local_18,iVar1 + 0x10);
  while( true ) {
    iVar1 = (**(code **)(local_18[0] + 0x28))(local_18);
    if (iVar1 == 0) break;
    local_c = *(undefined4 *)(iVar1 + 0x1e0);
    iVar2 = (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 200) + 0x68) + 0xc))
                      (*(int *)(DAT_004efc94 + 200) + 0x68,&local_c);
    if ((iVar2 != 0) && ((*(byte *)(iVar1 + 0x29) & 0x40) == 0)) {
      FUN_0045d2b4(param_1,iVar2,*(int *)(iVar1 + 0x1cc) + 1,local_8);
    }
  }
  FUN_00460914(param_1,local_8);
  FUN_0045d23c(param_1,(byte *)local_8);
  FUN_004de420((int *)local_8);
  FUN_00421452(local_18,2);
  return;
}



/* @00460914 file=? name=FUN_00460914 */

void __cdecl FUN_00460914(undefined4 param_1,uint *param_2)

{
  int iVar1;
  int iVar2;
  uint uVar3;
  int local_8;
  
  if ((*(uint *)(*(int *)(DAT_004efc94 + 0x14) + 0x28) & 0xc) == 0) {
    iVar1 = FUN_0041a1a4(**(int **)(*(int *)(DAT_004efc94 + 0x14) + 0xc),0x4e6aa4);
    if (iVar1 != 0) {
      uVar3 = 9;
      iVar1 = 1;
      do {
        local_8 = iVar1;
        iVar2 = (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 200) + 0x98) + 0xc))
                          (*(int *)(DAT_004efc94 + 200) + 0x98,&local_8);
        FUN_0045d2b4(param_1,iVar2,uVar3,param_2);
        uVar3 = uVar3 + 1;
        iVar1 = iVar1 + 1;
      } while (iVar1 < 5);
    }
  }
  return;
}



/* @00460994 file=munga_l4/l4video.cpp name=FUN_00460994 */

undefined4 * FUN_00460994(void)

{
  undefined4 *puVar1;
  undefined4 *puVar2;
  int iVar3;
  
  puVar1 = (undefined4 *)FUN_004022b0(0x8000);
  if (puVar1 == (undefined4 *)0x0) {
    FUN_0040385c(s_Could_not_allocate_RAM_for_worst_004f309c,
                 s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f30ca,0x17ec);
  }
  iVar3 = 0;
  puVar2 = puVar1;
  do {
    *puVar2 = 0;
    iVar3 = iVar3 + 1;
    puVar2 = puVar2 + 1;
  } while (iVar3 < 0x2000);
  return puVar1;
}



/* @004609dc file=? name=FUN_004609dc */

void __cdecl FUN_004609dc(undefined4 param_1)

{
  int iVar1;
  int iVar2;
  int local_10;
  int local_c;
  uint *local_8;
  
  local_8 = FUN_00460994();
  local_c = *(int *)(*(int *)(DAT_004efc94 + 200) + 0x48);
  iVar2 = 0;
  if (0 < local_c) {
    do {
      local_10 = iVar2 + 1;
      iVar1 = (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 200) + 0x68) + 0xc))
                        (*(int *)(DAT_004efc94 + 200) + 0x68,&local_10);
      if (iVar1 != 0) {
        FUN_0045d2b4(param_1,iVar1,iVar2 + 1,local_8);
      }
      iVar2 = iVar2 + 1;
    } while (iVar2 < local_c);
  }
  FUN_00460914(param_1,local_8);
  FUN_0045d23c(param_1,(byte *)local_8);
  FUN_004022e8((int *)local_8);
  return;
}



/* @00460a7c file=? name=FUN_00460a7c */

void __cdecl FUN_00460a7c(int param_1)

{
  int local_2c [5];
  int local_18 [5];
  
  FUN_0049060c();
  FUN_00461541(local_18,param_1 + 0x37c);
  FUN_004615ca(local_2c,param_1 + 0x390);
  FUN_00461608(local_2c,2);
  FUN_0046159e(local_18,2);
  return;
}



/* @00460ad4 file=? name=FUN_00460ad4 */

void FUN_00460ad4(void)

{
  return;
}



/* @00460adc file=? name=FUN_00460adc */

void FUN_00460adc(void)

{
  return;
}



/* @00460ae4 file=? name=FUN_00460ae4 */

uint __cdecl FUN_00460ae4(int param_1)

{
  uint uVar1;
  
  uVar1 = *(int *)(param_1 + 0xb8) + 1U & 0xffff;
  *(uint *)(param_1 + 0xb8) = uVar1;
  return uVar1;
}



/* @00460b04 file=? name=FUN_00460b04 */

undefined4 __cdecl FUN_00460b04(int param_1,undefined4 param_2)

{
  undefined4 *puVar1;
  undefined4 uVar2;
  
  puVar1 = (undefined4 *)(**(code **)(*(int *)(param_1 + 0x390) + 0xc))(param_1 + 0x390,param_2);
  if (puVar1 == (undefined4 *)0x0) {
    uVar2 = 0;
  }
  else {
    uVar2 = puVar1[4];
    if (puVar1 != (undefined4 *)0x0) {
      (**(code **)*puVar1)(puVar1,3);
    }
  }
  return uVar2;
}



/* @00460b48 file=? name=FUN_00460b48 */

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

{
  int *piVar1;
  undefined4 *puVar2;
  int iVar3;
  int *local_14;
  undefined4 *local_10;
  int *local_c;
  undefined4 local_8;
  
  puVar2 = (undefined4 *)FUN_00402298(0x14);
  if (puVar2 != (undefined4 *)0x0) {
    local_8 = param_3;
    local_c = param_2;
    FUN_00415e90(puVar2,1);
    *puVar2 = &PTR_FUN_004f3308;
    local_10 = (undefined4 *)FUN_00402298(0x10);
    if (local_10 == (undefined4 *)0x0) {
      iVar3 = 0;
    }
    else {
      iVar3 = FUN_004023f4(local_10);
    }
    puVar2[3] = iVar3;
    piVar1 = (int *)(puVar2[3] + 0xc);
    *piVar1 = *piVar1 + 1;
    FUN_00402a4c((int *)&local_14,puVar2 + 3,local_c);
    puVar2[4] = local_8;
    piVar1 = local_14 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(local_14,3);
    }
  }
  (**(code **)(*(int *)(param_1 + 0x390) + 8))(param_1 + 0x390,puVar2,param_2);
  return;
}



/* @00460c04 file=? name=FUN_00460c04 */

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

{
  undefined4 *puVar1;
  undefined4 *puVar2;
  int iVar3;
  int local_18 [5];
  
  FUN_00461541(local_18,param_1 + 0x37c);
  puVar2 = (undefined4 *)(**(code **)(local_18[0] + 0x30))(local_18);
  if (puVar2 == (undefined4 *)0x0) {
    puVar2 = (undefined4 *)FUN_00402298(0x18);
    if (puVar2 == (undefined4 *)0x0) {
      puVar2 = (undefined4 *)0x0;
    }
    else {
      puVar2 = FUN_00452cf8(puVar2,param_2,param_3);
    }
    FUN_0046159e(local_18,2);
  }
  else {
    (**(code **)(local_18[0] + 0x48))(local_18);
    puVar1 = (undefined4 *)puVar2[5];
    iVar3 = FUN_0048ab68((int)puVar1);
    if (param_2 != iVar3) {
      FUN_0048ab0c((int)puVar1,param_2);
      FUN_0048d5d4(puVar1);
    }
    FUN_0046159e(local_18,2);
  }
  return puVar2;
}



/* @00460cb0 file=? name=FUN_00460cb0 */

void __cdecl FUN_00460cb0(int param_1,undefined4 param_2)

{
  (**(code **)(*(int *)(param_1 + 0x37c) + 4))(param_1 + 0x37c,param_2);
  return;
}



/* @00460cd0 file=munga_l4/l4video.cpp name=FUN_00460cd0 */

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

{
  int iVar1;
  undefined4 uVar2;
  int unaff_EBX;
  int local_40 [7];
  int local_24 [7];
  int local_8;
  
  FUN_00415e90(param_1,1);
  *param_1 = &PTR_FUN_004f3304;
  iVar1 = FUN_0041a1a4(**(int **)(param_2 + 0xc),0x4e4afc);
  if (iVar1 == 0) {
    FUN_0040385c(s_DPLJointToDCSTranslator_was_call_004f30eb,
                 s_d__tesla_bt_munga_l4_L4VIDEO_CPP_004f312f,0x18c5);
    param_2 = unaff_EBX;
  }
  local_8 = FUN_00417ab4(param_2 + 0x31c);
  FUN_0041d3b3(local_24,local_8 + 0xe4);
  iVar1 = (**(code **)(local_24[0] + 0x14))(local_24);
  FUN_0041d3d2(local_24,2);
  uVar2 = FUN_004022b0(iVar1 << 2);
  param_1[4] = uVar2;
  FUN_0041f216(local_40,param_2 + 0x300);
  while (iVar1 = (**(code **)(local_40[0] + 0x28))(local_40), iVar1 != 0) {
    if (*(int *)(iVar1 + 0xc0) != -1) {
      *(undefined4 *)(param_1[4] + *(int *)(iVar1 + 0xc0) * 4) =
           *(undefined4 *)(param_3 + *(int *)(iVar1 + 0xcc) * 4);
    }
  }
  FUN_0041f235(local_40,2);
  return param_1;
}



/* @00460dcc file=? name=FUN_00460dcc */

void __cdecl FUN_00460dcc(int *param_1,byte param_2)

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



/* @00460e08 file=? name=FUN_00460e08 */

undefined4 FUN_00460e08(void)

{
  return 1;
}



/* @00460e14 file=? name=FUN_00460e14 */

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

{
  char *pcVar1;
  char cVar2;
  undefined4 *puVar3;
  char *pcVar4;
  int iVar5;
  undefined4 uVar6;
  int iVar7;
  char *pcVar8;
  char *pcVar9;
  int *piVar10;
  int *piVar11;
  uint uVar12;
  int *piVar13;
  bool bVar14;
  int local_60 [3];
  int local_54 [4];
  char local_44 [40];
  uint local_1c;
  int local_18;
  int *local_14;
  undefined4 local_10;
  undefined4 *local_c;
  int *local_8;
  
  puVar3 = (undefined4 *)FUN_00406ff8(param_1,param_2,10,-1);
  if (puVar3 == (undefined4 *)0x0) {
    local_8 = FUN_00404720(param_3,s_video_004f3150,(char *)0x0);
    if (local_8 != (int *)0x0) {
      FUN_00452cad(local_54,0);
      local_c = (undefined4 *)local_8[1];
LAB_00460e73:
      if (local_c != (undefined4 *)0x0) {
        do {
          puVar3 = (undefined4 *)*local_c;
          pcVar9 = (char *)(local_c + 2);
          if ((pcVar9 != (char *)0x0) && (*pcVar9 != '\0')) {
            pcVar8 = s_object_004f3156;
            pcVar4 = pcVar9;
            do {
              if (*pcVar4 != *pcVar8) goto LAB_00460ecc;
              bVar14 = true;
              if (*pcVar4 == '\0') break;
              pcVar1 = pcVar4 + 1;
              if (*pcVar1 != pcVar8[1]) goto LAB_00460ecc;
              pcVar4 = pcVar4 + 2;
              pcVar8 = pcVar8 + 2;
              bVar14 = *pcVar1 == '\0';
            } while (!bVar14);
            if (bVar14) {
              local_10 = 2;
            }
            else {
LAB_00460ecc:
              pcVar8 = s_rubble_004f315d;
              pcVar4 = pcVar9;
              do {
                if (*pcVar4 != *pcVar8) goto LAB_00460efd;
                bVar14 = true;
                if (*pcVar4 == '\0') break;
                pcVar1 = pcVar4 + 1;
                if (*pcVar1 != pcVar8[1]) goto LAB_00460efd;
                pcVar4 = pcVar4 + 2;
                pcVar8 = pcVar8 + 2;
                bVar14 = *pcVar1 == '\0';
              } while (!bVar14);
              if (bVar14) {
                local_10 = 3;
              }
              else {
LAB_00460efd:
                pcVar8 = s_skeleton_004f3164;
                pcVar4 = pcVar9;
                do {
                  if (*pcVar4 != *pcVar8) goto LAB_00460f2e;
                  bVar14 = true;
                  if (*pcVar4 == '\0') break;
                  pcVar1 = pcVar4 + 1;
                  if (*pcVar1 != pcVar8[1]) goto LAB_00460f2e;
                  pcVar4 = pcVar4 + 2;
                  pcVar8 = pcVar8 + 2;
                  bVar14 = *pcVar1 == '\0';
                } while (!bVar14);
                if (!bVar14) goto LAB_00460f2e;
                local_10 = 1;
              }
            }
            pcVar9 = (char *)local_c[1];
            local_c = puVar3;
            while ((puVar3 = local_c, pcVar9 != (char *)0x0 && (pcVar4 = pcVar9, *pcVar9 != '\0')))
            {
              while ((*pcVar4 != '\0' && (((&DAT_005207dd)[*pcVar4] & 1) != 0))) {
                pcVar4 = pcVar4 + 1;
              }
              pcVar9 = pcVar4;
              if (*pcVar4 == '\0') break;
              while ((*pcVar9 != '\0' && (((&DAT_005207dd)[*pcVar9] & 1) == 0))) {
                pcVar9 = pcVar9 + 1;
              }
              FUN_004d4b9c((undefined4 *)local_44,pcVar4,(int)pcVar9 - (int)pcVar4);
              local_44[(int)pcVar9 - (int)pcVar4] = '\0';
              uVar12 = 0;
              iVar5 = 0;
              for (pcVar4 = local_44; *pcVar4 != '\0'; pcVar4 = pcVar4 + 1) {
                if (iVar5 == 0) {
                  if (*pcVar4 == '/') {
                    *pcVar4 = '\0';
                    iVar5 = 2;
                  }
                }
                else if (iVar5 == 1) {
                  if (*pcVar4 == '/') {
                    iVar5 = 2;
                  }
                }
                else if (iVar5 == 2) {
                  cVar2 = *pcVar4;
                  if (cVar2 == 'B') {
LAB_004610c8:
                    iVar5 = 3;
                  }
                  else {
                    if (cVar2 != 'I') {
                      if (cVar2 == 'b') goto LAB_004610c8;
                      if (cVar2 != 'i') {
                        iVar5 = 1;
                        goto LAB_00461121;
                      }
                    }
                    uVar12 = uVar12 | 0x10;
                    iVar5 = 1;
                  }
                }
                else if (iVar5 == 3) {
                  cVar2 = *pcVar4;
                  if (cVar2 < '[') {
                    if (cVar2 == 'Z') {
LAB_00461110:
                      uVar12 = uVar12 | 4;
                    }
                    else {
                      if (cVar2 != '/') {
                        if (cVar2 != 'X') {
                          if (cVar2 != 'Y') goto LAB_0046111c;
                          goto LAB_0046110b;
                        }
                        goto LAB_00461106;
                      }
                      iVar5 = 2;
                    }
                  }
                  else if (cVar2 == 'x') {
LAB_00461106:
                    uVar12 = uVar12 | 1;
                  }
                  else if (cVar2 == 'y') {
LAB_0046110b:
                    uVar12 = uVar12 | 2;
                  }
                  else {
                    if (cVar2 == 'z') goto LAB_00461110;
LAB_0046111c:
                    iVar5 = 1;
                  }
                }
LAB_00461121:
              }
              pcVar4 = (char *)FUN_00402298(0x20);
              if (pcVar4 == (char *)0x0) {
                pcVar4 = (char *)0x0;
              }
              else {
                pcVar4 = FUN_00459fb4(pcVar4,local_44,local_10,uVar12,0,0);
              }
              puVar3 = (undefined4 *)FUN_00402298(0x14);
              if (puVar3 == (undefined4 *)0x0) {
                puVar3 = (undefined4 *)0x0;
              }
              else {
                puVar3 = FUN_0045a044(puVar3,pcVar4,1);
              }
              (**(code **)(local_54[0] + 4))(local_54,puVar3);
            }
          }
          local_c = puVar3;
          if (local_c == (undefined4 *)0x0) break;
        } while( true );
      }
      FUN_004614d7(local_60,(int)local_54);
      local_18 = (**(code **)(local_60[0] + 0x14))(local_60);
      local_1c = local_18 * 0x20 + 4;
      local_14 = (int *)FUN_004022b0(local_1c);
      *local_14 = local_18;
      piVar10 = local_14 + 1;
      while (iVar5 = (**(code **)(local_60[0] + 0x28))(local_60), iVar5 != 0) {
        piVar11 = *(int **)(iVar5 + 0xc);
        piVar13 = piVar10;
        for (iVar7 = 8; iVar7 != 0; iVar7 = iVar7 + -1) {
          *piVar13 = *piVar11;
          piVar11 = piVar11 + 1;
          piVar13 = piVar13 + 1;
        }
        piVar10 = piVar10 + 8;
      }
      puVar3 = (undefined4 *)FUN_00406db4(param_1,param_2,10,1,0,local_14,local_1c,-1);
      FUN_0045a134((int)local_54);
      FUN_004022d0(local_14);
      if (local_8 != (int *)0x0) {
        (**(code **)*local_8)(local_8,3);
      }
      FUN_00461515(local_60,2);
      FUN_00452ccc(local_54,2);
      goto LAB_00461277;
    }
    uVar6 = 0xffffffff;
  }
  else {
LAB_00461277:
    uVar6 = *puVar3;
  }
  return uVar6;
LAB_00460f2e:
  if (((*pcVar9 == ';') || (*pcVar9 == '#')) ||
     ((*pcVar9 == '/' && (*(char *)((int)local_c + 9) == '/')))) {
    bVar14 = true;
  }
  else {
    bVar14 = false;
  }
  local_c = puVar3;
  if ((((!bVar14) && (iVar5 = FUN_004d4ae0(pcVar9,s_skeleton_004f316d,8), iVar5 != 0)) &&
      (iVar5 = FUN_004d4ae0(pcVar9,s_destroyed_004f3176,9), iVar5 != 0)) &&
     (iVar5 = FUN_004d4ae0(pcVar9,&DAT_004f3180,3), iVar5 != 0)) {
    FUN_004dbb24(&DAT_00524e20,s_Unknown_entry___004f3184,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,pcVar9,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___in_model___004f3194,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___ignored__004f31a1,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  goto LAB_00460e73;
}



/* @00461280 file=? name=FUN_00461280 */

int * __cdecl FUN_00461280(int *param_1)

{
  undefined4 *puVar1;
  int iVar2;
  
  puVar1 = (undefined4 *)FUN_00402298(0x10);
  if (puVar1 == (undefined4 *)0x0) {
    iVar2 = 0;
  }
  else {
    iVar2 = FUN_004023f4(puVar1);
  }
  *param_1 = iVar2;
  *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
  return param_1;
}



/* @004612b0 file=? name=FUN_004612b0 */

void __cdecl FUN_004612b0(int *param_1,byte param_2)

{
  int *piVar1;
  int *piVar2;
  
  if (param_1 != (int *)0x0) {
    piVar2 = (int *)*param_1;
    piVar1 = piVar2 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar2,3);
    }
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004612dd file=? name=FUN_004612dd */

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

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



/* @004612fc file=? name=FUN_004612fc */

void __cdecl FUN_004612fc(int *param_1,byte param_2)

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



/* @00461328 file=? name=FUN_00461328 */

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

{
  FUN_00418bb8(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f32e0;
  return param_1;
}



/* @0046134b file=? name=FUN_0046134b */

void __cdecl FUN_0046134b(int *param_1,byte param_2)

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



/* @00461377 file=? name=FUN_00461377 */

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

{
  int iVar1;
  undefined4 uVar2;
  
  iVar1 = FUN_004027d8(*(int *)(param_2 + 0x20),*(int *)(param_3 + 0x20));
  if (iVar1 == 0) {
    uVar2 = 0;
  }
  else {
    iVar1 = FUN_004027d8(*(int *)(param_2 + 0x20),*(int *)(param_3 + 0x20));
    if (iVar1 < 1) {
      uVar2 = 0xffffffff;
    }
    else {
      uVar2 = 1;
    }
  }
  return uVar2;
}



/* @004613c4 file=? name=FUN_004613c4 */

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

{
  int iVar1;
  undefined4 uVar2;
  
  iVar1 = FUN_004027d8(*param_2,*(int *)(param_3 + 0x20));
  if (iVar1 == 0) {
    uVar2 = 0;
  }
  else {
    iVar1 = FUN_004027d8(*param_2,*(int *)(param_3 + 0x20));
    if (iVar1 < 1) {
      uVar2 = 0xffffffff;
    }
    else {
      uVar2 = 1;
    }
  }
  return uVar2;
}



/* @0046140e file=? name=FUN_0046140e */

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

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



/* @00461431 file=? name=FUN_00461431 */

void __cdecl FUN_00461431(int *param_1,byte param_2)

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



/* @0046145d file=? name=FUN_0046145d */

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

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



/* @0046148c file=? name=FUN_0046148c */

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

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



/* @004614b8 file=? name=FUN_004614b8 */

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

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



/* @004614d7 file=? name=FUN_004614d7 */

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

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



/* @004614f6 file=? name=FUN_004614f6 */

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

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



/* @00461515 file=? name=FUN_00461515 */

void __cdecl FUN_00461515(int *param_1,byte param_2)

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



/* @00461541 file=? name=FUN_00461541 */

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

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



/* @00461560 file=? name=FUN_00461560 */

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

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



/* @0046157f file=? name=FUN_0046157f */

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

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



/* @0046159e file=? name=FUN_0046159e */

void __cdecl FUN_0046159e(int *param_1,byte param_2)

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



/* @004615ca file=? name=FUN_004615ca */

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

{
  FUN_00418f34(param_1,param_2);
  *param_1 = (int)&PTR_FUN_004f31c4;
  return param_1;
}



/* @004615e9 file=? name=FUN_004615e9 */

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

{
  FUN_00418f34(param_1,param_2);
  *param_1 = (int)&PTR_FUN_004f31c4;
  return param_1;
}



/* @00461608 file=? name=FUN_00461608 */

void __cdecl FUN_00461608(int *param_1,byte param_2)

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



/* @00461634 file=? name=FUN_00461634 */

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

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



/* @00461664 file=? name=FUN_00461664 */

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

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



/* @00461694 file=? name=FUN_00461694 */

void __cdecl FUN_00461694(int *param_1,byte param_2)

{
  int *piVar1;
  int *piVar2;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f3308;
    piVar2 = (int *)param_1[3];
    piVar1 = piVar2 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar2,3);
    }
    FUN_00415ed8(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004616d5 file=? name=FUN_004616d5 */

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

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



/* @00461700 file=? name=FUN_00461700 */

void __cdecl FUN_00461700(int *param_1,byte param_2)

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



/* @0046172c file=? name=FUN_0046172c */

void FUN_0046172c(void)

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



/* @0046177c file=? name=FUN_0046177c */

void __cdecl FUN_0046177c(undefined4 *param_1)

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



/* @004617c8 file=? name=FUN_004617c8 */

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

{
  int iVar1;
  int iVar2;
  
  iVar1 = FUN_004d4a78(param_2);
  while( true ) {
    if (*param_1 == '\0') {
      return (char *)0x0;
    }
    iVar2 = FUN_004d4ae0(param_1,param_2,iVar1);
    if (iVar2 == 0) break;
    param_1 = param_1 + 1;
  }
  while( true ) {
    if (*param_1 == '~') {
      if (param_1[1] != '\0') {
        return param_1 + 1;
      }
      return (char *)0x0;
    }
    if (*param_1 == '\0') break;
    param_1 = param_1 + 1;
  }
  return (char *)0x0;
}



/* @0046181c file=? name=FUN_0046181c */

undefined4 __cdecl FUN_0046181c(char *param_1)

{
  char *pcVar1;
  int iVar2;
  
  pcVar1 = FUN_004617c8(param_1,s_video_004f3378);
  if (pcVar1 == (char *)0x0) {
    return 0;
  }
  iVar2 = FUN_004d4ae0(pcVar1,&DAT_004f337e,4);
  if (iVar2 == 0) {
    DAT_004f3368 = 0x2c0;
    DAT_004f336c = 0x1e0;
    return 1;
  }
  iVar2 = FUN_004d4ae0(pcVar1,s_ntsc_rgb_004f3383,4);
  if (iVar2 == 0) {
    DAT_004f3368 = 0x2c0;
    DAT_004f336c = 0x1e0;
    return 1;
  }
  iVar2 = FUN_004d4ae0(pcVar1,&DAT_004f338c,3);
  if (iVar2 == 0) {
    DAT_004f3368 = 0x280;
    DAT_004f336c = 0x1e0;
    return 1;
  }
  iVar2 = FUN_004d4ae0(pcVar1,&DAT_004f3390,3);
  if (iVar2 == 0) {
    DAT_004f3368 = 0x340;
    DAT_004f336c = 0x200;
    return 1;
  }
  iVar2 = FUN_004d4ae0(pcVar1,s_pal_rgb_004f3394,7);
  if (iVar2 == 0) {
    DAT_004f3368 = 0x340;
    DAT_004f336c = 0x200;
    return 1;
  }
  iVar2 = FUN_004d4ae0(pcVar1,s_hires_004f339c,5);
  if (iVar2 == 0) {
    DAT_004f3368 = 0x400;
    DAT_004f336c = 0x300;
    return 1;
  }
  iVar2 = FUN_004d4ae0(pcVar1,&DAT_004f33a2,4);
  if (iVar2 == 0) {
    DAT_004f3368 = 0x340;
    DAT_004f336c = 0x200;
    return 1;
  }
  iVar2 = FUN_004d4ae0(pcVar1,s_nucolor_004f33a7,7);
  if (iVar2 == 0) {
    DAT_004f3368 = 0x280;
    DAT_004f336c = 0x1e0;
    return 1;
  }
  iVar2 = FUN_004d4ae0(pcVar1,s_kaiser_004f33af,6);
  if (iVar2 == 0) {
    DAT_004f3368 = 0x340;
    DAT_004f336c = 0x100;
    return 1;
  }
  FUN_004d771c(s_Unknown_video_format__s_004f33b6);
  DAT_004f3368 = 0x280;
  DAT_004f336c = 0x1e0;
  return 0;
}



/* @00461a14 file=? name=FUN_00461a14 */

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

undefined4 * __cdecl FUN_00461a14(int param_1,int *param_2,int *param_3,float param_4)

{
  undefined4 *puVar1;
  undefined4 *puVar2;
  int iVar3;
  undefined4 *puVar4;
  float local_8;
  
  if (param_4 <= DAT_004f3374) {
    local_8 = DAT_004f3374;
  }
  else {
    local_8 = param_4 + _DAT_00461c70;
  }
  FUN_004d771c(s_initialize_eyes_004f33cf);
  puVar2 = FUN_004896cc();
  FUN_004d771c(s_create_1st_view_004f33e0);
  iVar3 = FUN_004896f0();
  *param_2 = iVar3;
  if (iVar3 == 0) {
    FUN_004d771c(s_NULL_eye_004f33f1);
    puVar2 = (undefined4 *)0x0;
  }
  else {
    puVar1 = (undefined4 *)*param_2;
    puVar4 = (undefined4 *)FUN_00489708();
    FUN_0048b4ac((int)puVar1,(int)puVar4);
    FUN_0048a890((int)puVar2);
    FUN_0048b56c((int)puVar1,DAT_004f3370,DAT_004f3374);
    FUN_0048b608((int)puVar1,0x3ecccccd,0x3f19999a,0x3f666666);
    FUN_0048b6b4((int)puVar1,0,0x3f000000,0x3f000000,0x3f19999a,param_4,local_8);
    FUN_0048b8fc((int)puVar1);
    FUN_0048b9d0((int)puVar1,0xbf800000,0xbf800000,0x3f800000,0x3f800000,0x3fa66666);
    FUN_00489bd4((int)puVar1);
    FUN_0048d3e8(puVar4);
    FUN_0048d42c(puVar1);
    FUN_0048d4b0(puVar2);
    if (param_1 == 0) {
      *param_3 = 0;
    }
    else {
      FUN_004d771c(s_create_2nd_view_004f33fb);
      iVar3 = FUN_004896f0();
      *param_3 = iVar3;
      if (iVar3 == 0) {
        FUN_004d771c(s_NULL_rye_004f340c);
        puVar2 = (undefined4 *)0x0;
      }
      else {
        puVar1 = (undefined4 *)*param_3;
        puVar4 = (undefined4 *)FUN_00489708();
        FUN_0048b4ac((int)puVar1,(int)puVar4);
        FUN_0048b56c((int)puVar1,DAT_004f3370,DAT_004f3374);
        FUN_0048b608((int)puVar1,0x3ecccccd,0x3f19999a,0x3f666666);
        FUN_0048b6b4((int)puVar1,0,0x3f000000,0x3f000000,0x3f19999a,param_4,local_8);
        FUN_0048b8fc((int)puVar1);
        FUN_0048b9d0((int)puVar1,0xbf800000,0xbf800000,0x3f800000,0x3f800000,0x3fa66666);
        FUN_00489bd4((int)puVar1);
        FUN_0048d3e8(puVar4);
        FUN_0048d42c(puVar1);
      }
    }
  }
  return puVar2;
}



/* @00461c74 file=? name=FUN_00461c74 */

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

{
  bool bVar1;
  int *piVar2;
  uint uVar3;
  char *pcVar4;
  
  bVar1 = true;
  uVar3 = 0;
  pcVar4 = param_1;
  do {
    if (*pcVar4 == param_3) {
      if (uVar3 == 0) {
        piVar2 = FUN_004de55c(1);
        *param_2 = (int)piVar2;
        *(undefined1 *)*param_2 = 0;
      }
      else {
        piVar2 = FUN_004de55c(uVar3 + 1);
        *param_2 = (int)piVar2;
        FUN_004d4918((undefined4 *)*param_2,(undefined4 *)param_1,uVar3);
        *(undefined1 *)(*param_2 + uVar3) = 0;
      }
      pcVar4 = pcVar4 + 1;
      bVar1 = false;
    }
    else if (*pcVar4 == '\0') {
      if (uVar3 == 0) {
        return (char *)0x0;
      }
      piVar2 = FUN_004de55c(uVar3 + 1);
      *param_2 = (int)piVar2;
      FUN_004d4918((undefined4 *)*param_2,(undefined4 *)param_1,uVar3);
      *(undefined1 *)(*param_2 + uVar3) = 0;
      bVar1 = false;
    }
    else {
      uVar3 = uVar3 + 1;
      pcVar4 = pcVar4 + 1;
    }
  } while (bVar1);
  return pcVar4;
}



/* @00461d14 file=? name=FUN_00461d14 */

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

{
  int iVar1;
  
  iVar1 = 0;
  while ((*param_2 != '\0' &&
         (param_2 = FUN_00461c74(param_2,(int *)(param_1 + iVar1 * 4),param_3),
         param_2 != (char *)0x0))) {
    iVar1 = iVar1 + 1;
  }
  return iVar1;
}



/* @00461d50 file=? name=FUN_00461d50 */

void __cdecl FUN_00461d50(char *param_1,int param_2,int *param_3,int *param_4,float param_5)

{
  int iVar1;
  undefined4 local_84 [32];
  
  iVar1 = FUN_00461d14((int)local_84,param_1,'~');
  FUN_0048d108(iVar1,local_84);
  FUN_00461a14(param_2,param_3,param_4,param_5);
  return;
}



/* @00461d90 file=? name=FUN_00461d90 */

undefined4 __cdecl FUN_00461d90(int param_1,LPCSTR param_2)

{
  undefined4 uVar1;
  uint uVar2;
  int *piVar3;
  char *pcVar4;
  char *pcVar5;
  DWORD DVar6;
  int iVar7;
  uint unaff_EDI;
  undefined4 local_14;
  undefined4 local_10;
  int local_8;
  
  if (*(int *)(&DAT_004f3558 + param_1 * 4) == 0xf) {
    uVar1 = 0xffffffff;
  }
  else {
    uVar2 = thunk_FUN_004d93ac(param_2,0x8000,unaff_EDI);
    if (uVar2 == 0xffffffff) {
      uVar1 = 0xfffffffe;
    }
    else {
      piVar3 = FUN_004de55c(0x2000);
      if (piVar3 == (int *)0x0) {
        thunk_FUN_004d92c4(uVar2);
        uVar1 = 0xfffffffd;
      }
      else {
        pcVar4 = (char *)FUN_0048790c(*(undefined4 *)(&DAT_00501368 + param_1 * 0x68),
                                      *(undefined4 *)(&DAT_0050136c + param_1 * 0x68),local_14,
                                      local_10,*(undefined4 *)(&DAT_004f3558 + param_1 * 4),0);
        if (pcVar4 == (char *)0xffffffff) {
          FUN_004de420(piVar3);
          thunk_FUN_004d92c4(uVar2);
          uVar1 = 0xfffffffc;
        }
        else {
          pcVar5 = thunk_FUN_004d892c(uVar2,(char *)piVar3,pcVar4);
          if (pcVar5 == (char *)0xffffffff) {
            uVar1 = 0xfffffffb;
          }
          else {
            uVar1 = FUN_0047ef40();
            local_8 = FUN_0048790c(*(undefined4 *)(&DAT_00501380 + param_1 * 0x68),
                                   *(undefined4 *)(&DAT_00501384 + param_1 * 0x68),piVar3,uVar1,
                                   *(undefined4 *)(&DAT_004f3558 + param_1 * 4),0);
            if (local_8 == -1) {
              FUN_004de420(piVar3);
              thunk_FUN_004d92c4(uVar2);
              uVar1 = 0xfffffffa;
            }
            else {
              DVar6 = thunk_FUN_004d9334(uVar2,local_8,0);
              if (DVar6 == 0xffffffff) {
                thunk_FUN_004d92c4(uVar2);
                FUN_004de420(*(int **)(&DAT_004f3418 +
                                      *(int *)(&DAT_004f3558 + param_1 * 4) * 4 + param_1 * 0x40));
                uVar1 = 0xfffffff9;
              }
              else {
                do {
                  pcVar4 = thunk_FUN_004d892c(uVar2,(char *)piVar3,pcVar4);
                  if (pcVar4 == (char *)0xffffffff) {
                    return 0xfffffff8;
                  }
                  uVar1 = FUN_0047ef40();
                  pcVar4 = (char *)FUN_0048790c(*(undefined4 *)(&DAT_00501370 + param_1 * 0x68),
                                                *(undefined4 *)(&DAT_00501374 + param_1 * 0x68),
                                                piVar3,uVar1,
                                                *(undefined4 *)(&DAT_004f3558 + param_1 * 4),0);
                  if (pcVar4 == (char *)0xffffffff) {
                    thunk_FUN_004d92c4(uVar2);
                    FUN_004de420(piVar3);
                    return 0xfffffff7;
                  }
                } while (pcVar4 != (char *)0x0);
                FUN_004de420(piVar3);
                pcVar4 = (char *)FUN_0048790c(*(undefined4 *)(&DAT_00501378 + param_1 * 0x68),
                                              *(undefined4 *)(&DAT_0050137c + param_1 * 0x68),piVar3
                                              ,uVar1,0,0);
                uVar1 = FUN_0047ef40();
                FUN_0048790c(*(undefined4 *)(&DAT_00501388 + param_1 * 0x68),
                             *(undefined4 *)(&DAT_0050138c + param_1 * 0x68),&local_8,uVar1,0,0);
                piVar3 = FUN_004de55c((uint)pcVar4);
                *(int **)(&DAT_004f3418 + *(int *)(&DAT_004f3558 + param_1 * 4) * 4 + param_1 * 0x40
                         ) = piVar3;
                if (piVar3 == (int *)0x0) {
                  thunk_FUN_004d92c4(uVar2);
                  uVar1 = 0xfffffff6;
                }
                else {
                  DVar6 = thunk_FUN_004d9334(uVar2,local_8,0);
                  if (DVar6 == 0xffffffff) {
                    thunk_FUN_004d92c4(uVar2);
                    FUN_004de420(*(int **)(&DAT_004f3418 +
                                          *(int *)(&DAT_004f3558 + param_1 * 4) * 4 + param_1 * 0x40
                                          ));
                    uVar1 = 0xfffffff5;
                  }
                  else {
                    pcVar4 = thunk_FUN_004d892c(uVar2,*(char **)(&DAT_004f3418 +
                                                                *(int *)(&DAT_004f3558 + param_1 * 4
                                                                        ) * 4 + param_1 * 0x40),
                                                pcVar4);
                    if (pcVar4 == (char *)0xffffffff) {
                      thunk_FUN_004d92c4(uVar2);
                      FUN_004de420(*(int **)(&DAT_004f3418 +
                                            *(int *)(&DAT_004f3558 + param_1 * 4) * 4 +
                                            param_1 * 0x40));
                      uVar1 = 0xfffffff4;
                    }
                    else {
                      uVar1 = FUN_0047ef40();
                      iVar7 = FUN_0048790c(*(undefined4 *)(&DAT_00501390 + param_1 * 0x68),
                                           *(undefined4 *)(&DAT_00501394 + param_1 * 0x68),
                                           *(undefined4 *)
                                            (&DAT_004f3418 +
                                            *(int *)(&DAT_004f3558 + param_1 * 4) * 4 +
                                            param_1 * 0x40),uVar1,0,0);
                      if (iVar7 == -1) {
                        FUN_004de420(*(int **)(&DAT_004f3418 +
                                              *(int *)(&DAT_004f3558 + param_1 * 4) * 4 +
                                              param_1 * 0x40));
                        thunk_FUN_004d92c4(uVar2);
                        uVar1 = 0xfffffff3;
                      }
                      else {
                        thunk_FUN_004d92c4(uVar2);
                        *(int *)(&DAT_004f3558 + param_1 * 4) =
                             *(int *)(&DAT_004f3558 + param_1 * 4) + 1;
                        uVar1 = *(undefined4 *)(&DAT_004f3558 + param_1 * 4);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  return uVar1;
}



/* @00462124 file=? name=FUN_00462124 */

undefined4 __cdecl FUN_00462124(int param_1)

{
  int iVar1;
  undefined4 uVar2;
  undefined *puVar3;
  uint uVar4;
  undefined4 local_c;
  undefined4 local_8;
  
  iVar1 = FUN_0048790c(*(undefined4 *)(&DAT_00501388 + param_1 * 0x68),
                       *(undefined4 *)(&DAT_0050138c + param_1 * 0x68),local_c,local_8,1,0);
  if (iVar1 == -1) {
    uVar2 = 0xffffffff;
  }
  else {
    puVar3 = &DAT_004f341c;
    for (uVar4 = 1; uVar4 < *(uint *)(&DAT_004f3558 + param_1 * 4); uVar4 = uVar4 + 1) {
      FUN_004de420(*(int **)(puVar3 + param_1 * 0x40));
      puVar3 = puVar3 + 4;
    }
    *(undefined4 *)(&DAT_004f3558 + param_1 * 4) = 1;
    uVar2 = 0;
  }
  return uVar2;
}



/* @004621ac file=? name=FUN_004621ac */

undefined4 __cdecl
FUN_004621ac(int param_1,undefined1 param_2,byte param_3,undefined1 param_4,undefined1 param_5,
            undefined1 param_6)

{
  byte local_14;
  undefined1 local_13;
  undefined1 local_12;
  
  local_14 = param_3 | 0xb0;
  local_13 = 0;
  local_12 = param_2;
  FUN_00486402(param_1,&local_14,3);
  local_14 = param_3 | 0xc0;
  local_13 = param_4;
  FUN_00486402(param_1,&local_14,2);
  local_14 = param_3 | 0x90;
  local_13 = param_5;
  local_12 = param_6;
  FUN_00486402(param_1,&local_14,2);
  return 0;
}



/* @00462224 file=? name=FUN_00462224 */

undefined4 __cdecl FUN_00462224(int param_1,byte param_2,undefined1 param_3)

{
  byte local_14;
  undefined1 local_13;
  undefined1 local_12;
  
  local_14 = param_2 | 0x90;
  local_13 = param_3;
  local_12 = 0;
  FUN_00486402(param_1,&local_14,3);
  return 0;
}



/* @00462254 file=? name=FUN_00462254 */

undefined4 FUN_00462254(void)

{
  return 1;
}



/* @00462260 file=? name=FUN_00462260 */

int * __cdecl FUN_00462260(int *param_1,byte *param_2)

{
  int *piVar1;
  
  FUN_004dbb24(param_1,&DAT_004f3582,(char *)0x0);
  piVar1 = FUN_004db78c(param_1,*param_2 & 0xf);
  FUN_004dbb24(piVar1,&DAT_004f3584,(char *)0x0);
  piVar1 = FUN_004db78c(param_1,(int)(uint)*param_2 >> 4);
  FUN_004dbb24(piVar1,&DAT_004f3586,(char *)0x0);
  piVar1 = FUN_004db78c(param_1,(uint)param_2[1]);
  FUN_004dbb24(piVar1,&DAT_004f3588,(char *)0x0);
  piVar1 = FUN_004db78c(param_1,(uint)param_2[2]);
  FUN_004dbb24(piVar1,&DAT_004f358a,(char *)0x0);
  return param_1;
}



/* @0046230c file=? name=FUN_0046230c */

undefined4 * __cdecl
FUN_0046230c(undefined4 *param_1,undefined4 param_2,undefined1 param_3,undefined4 param_4)

{
  FUN_00415e90(param_1,1);
  *param_1 = &PTR_FUN_004f36b4;
  param_1[3] = param_2;
  *(undefined1 *)(param_1 + 4) = param_3;
  param_1[5] = 0;
  param_1[6] = param_4;
  return param_1;
}



/* @00462340 file=? name=FUN_00462340 */

void __cdecl FUN_00462340(int *param_1,byte param_2)

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



/* @0046236c file=? name=FUN_0046236c */

undefined4 FUN_0046236c(void)

{
  FUN_00415f1c();
  return 1;
}



/* @00462380 file=? name=FUN_00462380 */

undefined4 * __cdecl FUN_00462380(undefined4 *param_1)

{
  undefined4 *puVar1;
  byte bVar2;
  
  FUN_004178cc(param_1,2);
  *param_1 = &PTR_FUN_004f36a8;
  FUN_00462c4e(param_1 + 0x15,0);
  FUN_00462c4e(param_1 + 0x19,0);
  bVar2 = 0;
  param_1[0x14] = 0x20;
  do {
    if (bVar2 == 9) {
      puVar1 = (undefined4 *)FUN_00402298(0x1c);
      if (puVar1 == (undefined4 *)0x0) {
        puVar1 = (undefined4 *)0x0;
      }
      else {
        puVar1 = FUN_0046230c(puVar1,1,9,param_1);
      }
      (**(code **)(param_1[0x19] + 4))(param_1 + 0x19,puVar1);
    }
    else {
      puVar1 = (undefined4 *)FUN_00402298(0x1c);
      if (puVar1 == (undefined4 *)0x0) {
        puVar1 = (undefined4 *)0x0;
      }
      else {
        puVar1 = FUN_0046230c(puVar1,0,bVar2,param_1);
      }
      (**(code **)(param_1[0x15] + 4))(param_1 + 0x15,puVar1);
    }
    bVar2 = bVar2 + 1;
  } while (bVar2 < 0x10);
  return param_1;
}



/* @00462430 file=? name=FUN_00462430 */

void __cdecl FUN_00462430(int *param_1,byte param_2)

{
  void *this;
  void *this_00;
  int local_1c [3];
  int local_10 [3];
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f36a8;
    FUN_00462c99(local_10,(int)(param_1 + 0x15));
    FUN_00417858(this,local_10,1);
    FUN_00462cf6(local_10,2);
    FUN_00462c99(local_1c,(int)(param_1 + 0x19));
    FUN_00417858(this_00,local_1c,1);
    FUN_00462cf6(local_1c,2);
    FUN_00462c6d(param_1 + 0x19,2);
    FUN_00462c6d(param_1 + 0x15,2);
    FUN_0041790c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004624d8 file=? name=FUN_004624d8 */

undefined4 FUN_004624d8(void)

{
  FUN_00415f1c();
  return 1;
}



/* @004624ec file=munga_l4/l4audhdw.cpp name=FUN_004624ec */

void __cdecl FUN_004624ec(int param_1)

{
  int iVar1;
  char *pcVar2;
  
  *(undefined4 *)(param_1 + 0x28) = 0;
  *(undefined4 *)(param_1 + 0x40) = *(undefined4 *)(param_1 + 0x1c);
  iVar1 = FUN_004832c2(0xa008,(undefined4 *)(param_1 + 0x40),param_1 + 0x20,(uint *)(param_1 + 0x4c)
                      );
  if (iVar1 != 0) {
    pcVar2 = FUN_004814e9(iVar1);
    FUN_004dbb24(&DAT_00524e20,pcVar2,(char *)0x0);
    FUN_0040385c(s_AudioCard__Initialize___sosMIDII_004f358c,
                 s_d__tesla_bt_munga_l4_L4AUDHDW_CP_004f35be,0xfa);
  }
  return;
}



/* @0046254c file=? name=FUN_0046254c */

void __cdecl FUN_0046254c(int param_1)

{
  FUN_00462124(*(int *)(param_1 + 0x4c));
  FUN_00483799(*(int *)(param_1 + 0x4c));
  FUN_004836b0(*(uint *)(param_1 + 0x4c),1);
  return;
}



/* @00462578 file=? name=FUN_00462578 */

void __cdecl FUN_00462578(int param_1,char *param_2)

{
  char *pcVar1;
  int iVar2;
  int iVar3;
  char *local_14;
  int local_10;
  int local_c;
  int local_8;
  
  iVar3 = 0xffff;
  local_8 = 0xffff;
  local_c = 0xffff;
  local_10 = 0xffff;
  iVar2 = 0xffff;
  local_14 = (char *)FUN_004dee74(param_2);
  while (*local_14 != '\0') {
    if ((*local_14 == 'a') || (pcVar1 = local_14, *local_14 == 'A')) {
      pcVar1 = local_14 + 1;
      if (*pcVar1 != '\0') {
        if (*pcVar1 == ':') {
          pcVar1 = local_14 + 2;
        }
        local_14 = pcVar1;
        iVar3 = FUN_00462abc(param_1,(int *)&local_14);
        pcVar1 = local_14;
      }
    }
    local_14 = pcVar1;
    if ((*local_14 == 'i') || (pcVar1 = local_14, *local_14 == 'I')) {
      pcVar1 = local_14 + 1;
      if (*pcVar1 != '\0') {
        if (*pcVar1 == ':') {
          pcVar1 = local_14 + 2;
        }
        local_14 = pcVar1;
        local_8 = FUN_00462abc(param_1,(int *)&local_14);
        pcVar1 = local_14;
      }
    }
    local_14 = pcVar1;
    if ((*local_14 == 'd') || (pcVar1 = local_14, *local_14 == 'D')) {
      pcVar1 = local_14 + 1;
      if (*pcVar1 != '\0') {
        if (*pcVar1 == ':') {
          pcVar1 = local_14 + 2;
        }
        local_14 = pcVar1;
        local_c = FUN_00462abc(param_1,(int *)&local_14);
        pcVar1 = local_14;
      }
    }
    local_14 = pcVar1;
    if ((*local_14 == 'e') || (pcVar1 = local_14, *local_14 == 'E')) {
      pcVar1 = local_14 + 1;
      if (*pcVar1 != '\0') {
        if (*pcVar1 == ':') {
          pcVar1 = local_14 + 2;
        }
        local_14 = pcVar1;
        iVar2 = FUN_00462abc(param_1,(int *)&local_14);
        pcVar1 = local_14;
      }
    }
    local_14 = pcVar1;
    if ((*local_14 == 'p') || (pcVar1 = local_14, *local_14 == 'P')) {
      pcVar1 = local_14 + 1;
      if (*pcVar1 != '\0') {
        if (*pcVar1 == ':') {
          pcVar1 = local_14 + 2;
        }
        local_14 = pcVar1;
        local_10 = FUN_00462abc(param_1,(int *)&local_14);
        pcVar1 = local_14;
      }
    }
    while ((local_14 = pcVar1, *local_14 != '\0' && (*local_14 != ' '))) {
      pcVar1 = local_14 + 1;
    }
    for (; *local_14 == ' '; local_14 = local_14 + 1) {
    }
  }
  if (iVar2 == 0xffff) {
    iVar2 = iVar3 + 0x400;
  }
  *(int *)(param_1 + 0xc) = iVar3;
  *(int *)(param_1 + 0x10) = local_8;
  *(int *)(param_1 + 0x14) = local_c;
  *(int *)(param_1 + 0x18) = local_10;
  *(int *)(param_1 + 0x1c) = iVar2;
  return;
}



/* @00462728 file=? name=FUN_00462728 */

undefined4 FUN_00462728(void)

{
  return 0;
}



/* @00462730 file=? name=FUN_00462730 */

void FUN_00462730(void)

{
  return;
}



/* @00462738 file=? name=FUN_00462738 */

undefined4 FUN_00462738(void)

{
  return 0;
}



/* @00462740 file=? name=FUN_00462740 */

undefined4 FUN_00462740(void)

{
  return 0;
}



/* @00462748 file=? name=FUN_00462748 */

void __cdecl FUN_00462748(int param_1)

{
  int iVar1;
  int local_1c [3];
  int local_10 [3];
  
  FUN_00462c99(local_10,param_1 + 0x54);
  while( true ) {
    iVar1 = (**(code **)(local_10[0] + 0x28))(local_10);
    if (iVar1 == 0) break;
    FUN_0046285c(*(int *)(iVar1 + 0x18),*(byte *)(iVar1 + 0x10),0x18);
  }
  FUN_00462cf6(local_10,2);
  FUN_00462c99(local_1c,param_1 + 100);
  iVar1 = (**(code **)(local_1c[0] + 0x30))(local_1c);
  FUN_0046285c(*(int *)(iVar1 + 0x18),*(byte *)(iVar1 + 0x10),0x18);
  FUN_00462cf6(local_1c,2);
  return;
}



/* @004627d8 file=? name=FUN_004627d8 */

void __cdecl FUN_004627d8(int param_1,LPCSTR param_2)

{
  FUN_00461d90(*(int *)(param_1 + 0x4c),param_2);
  return;
}



/* @004627f4 file=? name=FUN_004627f4 */

void __cdecl FUN_004627f4(int param_1)

{
  FUN_00462124(*(int *)(param_1 + 0x4c));
  return;
}



/* @00462808 file=? name=FUN_00462808 */

void __cdecl FUN_00462808(int param_1,byte param_2,int param_3)

{
  uint uVar1;
  uint uVar2;
  byte local_27;
  undefined1 local_26;
  undefined1 local_25;
  
  uVar1 = param_3 + 0x2000;
  uVar2 = uVar1;
  if ((int)uVar1 < 0) {
    uVar2 = param_3 + 0x207f;
  }
  uVar1 = uVar1 & 0x8000007f;
  if ((int)uVar1 < 0) {
    uVar1 = (uVar1 - 1 | 0xffffff80) + 1;
  }
  local_27 = param_2 | 0xe0;
  local_26 = (undefined1)uVar1;
  local_25 = (undefined1)((int)uVar2 >> 7);
  FUN_00486402(*(int *)(param_1 + 0x4c),&local_27,3);
  return;
}



/* @0046285c file=? name=FUN_0046285c */

void __cdecl FUN_0046285c(int param_1,byte param_2,undefined1 param_3)

{
  byte local_2f [3];
  byte local_2c [5];
  byte local_27 [35];
  
  local_27[0] = param_2 | 0xb0;
  local_27[1] = 0x65;
  local_27[2] = 0;
  FUN_00486402(*(int *)(param_1 + 0x4c),local_27,3);
  local_2c[0] = param_2 | 0xb0;
  local_2c[1] = 100;
  local_2c[2] = 0;
  FUN_00486402(*(int *)(param_1 + 0x4c),local_2c,3);
  local_2f[0] = param_2 | 0xb0;
  local_2f[1] = 6;
  local_2f[2] = param_3;
  FUN_00486402(*(int *)(param_1 + 0x4c),local_2f,3);
  return;
}



/* @004628d8 file=? name=FUN_004628d8 */

void __cdecl FUN_004628d8(int param_1,byte param_2,undefined1 param_3,int param_4)

{
  int iVar1;
  uint uVar2;
  byte local_34 [5];
  byte local_2f [3];
  byte local_2c [5];
  byte local_27 [35];
  
  local_27[0] = param_2 | 0xb0;
  local_27[1] = 99;
  local_27[2] = 0x7f;
  FUN_00486402(*(int *)(param_1 + 0x4c),local_27,3);
  local_2c[0] = param_2 | 0xb0;
  local_2c[1] = 0x62;
  local_2c[2] = param_3;
  FUN_00486402(*(int *)(param_1 + 0x4c),local_2c,3);
  iVar1 = param_4 + 0x2000;
  if (iVar1 < 0) {
    iVar1 = param_4 + 0x207f;
  }
  local_2f[0] = param_2 | 0xb0;
  local_2f[1] = 6;
  local_2f[2] = (byte)(iVar1 >> 7);
  FUN_00486402(*(int *)(param_1 + 0x4c),local_2f,3);
  uVar2 = param_4 + 0x2000U & 0x8000007f;
  if ((int)uVar2 < 0) {
    uVar2 = (uVar2 - 1 | 0xffffff80) + 1;
  }
  local_34[0] = param_2 | 0xb0;
  local_34[1] = 0x26;
  local_34[2] = (byte)uVar2;
  FUN_00486402(*(int *)(param_1 + 0x4c),local_34,3);
  return;
}



/* @0046299c file=? name=FUN_0046299c */

void __cdecl FUN_0046299c(int param_1,int param_2,undefined1 param_3)

{
  if (param_2 == 0) {
    DAT_004f3574 = param_3;
    FUN_004629e4(param_1,&DAT_004f356c,0xb);
    return;
  }
  if (param_2 != 1) {
    return;
  }
  DAT_004f357f = param_3;
  FUN_004629e4(param_1,&DAT_004f3577,0xb);
  return;
}



/* @004629e4 file=munga_l4/l4audhdw.cpp name=FUN_004629e4 */

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

{
  int iVar1;
  
  iVar1 = FUN_00486402(*(int *)(param_1 + 0x4c),param_2,param_3);
  if (iVar1 != 0) {
    FUN_0040385c(s_AudioCard__SendSysex___wError____004f35e0,
                 s_d__tesla_bt_munga_l4_L4AUDHDW_CP_004f360f,0x2b9);
  }
  return;
}



/* @00462a1c file=? name=FUN_00462a1c */

int __cdecl FUN_00462a1c(int param_1,int param_2)

{
  int iVar1;
  int local_10 [3];
  
  if (*(int *)(param_1 + 0x50) < param_2) {
    iVar1 = 0;
  }
  else {
    FUN_00462c99(local_10,param_1 + 0x54);
    iVar1 = (**(code **)(local_10[0] + 0x30))(local_10);
    if (iVar1 == 0) {
      iVar1 = 0;
      FUN_00462cf6(local_10,2);
    }
    else {
      (**(code **)(local_10[0] + 0x48))(local_10);
      *(int *)(param_1 + 0x50) = *(int *)(param_1 + 0x50) - param_2;
      *(int *)(iVar1 + 0x14) = param_2;
      FUN_00462cf6(local_10,2);
    }
  }
  return iVar1;
}



/* @00462a98 file=? name=FUN_00462a98 */

void __cdecl FUN_00462a98(int param_1,int param_2)

{
  *(int *)(param_1 + 0x50) = *(int *)(param_1 + 0x50) + *(int *)(param_2 + 0x14);
  *(undefined4 *)(param_2 + 0x14) = 0;
  (**(code **)(*(int *)(param_1 + 0x54) + 4))(param_1 + 0x54,param_2);
  return;
}



/* @00462abc file=? name=FUN_00462abc */

int __cdecl FUN_00462abc(undefined4 param_1,int *param_2)

{
  char *pcVar1;
  int iVar2;
  
  iVar2 = 0;
  while( true ) {
    while( true ) {
      while( true ) {
        if (*(char *)*param_2 == '\0') {
          return iVar2;
        }
        if ((*(char *)*param_2 < '0') || ('9' < *(char *)*param_2)) break;
        pcVar1 = (char *)*param_2;
        *param_2 = *param_2 + 1;
        iVar2 = iVar2 * 0x10 + *pcVar1 + -0x30;
      }
      if ((*(char *)*param_2 < 'a') || ('f' < *(char *)*param_2)) break;
      pcVar1 = (char *)*param_2;
      *param_2 = *param_2 + 1;
      iVar2 = iVar2 * 0x10 + (int)*pcVar1 + -0x57;
    }
    if (*(char *)*param_2 < 'A') break;
    if ('F' < *(char *)*param_2) {
      return iVar2;
    }
    pcVar1 = (char *)*param_2;
    *param_2 = *param_2 + 1;
    iVar2 = iVar2 * 0x10 + (int)*pcVar1 + -0x37;
  }
  return iVar2;
}



/* @00462b38 file=? name=FUN_00462b38 */

undefined4 * __cdecl FUN_00462b38(undefined4 *param_1)

{
  FUN_004178cc(param_1,2);
  *param_1 = &PTR_FUN_004f369c;
  FUN_00462380(param_1 + 3);
  FUN_00462380(param_1 + 0x20);
  return param_1;
}



/* @00462b6c file=? name=FUN_00462b6c */

void __cdecl FUN_00462b6c(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f369c;
    FUN_00462430(param_1 + 0x20,2);
    FUN_00462430(param_1 + 3,2);
    FUN_0041790c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00462bb8 file=? name=FUN_00462bb8 */

undefined4 FUN_00462bb8(void)

{
  FUN_00415f1c();
  return 1;
}



/* @00462bcc file=? name=FUN_00462bcc */

void __cdecl FUN_00462bcc(int param_1)

{
  int iVar1;
  int iVar2;
  
  FUN_00483193((char *)0x0);
  iVar1 = param_1 + 0xc;
  FUN_00462578(iVar1,s_AWE_FRONT_004f3631);
  iVar2 = param_1 + 0x80;
  FUN_00462578(iVar2,s_AWE_REAR_004f363b);
  FUN_004624ec(iVar1);
  FUN_004624ec(iVar2);
  FUN_00462748(iVar1);
  FUN_00462748(iVar2);
  return;
}



/* @00462c28 file=? name=FUN_00462c28 */

void __cdecl FUN_00462c28(int param_1)

{
  FUN_0046254c(param_1 + 0xc);
  FUN_0046254c(param_1 + 0x80);
  FUN_004832a1();
  return;
}



/* @00462c4e file=? name=FUN_00462c4e */

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

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



/* @00462c6d file=? name=FUN_00462c6d */

void __cdecl FUN_00462c6d(int *param_1,byte param_2)

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



/* @00462c99 file=? name=FUN_00462c99 */

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

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



/* @00462cb8 file=? name=FUN_00462cb8 */

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

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



/* @00462cd7 file=? name=FUN_00462cd7 */

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

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



/* @00462cf6 file=? name=FUN_00462cf6 */

void __cdecl FUN_00462cf6(int *param_1,byte param_2)

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



/* @00462d24 file=? name=FUN_00462d24 */

void __cdecl FUN_00462d24(undefined4 *param_1)

{
  *param_1 = 0;
  param_1[1] = 0;
  param_1[2] = 0;
  param_1[3] = 0;
  param_1[4] = 0;
  param_1[5] = 0;
  param_1[6] = 0;
  param_1[7] = 0;
  param_1[8] = 0;
  param_1[9] = 0;
  return;
}



/* @00462d60 file=? name=FUN_00462d60 */

void __cdecl FUN_00462d60(int *param_1,byte param_2)

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



/* @00462d7c file=? name=FUN_00462d7c */

undefined4 FUN_00462d7c(void)

{
  return 1;
}



/* @00462d88 file=? name=FUN_00462d88 */

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

void __cdecl FUN_00462d88(float *param_1,float param_2)

{
  float fVar1;
  int iVar2;
  float fVar3;
  float10 fVar4;
  float10 fVar5;
  
  *param_1 = param_2;
  *param_1 = _DAT_0046312c + *param_1;
  if (_DAT_0046312c < *param_1) {
    *param_1 = *param_1 - _DAT_00463130;
  }
  iVar2 = *(int *)(*(int *)(DAT_004efc94 + 0x44) + 0x4c);
  param_1[1] = 0.0;
  param_1[2] = 0.0;
  param_1[3] = 0.0;
  param_1[4] = 0.0;
  fVar3 = *(float *)(iVar2 + 0x48);
  param_1[5] = 0.0;
  param_1[6] = 0.0;
  param_1[7] = 0.0;
  param_1[8] = 0.0;
  if ((*param_1 <= -0.7853982) || (0.7853982 <= *param_1)) {
    if ((*param_1 <= 0.7853982) || (_DAT_0046312c - 0.7853982 <= *param_1)) {
      if ((_DAT_0046312c - 0.7853982 < *param_1) || (*param_1 < _DAT_00463144 + 0.7853982)) {
        param_1[9] = 2.8026e-45;
        *param_1 = *param_1 - _DAT_0046312c;
        fVar4 = (float10)FUN_004dd188(SUB84((double)*param_1,0),
                                      (int)((ulonglong)(double)*param_1 >> 0x20));
        fVar5 = (float10)FUN_004dd188(0x60000000,0x3fe921fb);
        fVar1 = (float)(((float10)(double)fVar4 / fVar5) * (float10)_DAT_00463134);
        fVar4 = FUN_004dd138((double)(_DAT_00463134 + fVar1));
        param_1[4] = (float)fVar4;
        fVar4 = FUN_004dd138((double)(_DAT_00463134 - fVar1));
        param_1[3] = (float)fVar4;
        if (*param_1 <= -0.7853982) {
          param_1[8] = -(-fVar1 * fVar3 * _DAT_0046313c);
        }
        else {
          param_1[7] = -(fVar3 * fVar1 * _DAT_0046313c);
        }
      }
      else {
        param_1[9] = 4.2039e-45;
        *param_1 = *param_1 + _DAT_00463140;
        fVar4 = (float10)FUN_004dd188(SUB84((double)*param_1,0),
                                      (int)((ulonglong)(double)*param_1 >> 0x20));
        fVar5 = (float10)FUN_004dd188(SUB84((double)(_DAT_00463140 - 0.7853982),0),
                                      (int)((ulonglong)(double)(_DAT_00463140 - 0.7853982) >> 0x20))
        ;
        fVar1 = (float)(((float10)(double)fVar4 / fVar5) * (float10)_DAT_00463134);
        fVar4 = FUN_004dd138((double)(_DAT_00463134 + fVar1));
        param_1[2] = (float)fVar4;
        fVar4 = FUN_004dd138((double)(_DAT_00463134 - fVar1));
        param_1[4] = (float)fVar4;
        if (*param_1 <= _DAT_00463138) {
          param_1[8] = -fVar1 * fVar3 * _DAT_0046313c;
        }
        else {
          param_1[6] = fVar3 * fVar1 * _DAT_0046313c;
        }
      }
    }
    else {
      param_1[9] = 1.4013e-45;
      *param_1 = *param_1 - _DAT_00463140;
      fVar4 = (float10)FUN_004dd188(SUB84((double)*param_1,0),
                                    (int)((ulonglong)(double)*param_1 >> 0x20));
      fVar5 = (float10)FUN_004dd188(SUB84((double)(_DAT_00463140 - 0.7853982),0),
                                    (int)((ulonglong)(double)(_DAT_00463140 - 0.7853982) >> 0x20));
      fVar1 = (float)(((float10)(double)fVar4 / fVar5) * (float10)_DAT_00463134);
      fVar4 = FUN_004dd138((double)(_DAT_00463134 + fVar1));
      param_1[3] = (float)fVar4;
      fVar4 = FUN_004dd138((double)(_DAT_00463134 - fVar1));
      param_1[1] = (float)fVar4;
      if (*param_1 <= _DAT_00463138) {
        param_1[5] = -fVar1 * fVar3 * _DAT_0046313c;
      }
      else {
        param_1[7] = fVar3 * fVar1 * _DAT_0046313c;
      }
    }
  }
  else {
    param_1[9] = 0.0;
    fVar4 = (float10)FUN_004dd188(SUB84((double)*param_1,0),
                                  (int)((ulonglong)(double)*param_1 >> 0x20));
    fVar5 = (float10)FUN_004dd188(0x60000000,0x3fe921fb);
    fVar1 = (float)(((float10)(double)fVar4 / fVar5) * (float10)_DAT_00463134);
    fVar4 = FUN_004dd138((double)(_DAT_00463134 + fVar1));
    param_1[1] = (float)fVar4;
    fVar4 = FUN_004dd138((double)(_DAT_00463134 - fVar1));
    param_1[2] = (float)fVar4;
    if (*param_1 <= _DAT_00463138) {
      param_1[6] = -fVar1 * fVar3 * _DAT_0046313c;
    }
    else {
      param_1[5] = fVar3 * fVar1 * _DAT_0046313c;
    }
  }
  return;
}



/* @00463148 file=? name=FUN_00463148 */

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

{
  FUN_00438060(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f3ac0;
  FUN_00462d24(param_1 + 0x19);
  FUN_0046317c((int)param_1);
  return param_1;
}



/* @0046317c file=? name=FUN_0046317c */

void __cdecl FUN_0046317c(int param_1)

{
  int *piVar1;
  int iVar2;
  int *piVar3;
  
  iVar2 = *(int *)(*(int *)(DAT_004efc94 + 0x44) + 0x18);
  piVar3 = (int *)FUN_00414b60();
  piVar1 = (int *)(param_1 + 0x8c);
  *piVar1 = *piVar3;
  *piVar1 = *piVar1 - iVar2;
  *(undefined4 *)(param_1 + 0x90) = 0;
  *(undefined4 *)(param_1 + 0x94) = 0;
  *(undefined4 *)(param_1 + 0x98) = 0;
  *(undefined4 *)(param_1 + 0x9c) = 0;
  *(undefined4 *)(param_1 + 0xa0) = 0;
  *(undefined4 *)(param_1 + 0xa4) = 0;
  *(undefined4 *)(param_1 + 0xa8) = 0;
  *(undefined4 *)(param_1 + 0xac) = 0;
  return;
}



/* @004631f4 file=? name=FUN_004631f4 */

void __cdecl FUN_004631f4(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f3ac0;
    FUN_00462d60(param_1 + 0x19,2);
    FUN_004380f8(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00463230 file=? name=FUN_00463230 */

undefined4 __cdecl FUN_00463230(int param_1)

{
  FUN_00438178(param_1);
  return 1;
}



/* @00463244 file=? name=FUN_00463244 */

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

void FUN_00463244(int param_1,int param_2)

{
  int iVar1;
  float fVar2;
  float fVar3;
  int *piVar4;
  float10 fVar5;
  
  FUN_004383b4(param_1,(int *)param_2);
  if (*(int *)(param_1 + 0x38) == 0) {
    FUN_00462d88((float *)(param_1 + 100),*(float *)(param_1 + 0x4c));
    piVar4 = (int *)FUN_00414b60();
    iVar1 = *piVar4 - *(int *)(param_1 + 0x8c);
    piVar4 = (int *)FUN_00414b60();
    *(int *)(param_1 + 0x8c) = *piVar4;
    *(undefined4 *)(param_1 + 0xa0) = 0;
    *(undefined4 *)(param_1 + 0xa4) = 0;
    *(undefined4 *)(param_1 + 0xa8) = 0;
    *(undefined4 *)(param_1 + 0xac) = 0;
    fVar5 = FUN_004dcd00((double)((float)iVar1 / DAT_0052140c));
    if ((float10)_DAT_00463574 < fVar5) {
      if (*(float *)(param_1 + 0x90) != *(float *)(param_1 + 0x78)) {
        *(float *)(param_1 + 0xa0) =
             ((*(float *)(param_1 + 0x78) - *(float *)(param_1 + 0x90)) * 1915.5) /
             ((float)iVar1 / DAT_0052140c);
        *(undefined4 *)(param_1 + 0x90) = *(undefined4 *)(param_1 + 0x78);
      }
      if (*(float *)(param_1 + 0x94) != *(float *)(param_1 + 0x7c)) {
        *(float *)(param_1 + 0xa4) =
             ((*(float *)(param_1 + 0x7c) - *(float *)(param_1 + 0x94)) * 1915.5) /
             ((float)iVar1 / DAT_0052140c);
        *(undefined4 *)(param_1 + 0x94) = *(undefined4 *)(param_1 + 0x7c);
      }
      if (*(float *)(param_1 + 0x98) != *(float *)(param_1 + 0x80)) {
        *(float *)(param_1 + 0xa8) =
             ((*(float *)(param_1 + 0x80) - *(float *)(param_1 + 0x98)) * 1915.5) /
             ((float)iVar1 / DAT_0052140c);
        *(undefined4 *)(param_1 + 0x98) = *(undefined4 *)(param_1 + 0x80);
      }
      if (*(float *)(param_1 + 0x9c) != *(float *)(param_1 + 0x84)) {
        *(float *)(param_1 + 0xac) =
             ((*(float *)(param_1 + 0x84) - *(float *)(param_1 + 0x9c)) * 1915.5) /
             ((float)iVar1 / DAT_0052140c);
        *(undefined4 *)(param_1 + 0x9c) = *(undefined4 *)(param_1 + 0x84);
      }
    }
    fVar3 = *(float *)(param_2 + 0x18) * _DAT_00463578;
    fVar5 = FUN_004dd138((double)(*(float *)(param_1 + 0x44) * *(float *)(param_1 + 0x44) +
                                 *(float *)(param_1 + 0x3c) * *(float *)(param_1 + 0x3c) + 0.0));
    if ((float)fVar5 < fVar3) {
      fVar3 = ((fVar3 - (float)fVar5) * _DAT_00463578) / fVar3;
      fVar5 = FUN_004dd138((double)(_DAT_0046357c - fVar3));
      fVar2 = (float)fVar5;
      fVar5 = FUN_004dd138((double)fVar3);
      fVar3 = (float)fVar5;
      iVar1 = *(int *)(param_1 + 0x88);
      if (iVar1 == 0) {
        *(float *)(param_1 + 0x70) = *(float *)(param_1 + 0x68) * fVar3;
        *(float *)(param_1 + 0x74) = *(float *)(param_1 + 0x6c) * fVar3;
        *(float *)(param_1 + 0x68) = fVar2 * *(float *)(param_1 + 0x68);
        *(float *)(param_1 + 0x6c) = fVar2 * *(float *)(param_1 + 0x6c);
      }
      else if (iVar1 == 1) {
        *(float *)(param_1 + 0x74) = *(float *)(param_1 + 0x70) * fVar3;
        *(float *)(param_1 + 0x6c) = *(float *)(param_1 + 0x68) * fVar3;
        *(float *)(param_1 + 0x70) = fVar2 * *(float *)(param_1 + 0x70);
        *(float *)(param_1 + 0x68) = fVar2 * *(float *)(param_1 + 0x68);
      }
      else if (iVar1 == 2) {
        *(float *)(param_1 + 0x6c) = *(float *)(param_1 + 0x74) * fVar3;
        *(float *)(param_1 + 0x68) = *(float *)(param_1 + 0x70) * fVar3;
        *(float *)(param_1 + 0x74) = fVar2 * *(float *)(param_1 + 0x74);
        *(float *)(param_1 + 0x70) = fVar2 * *(float *)(param_1 + 0x70);
      }
      else if (iVar1 == 3) {
        *(float *)(param_1 + 0x68) = *(float *)(param_1 + 0x6c) * fVar3;
        *(float *)(param_1 + 0x70) = *(float *)(param_1 + 0x74) * fVar3;
        *(float *)(param_1 + 0x6c) = fVar2 * *(float *)(param_1 + 0x6c);
        *(float *)(param_1 + 0x74) = fVar2 * *(float *)(param_1 + 0x74);
      }
    }
  }
  else {
    *(undefined4 *)(param_1 + 0x68) = 0x3f800000;
    *(undefined4 *)(param_1 + 0x6c) = 0x3f800000;
    *(undefined4 *)(param_1 + 0x70) = 0x3f800000;
    *(undefined4 *)(param_1 + 0x74) = 0x3f800000;
    *(undefined4 *)(param_1 + 0xa0) = 0;
    *(undefined4 *)(param_1 + 0xa4) = 0;
    *(undefined4 *)(param_1 + 0xa8) = 0;
    *(undefined4 *)(param_1 + 0xac) = 0;
  }
  return;
}



/* @0046324a file=? name=FUN_0046324a */

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

void FUN_0046324a(void)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  undefined4 *puVar4;
  int *piVar5;
  int unaff_EBP;
  float10 fVar6;
  
  piVar1 = *(int **)(unaff_EBP + 0xc);
  iVar2 = *(int *)(unaff_EBP + 8);
  FUN_004383b4(iVar2,piVar1);
  if (*(int *)(iVar2 + 0x38) == 0) {
    FUN_00462d88((float *)(iVar2 + 100),*(float *)(iVar2 + 0x4c));
    *(undefined4 *)(unaff_EBP + -4) = 0x44ef7000;
    puVar4 = (undefined4 *)FUN_00414b60();
    *(undefined4 *)(unaff_EBP + -8) = *puVar4;
    *(int *)(unaff_EBP + -8) = *(int *)(unaff_EBP + -8) - *(int *)(iVar2 + 0x8c);
    piVar5 = (int *)FUN_00414b60();
    *(int *)(iVar2 + 0x8c) = *piVar5;
    *(undefined4 *)(iVar2 + 0xa0) = 0;
    *(undefined4 *)(iVar2 + 0xa4) = 0;
    *(undefined4 *)(iVar2 + 0xa8) = 0;
    *(undefined4 *)(iVar2 + 0xac) = 0;
    *(float *)(unaff_EBP + -0xc) = (float)*(int *)(unaff_EBP + -8) / DAT_0052140c;
    fVar6 = FUN_004dcd00((double)*(float *)(unaff_EBP + -0xc));
    if ((float10)_DAT_00463574 < fVar6) {
      if (*(float *)(iVar2 + 0x90) != *(float *)(iVar2 + 0x78)) {
        *(float *)(iVar2 + 0xa0) =
             ((*(float *)(iVar2 + 0x78) - *(float *)(iVar2 + 0x90)) * *(float *)(unaff_EBP + -4)) /
             ((float)*(int *)(unaff_EBP + -8) / DAT_0052140c);
        *(undefined4 *)(iVar2 + 0x90) = *(undefined4 *)(iVar2 + 0x78);
      }
      if (*(float *)(iVar2 + 0x94) != *(float *)(iVar2 + 0x7c)) {
        *(float *)(iVar2 + 0xa4) =
             ((*(float *)(iVar2 + 0x7c) - *(float *)(iVar2 + 0x94)) * *(float *)(unaff_EBP + -4)) /
             ((float)*(int *)(unaff_EBP + -8) / DAT_0052140c);
        *(undefined4 *)(iVar2 + 0x94) = *(undefined4 *)(iVar2 + 0x7c);
      }
      if (*(float *)(iVar2 + 0x98) != *(float *)(iVar2 + 0x80)) {
        *(float *)(iVar2 + 0xa8) =
             ((*(float *)(iVar2 + 0x80) - *(float *)(iVar2 + 0x98)) * *(float *)(unaff_EBP + -4)) /
             ((float)*(int *)(unaff_EBP + -8) / DAT_0052140c);
        *(undefined4 *)(iVar2 + 0x98) = *(undefined4 *)(iVar2 + 0x80);
      }
      if (*(float *)(iVar2 + 0x9c) != *(float *)(iVar2 + 0x84)) {
        *(float *)(iVar2 + 0xac) =
             ((*(float *)(iVar2 + 0x84) - *(float *)(iVar2 + 0x9c)) * *(float *)(unaff_EBP + -4)) /
             ((float)*(int *)(unaff_EBP + -8) / DAT_0052140c);
        *(undefined4 *)(iVar2 + 0x9c) = *(undefined4 *)(iVar2 + 0x84);
      }
    }
    *(float *)(unaff_EBP + -0x10) = (float)piVar1[6] * _DAT_00463578;
    *(undefined4 *)(unaff_EBP + -0x18) = *(undefined4 *)(iVar2 + 0x44);
    *(undefined4 *)(unaff_EBP + -0x1c) = *(undefined4 *)(iVar2 + 0x3c);
    *(undefined4 *)(unaff_EBP + -0x34) = *(undefined4 *)(unaff_EBP + -0x1c);
    *(undefined4 *)(unaff_EBP + -0x30) = 0;
    *(undefined4 *)(unaff_EBP + -0x2c) = *(undefined4 *)(unaff_EBP + -0x18);
    fVar6 = FUN_004dd138((double)(*(float *)(unaff_EBP + -0x2c) * *(float *)(unaff_EBP + -0x2c) +
                                 *(float *)(unaff_EBP + -0x30) * *(float *)(unaff_EBP + -0x30) +
                                 *(float *)(unaff_EBP + -0x34) * *(float *)(unaff_EBP + -0x34)));
    *(float *)(unaff_EBP + -0x14) = (float)fVar6;
    if (*(float *)(unaff_EBP + -0x14) < *(float *)(unaff_EBP + -0x10)) {
      *(float *)(unaff_EBP + -0x20) =
           ((*(float *)(unaff_EBP + -0x10) - *(float *)(unaff_EBP + -0x14)) * _DAT_00463578) /
           *(float *)(unaff_EBP + -0x10);
      fVar6 = FUN_004dd138((double)(_DAT_0046357c - *(float *)(unaff_EBP + -0x20)));
      *(float *)(unaff_EBP + -0x24) = (float)fVar6;
      fVar6 = FUN_004dd138((double)*(float *)(unaff_EBP + -0x20));
      *(float *)(unaff_EBP + -0x28) = (float)fVar6;
      iVar3 = *(int *)(iVar2 + 0x88);
      if (iVar3 == 0) {
        *(float *)(iVar2 + 0x70) = *(float *)(iVar2 + 0x68) * *(float *)(unaff_EBP + -0x28);
        *(float *)(iVar2 + 0x74) = *(float *)(iVar2 + 0x6c) * *(float *)(unaff_EBP + -0x28);
        *(float *)(iVar2 + 0x68) = *(float *)(unaff_EBP + -0x24) * *(float *)(iVar2 + 0x68);
        *(float *)(iVar2 + 0x6c) = *(float *)(unaff_EBP + -0x24) * *(float *)(iVar2 + 0x6c);
      }
      else if (iVar3 == 1) {
        *(float *)(iVar2 + 0x74) = *(float *)(iVar2 + 0x70) * *(float *)(unaff_EBP + -0x28);
        *(float *)(iVar2 + 0x6c) = *(float *)(iVar2 + 0x68) * *(float *)(unaff_EBP + -0x28);
        *(float *)(iVar2 + 0x70) = *(float *)(unaff_EBP + -0x24) * *(float *)(iVar2 + 0x70);
        *(float *)(iVar2 + 0x68) = *(float *)(unaff_EBP + -0x24) * *(float *)(iVar2 + 0x68);
      }
      else if (iVar3 == 2) {
        *(float *)(iVar2 + 0x6c) = *(float *)(iVar2 + 0x74) * *(float *)(unaff_EBP + -0x28);
        *(float *)(iVar2 + 0x68) = *(float *)(iVar2 + 0x70) * *(float *)(unaff_EBP + -0x28);
        *(float *)(iVar2 + 0x74) = *(float *)(unaff_EBP + -0x24) * *(float *)(iVar2 + 0x74);
        *(float *)(iVar2 + 0x70) = *(float *)(unaff_EBP + -0x24) * *(float *)(iVar2 + 0x70);
      }
      else if (iVar3 == 3) {
        *(float *)(iVar2 + 0x68) = *(float *)(iVar2 + 0x6c) * *(float *)(unaff_EBP + -0x28);
        *(float *)(iVar2 + 0x70) = *(float *)(iVar2 + 0x74) * *(float *)(unaff_EBP + -0x28);
        *(float *)(iVar2 + 0x6c) = *(float *)(unaff_EBP + -0x24) * *(float *)(iVar2 + 0x6c);
        *(float *)(iVar2 + 0x74) = *(float *)(unaff_EBP + -0x24) * *(float *)(iVar2 + 0x74);
      }
    }
  }
  else {
    *(undefined4 *)(iVar2 + 0x68) = 0x3f800000;
    *(undefined4 *)(iVar2 + 0x6c) = 0x3f800000;
    *(undefined4 *)(iVar2 + 0x70) = 0x3f800000;
    *(undefined4 *)(iVar2 + 0x74) = 0x3f800000;
    *(undefined4 *)(iVar2 + 0xa0) = 0;
    *(undefined4 *)(iVar2 + 0xa4) = 0;
    *(undefined4 *)(iVar2 + 0xa8) = 0;
    *(undefined4 *)(iVar2 + 0xac) = 0;
  }
  return;
}



/* @00463580 file=? name=FUN_00463580 */

undefined4 * __cdecl FUN_00463580(undefined4 *param_1)

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



/* @004635a4 file=? name=FUN_004635a4 */

undefined4 FUN_004635a4(void)

{
  int iVar1;
  
  iVar1 = 0;
  do {
    iVar1 = iVar1 + 1;
  } while (iVar1 < 4);
  return 1;
}



/* @004635c0 file=? name=FUN_004635c0 */

void __cdecl FUN_004635c0(undefined4 *param_1)

{
  int iVar1;
  
  iVar1 = 0;
  do {
    *param_1 = 0;
    param_1[4] = 1;
    iVar1 = iVar1 + 1;
    param_1 = param_1 + 1;
  } while (iVar1 < 4);
  return;
}



/* @004635e0 file=? name=FUN_004635e0 */

void __cdecl FUN_004635e0(int *param_1)

{
  int iVar1;
  int iVar2;
  
  iVar2 = 0;
  do {
    iVar1 = *param_1;
    if (iVar1 != 0) {
      FUN_00462a98(*(int *)(iVar1 + 0x18),iVar1);
      *param_1 = 0;
    }
    iVar2 = iVar2 + 1;
    param_1 = param_1 + 1;
  } while (iVar2 < 4);
  return;
}



/* @00463610 file=? name=FUN_00463610 */

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

{
  FUN_0043b22c(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f3a60;
  FUN_00463580(param_1 + 0x29);
  FUN_00463668();
  return param_1;
}



/* @00463648 file=? name=FUN_00463648 */

void __cdecl FUN_00463648(int *param_1,int param_2)

{
  FUN_0043b37c(param_1,param_2);
  return;
}



/* @00463668 file=? name=FUN_00463668 */

void FUN_00463668(void)

{
  return;
}



/* @00463670 file=? name=FUN_00463670 */

void __cdecl FUN_00463670(int *param_1,byte param_2)

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



/* @0046369c file=? name=FUN_0046369c */

undefined4 __cdecl FUN_0046369c(int param_1)

{
  FUN_0043b9e0(param_1);
  return 1;
}



/* @004636b0 file=? name=FUN_004636b0 */

void __cdecl FUN_004636b0(int *param_1)

{
  FUN_00467a9c(*(int *)(DAT_004efc94 + 0x44),param_1);
  return;
}



/* @004636cc file=? name=FUN_004636cc */

void __cdecl FUN_004636cc(int param_1,undefined4 *param_2)

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



/* @004636ec file=? name=FUN_004636ec */

int __cdecl FUN_004636ec(int param_1)

{
  return param_1 + 0xa4;
}



/* @004636fc file=? name=FUN_004636fc */

void __cdecl FUN_004636fc(int param_1)

{
  FUN_004635e0((int *)(param_1 + 0xa4));
  return;
}



/* @00463710 file=? name=FUN_00463710 */

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

{
  FUN_00463610(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f3a00;
  (**(code **)(*param_2 + 0x1c))(param_2,param_1 + 0x31,4);
  param_1[0x32] = 0;
  return param_1;
}



/* @00463754 file=munga_l4/l4audio.cpp name=FUN_00463754 */

void __cdecl FUN_00463754(int *param_1,int param_2)

{
  char *pcVar1;
  int local_8;
  
  FUN_00463648(param_1,param_2);
  pcVar1 = (char *)FUN_00403ad0(param_2,s_position_004f36b8);
  if (pcVar1 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_DYN_MEM_STRM_WRITE_ENTRY____name_004f36c1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_position_004f36e6,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f36ef,(char *)0x0);
    FUN_0040385c(s_DYN_MEM_STRM_WRITE_ENTRY____name_004f36f1,
                 s_d__tesla_bt_munga_l4_L4AUDIO_CPP_004f3731,0x330);
  }
  FUN_00407ae0(pcVar1,&local_8);
  (**(code **)(*param_1 + 0x20))(param_1,&local_8,4);
  return;
}



/* @004637fc file=? name=FUN_004637fc */

void __cdecl FUN_004637fc(int *param_1,byte param_2)

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



/* @00463828 file=? name=FUN_00463828 */

undefined4 __cdecl FUN_00463828(int param_1)

{
  FUN_0046369c(param_1);
  return 1;
}



/* @00463848 file=? name=FUN_00463848 */

void __cdecl FUN_00463848(int *param_1)

{
  int iVar1;
  int *piVar2;
  int *piVar3;
  
  piVar2 = &DAT_00522c9c;
  piVar3 = param_1 + 0x29;
  for (iVar1 = 8; iVar1 != 0; iVar1 = iVar1 + -1) {
    *piVar3 = *piVar2;
    piVar2 = piVar2 + 1;
    piVar3 = piVar3 + 1;
  }
  iVar1 = param_1[0x31];
  if (iVar1 == 0) {
LAB_0046387c:
    param_1[0x2d] = 1;
  }
  else {
    if (iVar1 != 1) {
      if (iVar1 - 2U < 2) goto LAB_0046387c;
      if (1 < iVar1 - 4U) goto LAB_00463892;
    }
    param_1[0x2f] = 1;
  }
LAB_00463892:
  FUN_0046797c(*(int *)(DAT_004efc94 + 0x44),param_1);
  return;
}



/* @004638a8 file=? name=FUN_004638a8 */

void __cdecl FUN_004638a8(int *param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 uVar3;
  byte local_601;
  undefined1 local_600;
  undefined1 local_5ff;
  byte local_502 [255];
  byte local_403 [255];
  byte local_304 [4];
  undefined1 local_300;
  undefined1 local_2ff;
  byte local_202 [255];
  byte local_103 [255];
  
  FUN_0043bfa4((int)param_1);
  iVar2 = param_1[0x31];
  if (iVar2 == 0) {
LAB_004638d8:
    param_1[0x32] = param_1[0x29];
  }
  else {
    if (iVar2 != 1) {
      if (iVar2 - 2U < 2) goto LAB_004638d8;
      if (1 < iVar2 - 4U) goto LAB_004638f2;
    }
    param_1[0x32] = param_1[0x2b];
  }
LAB_004638f2:
  FUN_00436db0((int)param_1);
  local_103[0] = *(byte *)(param_1[0x32] + 0x10) | 0xb0;
  local_103[1] = 7;
  local_103[2] = 0;
  FUN_00486402(*(int *)(*(int *)(param_1[0x32] + 0x18) + 0x4c),local_103,3);
  iVar2 = param_1[10];
  FUN_004379b8(iVar2,*(float *)(param_1[9] + 0x48));
  FUN_00465cb4(iVar2,param_1[0x32]);
  local_202[0] = *(byte *)(param_1[0x32] + 0x10) | 0xb0;
  local_202[1] = 0x5b;
  local_202[2] = 0;
  FUN_00486402(*(int *)(*(int *)(param_1[0x32] + 0x18) + 0x4c),local_202,3);
  local_304[3] = *(byte *)(param_1[0x32] + 0x10) | 0xb0;
  local_300 = 0x5d;
  local_2ff = 0;
  FUN_00486402(*(int *)(*(int *)(param_1[0x32] + 0x18) + 0x4c),local_304 + 3,3);
  switch(param_1[0x31]) {
  case 0:
  case 1:
    local_304[0] = *(byte *)(param_1[0x32] + 0x10) | 0xb0;
    local_304[1] = 10;
    local_304[2] = 0x3f;
    FUN_00486402(*(int *)(*(int *)(param_1[0x32] + 0x18) + 0x4c),local_304,3);
    break;
  case 2:
  case 4:
    local_403[0] = *(byte *)(param_1[0x32] + 0x10) | 0xb0;
    local_403[1] = 10;
    local_403[2] = 0;
    FUN_00486402(*(int *)(*(int *)(param_1[0x32] + 0x18) + 0x4c),local_403,3);
    break;
  case 3:
  case 5:
    local_502[0] = *(byte *)(param_1[0x32] + 0x10) | 0xb0;
    local_502[1] = 10;
    local_502[2] = 0x7f;
    FUN_00486402(*(int *)(*(int *)(param_1[0x32] + 0x18) + 0x4c),local_502,3);
  }
  *(undefined1 *)(param_1 + 0x33) = 0;
  param_1[0x34] = 0;
  param_1[0x35] = 0x7f;
  uVar1 = FUN_004dcd94();
  if (param_1[0x19] != 0) {
    iVar2 = FUN_004dcd94();
    FUN_004628d8(*(int *)(param_1[0x32] + 0x18),*(byte *)(param_1[0x32] + 0x10),0xb,iVar2);
  }
  (**(code **)(*param_1 + 0x5c))(param_1,1);
  uVar3 = FUN_004dcd94();
  local_601 = *(byte *)(param_1[0x32] + 0x10) | 0x90;
  local_600 = (undefined1)uVar3;
  local_5ff = (undefined1)uVar1;
  FUN_00486402(*(int *)(*(int *)(param_1[0x32] + 0x18) + 0x4c),&local_601,3);
  return;
}



/* @00463bbc file=? name=FUN_00463bbc */

void __cdecl FUN_00463bbc(int *param_1,int param_2)

{
  int iVar1;
  uint uVar2;
  int iVar3;
  float10 fVar4;
  byte local_103 [243];
  float local_10;
  float local_c;
  float local_8;
  
  fVar4 = (float10)(**(code **)(*param_1 + 0x20))(param_1);
  local_8 = (float)fVar4;
  iVar1 = FUN_004dcd94();
  if (iVar1 < -0x1fff) {
    iVar1 = -0x1fff;
  }
  else if (0x1fff < iVar1) {
    iVar1 = 0x1fff;
  }
  iVar3 = param_1[0x34] - iVar1;
  if (iVar3 < 1) {
    iVar3 = -iVar3;
  }
  if ((0xb < iVar3) || (param_2 != 0)) {
    param_1[0x34] = iVar1;
    FUN_00462808(*(int *)(param_1[0x32] + 0x18),*(byte *)(param_1[0x32] + 0x10),iVar1);
  }
  if (param_1[0x22] != 0) {
    fVar4 = (float10)(**(code **)(*param_1 + 0x24))(param_1);
    local_c = (float)fVar4;
    FUN_00465ccc(param_1[10]);
    iVar1 = FUN_004dcd94();
    iVar3 = param_1[0x35] - iVar1;
    if (iVar3 < 1) {
      iVar3 = -iVar3;
    }
    if (1 < iVar3) {
      param_1[0x35] = iVar1;
      FUN_004628d8(*(int *)(param_1[0x32] + 0x18),*(byte *)(param_1[0x32] + 0x10),0x15,iVar1);
    }
  }
  fVar4 = (float10)(**(code **)(*param_1 + 0x1c))(param_1);
  local_10 = (float)fVar4;
  uVar2 = FUN_004dcd94();
  local_103[2] = (byte)uVar2;
  iVar1 = (uint)*(byte *)(param_1 + 0x33) - (uVar2 & 0xff);
  if (iVar1 < 1) {
    iVar1 = -iVar1;
  }
  if (1 < iVar1) {
    *(byte *)(param_1 + 0x33) = local_103[2];
    local_103[0] = *(byte *)(param_1[0x32] + 0x10) | 0xb0;
    local_103[1] = 7;
    FUN_00486402(*(int *)(*(int *)(param_1[0x32] + 0x18) + 0x4c),local_103,3);
  }
  return;
}



/* @00463d4c file=? name=FUN_00463d4c */

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

{
  FUN_00463610(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f39a0;
  return param_1;
}



/* @00463d70 file=? name=FUN_00463d70 */

void __cdecl FUN_00463d70(int *param_1,byte param_2)

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



/* @00463d9c file=? name=FUN_00463d9c */

undefined4 __cdecl FUN_00463d9c(int param_1)

{
  FUN_0046369c(param_1);
  return 1;
}



/* @00463db0 file=? name=FUN_00463db0 */

void __cdecl FUN_00463db0(int *param_1)

{
  FUN_004635c0(param_1 + 0x29);
  FUN_0046797c(*(int *)(DAT_004efc94 + 0x44),param_1);
  return;
}



/* @00463ddc file=? name=FUN_00463ddc */

void __cdecl FUN_00463ddc(int *param_1)

{
  int iVar1;
  undefined4 uVar2;
  int iVar3;
  int *piVar4;
  byte local_704;
  undefined1 local_703;
  undefined1 local_702;
  undefined1 local_609;
  int local_608;
  undefined1 local_604;
  byte local_603 [255];
  byte local_504 [4];
  undefined1 local_500;
  undefined1 local_4ff;
  byte local_402 [255];
  byte local_303 [255];
  byte local_204 [251];
  undefined1 local_109;
  int local_108;
  byte local_103 [251];
  undefined4 local_8;
  
  FUN_0043bfa4((int)param_1);
  local_8 = *(undefined4 *)(*(int *)(DAT_004efc94 + 0x44) + 0x4c);
  FUN_00436db0((int)param_1);
  iVar3 = 0;
  piVar4 = param_1 + 0x29;
  do {
    local_103[0] = *(byte *)(*piVar4 + 0x10) | 0xb0;
    local_103[1] = 7;
    local_103[2] = 0;
    FUN_00486402(*(int *)(*(int *)(*piVar4 + 0x18) + 0x4c),local_103,3);
    iVar3 = iVar3 + 1;
    piVar4 = piVar4 + 1;
  } while (iVar3 < 4);
  local_108 = param_1[10];
  FUN_004379b8(local_108,*(float *)(param_1[9] + 0x48));
  iVar3 = 0;
  piVar4 = param_1 + 0x29;
  do {
    FUN_00465cb4(local_108,*piVar4);
    iVar3 = iVar3 + 1;
    piVar4 = piVar4 + 1;
  } while (iVar3 < 4);
  uVar2 = FUN_004dcd94();
  local_109 = (undefined1)uVar2;
  iVar3 = 0;
  piVar4 = param_1 + 0x29;
  do {
    iVar1 = *piVar4;
    local_204[0] = *(byte *)(iVar1 + 0x10) | 0xb0;
    local_204[1] = 0x5b;
    local_204[2] = local_109;
    FUN_00486402(*(int *)(*(int *)(iVar1 + 0x18) + 0x4c),local_204,3);
    local_303[0] = *(byte *)(iVar1 + 0x10) | 0xb0;
    local_303[1] = 0x5d;
    local_303[2] = 0;
    FUN_00486402(*(int *)(*(int *)(iVar1 + 0x18) + 0x4c),local_303,3);
    iVar3 = iVar3 + 1;
    piVar4 = piVar4 + 1;
  } while (iVar3 < 4);
  local_402[0] = *(byte *)(param_1[0x29] + 0x10) | 0xb0;
  local_402[1] = 10;
  local_402[2] = 0;
  FUN_00486402(*(int *)(*(int *)(param_1[0x29] + 0x18) + 0x4c),local_402,3);
  local_504[3] = *(byte *)(param_1[0x2a] + 0x10) | 0xb0;
  local_500 = 10;
  local_4ff = 0x7f;
  FUN_00486402(*(int *)(*(int *)(param_1[0x2a] + 0x18) + 0x4c),local_504 + 3,3);
  local_504[0] = *(byte *)(param_1[0x2b] + 0x10) | 0xb0;
  local_504[1] = 10;
  local_504[2] = 0;
  FUN_00486402(*(int *)(*(int *)(param_1[0x2b] + 0x18) + 0x4c),local_504,3);
  local_603[0] = *(byte *)(param_1[0x2c] + 0x10) | 0xb0;
  local_603[1] = 10;
  local_603[2] = 0x7f;
  FUN_00486402(*(int *)(*(int *)(param_1[0x2c] + 0x18) + 0x4c),local_603,3);
  *(undefined1 *)(param_1 + 0x31) = 0;
  *(undefined1 *)((int)param_1 + 0xc5) = 0;
  *(undefined1 *)((int)param_1 + 0xc6) = 0;
  *(undefined1 *)((int)param_1 + 199) = 0;
  param_1[0x32] = 0;
  param_1[0x33] = 0;
  param_1[0x34] = 0;
  param_1[0x35] = 0;
  param_1[0x36] = 0x7f;
  uVar2 = FUN_004dcd94();
  local_604 = (undefined1)uVar2;
  if (param_1[0x19] != 0) {
    local_608 = FUN_004dcd94();
    iVar3 = 0;
    piVar4 = param_1 + 0x29;
    do {
      FUN_004628d8(*(int *)(*piVar4 + 0x18),*(byte *)(*piVar4 + 0x10),0xb,local_608);
      iVar3 = iVar3 + 1;
      piVar4 = piVar4 + 1;
    } while (iVar3 < 4);
  }
  (**(code **)(*param_1 + 0x5c))(param_1,1);
  iVar3 = 0;
  piVar4 = param_1 + 0x29;
  do {
    iVar1 = *piVar4;
    local_609 = local_604;
    uVar2 = FUN_004dcd94();
    local_704 = *(byte *)(iVar1 + 0x10) | 0x90;
    local_703 = (undefined1)uVar2;
    local_702 = local_609;
    FUN_00486402(*(int *)(*(int *)(iVar1 + 0x18) + 0x4c),&local_704,3);
    iVar3 = iVar3 + 1;
    piVar4 = piVar4 + 1;
  } while (iVar3 < 4);
  return;
}



/* @004641e0 file=? name=FUN_004641e0 */

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

void __cdecl FUN_004641e0(int *param_1,int param_2)

{
  bool bVar1;
  undefined4 uVar2;
  int iVar3;
  int iVar4;
  int iVar5;
  float10 fVar6;
  byte local_404 [255];
  byte local_305;
  char local_304;
  byte local_303 [255];
  byte local_204;
  char local_203;
  byte local_202 [255];
  byte local_103;
  char local_102;
  byte local_101 [171];
  byte local_56;
  char local_55;
  int local_54;
  int local_50;
  int local_4c;
  uint local_48;
  int local_44;
  int local_40;
  undefined4 local_3c;
  float local_38;
  int local_34;
  int local_30;
  int local_2c;
  float local_28;
  char local_24;
  char local_23;
  char local_22;
  char local_21;
  float local_20;
  float local_1c;
  int local_18;
  int local_14;
  int local_10;
  int local_c;
  int local_8;
  
  FUN_0043c030(param_1);
  local_8 = param_1[10];
  iVar4 = param_1[9];
  local_c = param_1[0x29];
  local_10 = param_1[0x2a];
  local_14 = param_1[0x2b];
  local_18 = param_1[0x2c];
  fVar6 = (float10)(**(code **)(*param_1 + 0x1c))(param_1);
  local_1c = (float)fVar6;
  local_20 = local_1c * _DAT_00464818;
  uVar2 = FUN_004dcd94();
  local_21 = (char)uVar2;
  uVar2 = FUN_004dcd94();
  local_22 = (char)uVar2;
  uVar2 = FUN_004dcd94();
  local_23 = (char)uVar2;
  uVar2 = FUN_004dcd94();
  local_24 = (char)uVar2;
  fVar6 = (float10)(**(code **)(*param_1 + 0x20))(param_1);
  local_28 = *(float *)(iVar4 + 0x58) + (float)fVar6;
  iVar3 = FUN_004dcd94();
  local_2c = FUN_004dcd94();
  local_30 = FUN_004dcd94();
  local_34 = FUN_004dcd94();
  if (iVar3 < -0x1fff) {
    iVar3 = -0x1fff;
  }
  else if (0x1fff < iVar3) {
    iVar3 = 0x1fff;
  }
  if (local_2c < -0x1fff) {
    local_2c = -0x1fff;
  }
  else if (0x1fff < local_2c) {
    local_2c = 0x1fff;
  }
  if (local_30 < -0x1fff) {
    local_30 = -0x1fff;
  }
  else if (0x1fff < local_30) {
    local_30 = 0x1fff;
  }
  if (local_34 < -0x1fff) {
    local_34 = -0x1fff;
  }
  else if (0x1fff < local_34) {
    local_34 = 0x1fff;
  }
  fVar6 = (float10)(**(code **)(*param_1 + 0x24))(param_1);
  local_38 = *(float *)(iVar4 + 0x54) * (float)fVar6;
  FUN_00465ccc(local_8);
  iVar4 = FUN_004dcd94();
  local_3c = 2;
  iVar5 = iVar3 - param_1[0x32];
  if (iVar5 < 1) {
    iVar5 = -iVar5;
  }
  if ((1 < iVar5) || (param_2 != 0)) {
    param_1[0x32] = iVar3;
    FUN_00462808(*(int *)(local_c + 0x18),*(byte *)(local_c + 0x10),iVar3);
  }
  iVar3 = local_2c - param_1[0x33];
  if (iVar3 < 1) {
    iVar3 = -iVar3;
  }
  if ((1 < iVar3) || (param_2 != 0)) {
    param_1[0x33] = local_2c;
    FUN_00462808(*(int *)(local_10 + 0x18),*(byte *)(local_10 + 0x10),local_2c);
  }
  iVar3 = local_30 - param_1[0x34];
  if (iVar3 < 1) {
    iVar3 = -iVar3;
  }
  if ((1 < iVar3) || (param_2 != 0)) {
    param_1[0x34] = local_30;
    local_40 = local_30;
    FUN_00462808(*(int *)(local_14 + 0x18),*(byte *)(local_14 + 0x10),local_30);
  }
  iVar3 = local_34 - param_1[0x35];
  if (iVar3 < 1) {
    iVar3 = -iVar3;
  }
  if ((1 < iVar3) || (param_2 != 0)) {
    param_1[0x35] = local_34;
    local_44 = local_34;
    FUN_00462808(*(int *)(local_18 + 0x18),*(byte *)(local_18 + 0x10),local_34);
  }
  local_48 = 0;
  local_4c = 0;
  local_50 = 0;
  local_54 = 0;
  if ((char)param_1[0x31] != local_21) {
    local_48 = (uint)((char)param_1[0x31] == '\0');
    *(char *)(param_1 + 0x31) = local_21;
    local_55 = local_21;
    local_56 = *(byte *)(local_c + 0x10);
    local_101[0] = local_56 | 0xb0;
    local_101[1] = 7;
    local_101[2] = local_21;
    FUN_00486402(*(int *)(*(int *)(local_c + 0x18) + 0x4c),local_101,3);
  }
  if (*(char *)((int)param_1 + 0xc5) != local_22) {
    if (*(char *)((int)param_1 + 0xc5) == '\0') {
      local_4c = 1;
    }
    *(char *)((int)param_1 + 0xc5) = local_22;
    local_102 = local_22;
    local_103 = *(byte *)(local_10 + 0x10);
    local_202[0] = local_103 | 0xb0;
    local_202[1] = 7;
    local_202[2] = local_22;
    FUN_00486402(*(int *)(*(int *)(local_10 + 0x18) + 0x4c),local_202,3);
  }
  if (*(char *)((int)param_1 + 0xc6) != local_23) {
    if (*(char *)((int)param_1 + 0xc6) == '\0') {
      local_50 = 1;
    }
    *(char *)((int)param_1 + 0xc6) = local_23;
    local_203 = local_23;
    local_204 = *(byte *)(local_14 + 0x10);
    local_303[0] = local_204 | 0xb0;
    local_303[1] = 7;
    local_303[2] = local_23;
    FUN_00486402(*(int *)(*(int *)(local_14 + 0x18) + 0x4c),local_303,3);
  }
  if (*(char *)((int)param_1 + 199) != local_24) {
    if (*(char *)((int)param_1 + 199) == '\0') {
      local_54 = 1;
    }
    *(char *)((int)param_1 + 199) = local_24;
    local_304 = local_24;
    local_305 = *(byte *)(local_18 + 0x10);
    local_404[0] = local_305 | 0xb0;
    local_404[1] = 7;
    local_404[2] = local_24;
    FUN_00486402(*(int *)(*(int *)(local_18 + 0x18) + 0x4c),local_404,3);
  }
  iVar3 = iVar4 - param_1[0x36];
  if (iVar3 < 1) {
    iVar3 = -iVar3;
  }
  bVar1 = 3 < iVar3;
  if ((local_48 != 0) || ((bVar1 && (local_21 != '\0')))) {
    param_1[0x36] = iVar4;
    FUN_004628d8(*(int *)(local_c + 0x18),*(byte *)(local_c + 0x10),0x15,iVar4);
  }
  if ((local_4c != 0) || ((bVar1 && (local_22 != '\0')))) {
    param_1[0x36] = iVar4;
    FUN_004628d8(*(int *)(local_10 + 0x18),*(byte *)(local_10 + 0x10),0x15,iVar4);
  }
  if ((local_50 != 0) || ((bVar1 && (local_23 != '\0')))) {
    param_1[0x36] = iVar4;
    FUN_004628d8(*(int *)(local_14 + 0x18),*(byte *)(local_14 + 0x10),0x15,iVar4);
  }
  if ((local_54 != 0) || ((bVar1 && (local_24 != '\0')))) {
    param_1[0x36] = iVar4;
    FUN_004628d8(*(int *)(local_18 + 0x18),*(byte *)(local_18 + 0x10),0x15,iVar4);
  }
  return;
}



/* @0046487c file=? name=FUN_0046487c */

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

{
  FUN_00463610(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f3940;
  param_1[0x31] = 0;
  param_1[0x32] = 0;
  param_1[0x33] = 0;
  FUN_00462d24(param_1 + 0x35);
  (**(code **)(*param_2 + 0x1c))(param_2,param_1 + 0x34,4);
  return param_1;
}



/* @004648d8 file=? name=FUN_004648d8 */

void __cdecl FUN_004648d8(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f3940;
    FUN_00462d60(param_1 + 0x35,2);
    FUN_00463670(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00464918 file=munga_l4/l4audio.cpp name=FUN_00464918 */

void __cdecl FUN_00464918(int *param_1,int param_2)

{
  int iVar1;
  char *pcVar2;
  undefined4 local_c;
  int local_8;
  
  FUN_00463648(param_1,param_2);
  iVar1 = FUN_00403ad0(param_2,s_use_internal_004f3752);
  if (iVar1 == 0) {
    local_c = 1;
    (**(code **)(*param_1 + 0x20))(param_1,&local_c,4);
  }
  else {
    pcVar2 = (char *)FUN_00403ad0(param_2,s_use_internal_004f375f);
    if (pcVar2 == (char *)0x0) {
      FUN_004dbb24(&DAT_00524e20,s_DYN_MEM_STRM_WRITE_ENTRY____name_004f376c,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_use_internal_004f3791,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,&DAT_004f379e,(char *)0x0);
      FUN_0040385c(s_DYN_MEM_STRM_WRITE_ENTRY____name_004f37a0,
                   s_d__tesla_bt_munga_l4_L4AUDIO_CPP_004f37e0,0x6a2);
    }
    FUN_00407ae0(pcVar2,&local_8);
    (**(code **)(*param_1 + 0x20))(param_1,&local_8,4);
  }
  return;
}



/* @004649f4 file=? name=FUN_004649f4 */

undefined4 __cdecl FUN_004649f4(int param_1)

{
  FUN_0046369c(param_1);
  return 1;
}



/* @00464a14 file=? name=FUN_00464a14 */

void __cdecl FUN_00464a14(int param_1,undefined4 *param_2)

{
  FUN_00408440((undefined4 *)(param_1 + 0xc4),param_2);
  return;
}



/* @00464a34 file=? name=FUN_00464a34 */

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

void __cdecl FUN_00464a34(int *param_1)

{
  int iVar1;
  int *piVar2;
  int iVar3;
  float10 fVar4;
  float local_c;
  
  iVar1 = *(int *)(DAT_004efc94 + 0x44);
  if (param_1[0x34] == 0) {
    iVar3 = *(int *)(iVar1 + 0x4c);
    piVar2 = (int *)param_1[9];
    if (piVar2[0x18] <= *(int *)(iVar3 + 4)) {
      piVar2[0x18] = *(int *)(iVar3 + 4) + piVar2[0x17];
      (**(code **)(*piVar2 + 0x1c))(piVar2);
    }
    iVar3 = param_1[9];
    param_1[0x36] = *(int *)(iVar3 + 0x68);
    param_1[0x37] = *(int *)(iVar3 + 0x6c);
    param_1[0x38] = *(int *)(iVar3 + 0x70);
    param_1[0x39] = *(int *)(iVar3 + 0x74);
    param_1[0x3a] = *(int *)(iVar3 + 0x78);
    param_1[0x3b] = *(int *)(iVar3 + 0x7c);
    param_1[0x3c] = *(int *)(iVar3 + 0x80);
    param_1[0x3d] = *(int *)(iVar3 + 0x84);
    param_1[0x3e] = *(int *)(iVar3 + 0x88);
    param_1[0x35] = *(int *)(iVar3 + 100);
  }
  else {
    fVar4 = FUN_004dcd00((double)(float)param_1[0x31]);
    if (((float10)_DAT_00464bf8 < fVar4) ||
       (fVar4 = FUN_004dcd00((double)(float)param_1[0x33]), (float10)_DAT_00464bf8 < fVar4)) {
      fVar4 = FUN_004dc8ec((double)(float)param_1[0x31],SUB84((double)(float)param_1[0x33],0),
                           (uint)((ulonglong)(double)(float)param_1[0x33] >> 0x20));
      local_c = (float)fVar4;
    }
    else {
      local_c = 0.0;
    }
    FUN_00462d88((float *)(param_1 + 0x35),local_c);
  }
  param_1[0x2d] = 0;
  param_1[0x2e] = 0;
  param_1[0x2f] = 0;
  param_1[0x30] = 0;
  iVar3 = param_1[0x3e];
  if (iVar3 == 0) {
    param_1[0x2d] = 1;
  }
  else if (iVar3 == 1) {
    param_1[0x2d] = 1;
    param_1[0x2f] = 1;
  }
  else if (iVar3 == 2) {
    param_1[0x2f] = 1;
  }
  else if (iVar3 == 3) {
    param_1[0x2e] = 1;
    param_1[0x30] = 1;
  }
  FUN_0046797c(iVar1,param_1);
  return;
}



/* @004651ac file=? name=FUN_004651ac */

void __cdecl FUN_004651ac(int *param_1,int param_2)

{
  int iVar1;
  int iVar2;
  int iVar3;
  undefined4 uVar4;
  float10 fVar5;
  byte local_602 [255];
  byte local_503;
  char local_502;
  byte local_501 [251];
  byte local_406;
  char local_405;
  char local_404;
  char local_403;
  byte local_402 [255];
  byte local_303;
  char local_302;
  byte local_301 [251];
  byte local_206;
  char local_205;
  byte local_204 [255];
  byte local_105;
  char local_104;
  char local_103;
  char local_102;
  byte local_101 [207];
  byte local_32;
  char local_31;
  int local_30;
  int local_2c;
  int local_28;
  int local_24;
  float local_20;
  float local_1c;
  float local_18;
  int local_14;
  int local_10;
  int local_c;
  int local_8;
  
  iVar2 = param_1[10];
  local_8 = param_1[0x29];
  local_c = param_1[0x2a];
  local_10 = param_1[0x2b];
  local_14 = param_1[0x2c];
  fVar5 = (float10)(**(code **)(*param_1 + 0x1c))(param_1);
  local_18 = (float)fVar5;
  fVar5 = (float10)(**(code **)(*param_1 + 0x20))(param_1);
  local_1c = (float)fVar5;
  iVar1 = FUN_004dcd94();
  if (iVar1 < -0x1fff) {
    iVar1 = -0x1fff;
  }
  else if (0x1fff < iVar1) {
    iVar1 = 0x1fff;
  }
  fVar5 = (float10)(**(code **)(*param_1 + 0x24))(param_1);
  local_20 = (float)fVar5;
  FUN_00465ccc(iVar2);
  iVar2 = FUN_004dcd94();
  iVar3 = iVar1 - param_1[0x40];
  if (iVar3 < 1) {
    iVar3 = -iVar3;
  }
  if ((1 < iVar3) || (param_2 != 0)) {
    param_1[0x40] = iVar1;
    iVar3 = param_1[0x3e];
    if (iVar3 == 0) {
      FUN_00462808(*(int *)(local_8 + 0x18),*(byte *)(local_8 + 0x10),iVar1);
    }
    else if (iVar3 == 1) {
      FUN_00462808(*(int *)(local_8 + 0x18),*(byte *)(local_8 + 0x10),iVar1);
      FUN_00462808(*(int *)(local_10 + 0x18),*(byte *)(local_10 + 0x10),iVar1);
    }
    else if (iVar3 == 2) {
      FUN_00462808(*(int *)(local_10 + 0x18),*(byte *)(local_10 + 0x10),iVar1);
    }
    else if (iVar3 == 3) {
      FUN_00462808(*(int *)(local_c + 0x18),*(byte *)(local_c + 0x10),iVar1);
      FUN_00462808(*(int *)(local_14 + 0x18),*(byte *)(local_14 + 0x10),iVar1);
    }
  }
  if (param_1[0x22] != 0) {
    iVar1 = iVar2 - param_1[0x41];
    if (iVar1 < 1) {
      iVar1 = -iVar1;
    }
    if (1 < iVar1) {
      param_1[0x41] = iVar2;
      iVar1 = param_1[0x3e];
      if (iVar1 == 0) {
        FUN_004628d8(*(int *)(local_8 + 0x18),*(byte *)(local_8 + 0x10),0x15,iVar2);
      }
      else if (iVar1 == 1) {
        FUN_004628d8(*(int *)(local_8 + 0x18),*(byte *)(local_8 + 0x10),0x15,iVar2);
        local_24 = iVar2;
        FUN_004628d8(*(int *)(local_10 + 0x18),*(byte *)(local_10 + 0x10),0x15,iVar2);
      }
      else if (iVar1 == 2) {
        local_28 = iVar2;
        FUN_004628d8(*(int *)(local_10 + 0x18),*(byte *)(local_10 + 0x10),0x15,iVar2);
      }
      else if (iVar1 == 3) {
        local_2c = iVar2;
        FUN_004628d8(*(int *)(local_c + 0x18),*(byte *)(local_c + 0x10),0x15,iVar2);
        local_30 = iVar2;
        FUN_004628d8(*(int *)(local_14 + 0x18),*(byte *)(local_14 + 0x10),0x15,iVar2);
      }
    }
  }
  iVar2 = param_1[0x3e];
  if (iVar2 == 0) {
    uVar4 = FUN_004dcd94();
    local_101[2] = (byte)uVar4;
    if (local_101[2] != (char)param_1[0x3f]) {
      *(byte *)(param_1 + 0x3f) = local_101[2];
      local_32 = *(byte *)(local_8 + 0x10);
      local_101[0] = local_32 | 0xb0;
      local_101[1] = 7;
      local_31 = local_101[2];
      FUN_00486402(*(int *)(*(int *)(local_8 + 0x18) + 0x4c),local_101,3);
    }
  }
  else if (iVar2 == 1) {
    uVar4 = FUN_004dcd94();
    local_102 = (char)uVar4;
    uVar4 = FUN_004dcd94();
    local_103 = (char)uVar4;
    if (local_102 != (char)param_1[0x3f]) {
      *(char *)(param_1 + 0x3f) = local_102;
      local_104 = local_102;
      local_105 = *(byte *)(local_8 + 0x10);
      local_204[0] = local_105 | 0xb0;
      local_204[1] = 7;
      local_204[2] = local_102;
      FUN_00486402(*(int *)(*(int *)(local_8 + 0x18) + 0x4c),local_204,3);
    }
    if (local_103 != *(char *)((int)param_1 + 0xfe)) {
      *(char *)((int)param_1 + 0xfe) = local_103;
      local_205 = local_103;
      local_206 = *(byte *)(local_10 + 0x10);
      local_301[0] = local_206 | 0xb0;
      local_301[1] = 7;
      local_301[2] = local_103;
      FUN_00486402(*(int *)(*(int *)(local_10 + 0x18) + 0x4c),local_301,3);
    }
  }
  else if (iVar2 == 2) {
    uVar4 = FUN_004dcd94();
    local_402[2] = (byte)uVar4;
    if (local_402[2] != *(char *)((int)param_1 + 0xfe)) {
      *(byte *)((int)param_1 + 0xfe) = local_402[2];
      local_303 = *(byte *)(local_10 + 0x10);
      local_402[0] = local_303 | 0xb0;
      local_402[1] = 7;
      local_302 = local_402[2];
      FUN_00486402(*(int *)(*(int *)(local_10 + 0x18) + 0x4c),local_402,3);
    }
  }
  else if (iVar2 == 3) {
    uVar4 = FUN_004dcd94();
    local_403 = (char)uVar4;
    uVar4 = FUN_004dcd94();
    local_404 = (char)uVar4;
    if (local_403 != *(char *)((int)param_1 + 0xfd)) {
      *(char *)((int)param_1 + 0xfd) = local_403;
      local_405 = local_403;
      local_406 = *(byte *)(local_c + 0x10);
      local_501[0] = local_406 | 0xb0;
      local_501[1] = 7;
      local_501[2] = local_403;
      FUN_00486402(*(int *)(*(int *)(local_c + 0x18) + 0x4c),local_501,3);
    }
    if (local_404 != *(char *)((int)param_1 + 0xff)) {
      *(char *)((int)param_1 + 0xff) = local_404;
      local_502 = local_404;
      local_503 = *(byte *)(local_14 + 0x10);
      local_602[0] = local_503 | 0xb0;
      local_602[1] = 7;
      local_602[2] = local_404;
      FUN_00486402(*(int *)(*(int *)(local_14 + 0x18) + 0x4c),local_602,3);
    }
  }
  return;
}



/* @004657c9 file=? name=FUN_004657c9 */

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

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



/* @004657e8 file=? name=FUN_004657e8 */

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

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



/* @00465807 file=? name=FUN_00465807 */

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

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



/* @00465826 file=? name=FUN_00465826 */

void __cdecl FUN_00465826(int *param_1,byte param_2)

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



/* @00465852 file=? name=FUN_00465852 */

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

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



/* @00465871 file=? name=FUN_00465871 */

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

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



/* @00465890 file=? name=FUN_00465890 */

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

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



/* @004658af file=? name=FUN_004658af */

void __cdecl FUN_004658af(int *param_1,byte param_2)

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



/* @004658db file=? name=FUN_004658db */

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

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



/* @004658fa file=? name=FUN_004658fa */

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

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



/* @00465919 file=? name=FUN_00465919 */

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

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



/* @00465938 file=? name=FUN_00465938 */

void __cdecl FUN_00465938(int *param_1,byte param_2)

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



/* @00465964 file=? name=FUN_00465964 */

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

{
  FUN_0043744c(param_1,param_2);
  *param_1 = &PTR_FUN_004f3d04;
  (**(code **)(*param_2 + 0x1c))(param_2,param_1 + 6,1);
  (**(code **)(*param_2 + 0x1c))(param_2,(int)param_1 + 0x19,1);
  (**(code **)(*param_2 + 0x1c))(param_2,param_1 + 7,4);
  return param_1;
}



/* @004659b8 file=munga_l4/l4audlvl.cpp name=FUN_004659b8 */

void __cdecl FUN_004659b8(int *param_1,int param_2)

{
  char *pcVar1;
  int local_c;
  undefined1 local_6;
  undefined1 local_5;
  
  FUN_004374c4(param_1,param_2);
  pcVar1 = (char *)FUN_00403ad0(param_2,s_bank_ID_004f3ae0);
  if (pcVar1 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3ae8,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_bank_ID_004f3b0d,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f3b15,(char *)0x0);
    FUN_0040385c(s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3b17,
                 s_d__tesla_bt_munga_l4_L4AUDLVL_CP_004f3b57,0x57);
  }
  FUN_00407ab8(pcVar1,&local_5);
  (**(code **)(*param_1 + 0x20))(param_1,&local_5,1);
  pcVar1 = (char *)FUN_00403ad0(param_2,s_patch_ID_004f3b79);
  if (pcVar1 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3b82,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_patch_ID_004f3ba7,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f3bb0,(char *)0x0);
    FUN_0040385c(s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3bb2,
                 s_d__tesla_bt_munga_l4_L4AUDLVL_CP_004f3bf2,0x58);
  }
  FUN_00407ab8(pcVar1,&local_6);
  (**(code **)(*param_1 + 0x20))(param_1,&local_6,1);
  pcVar1 = (char *)FUN_00403ad0(param_2,s_max_filter_cutoff_004f3c14);
  if (pcVar1 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3c26,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_max_filter_cutoff_004f3c4b,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f3c5d,(char *)0x0);
    FUN_0040385c(s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3c5f,
                 s_d__tesla_bt_munga_l4_L4AUDLVL_CP_004f3c9f,0x59);
  }
  FUN_00407ae0(pcVar1,&local_c);
  (**(code **)(*param_1 + 0x20))(param_1,&local_c,4);
  return;
}



/* @00465b68 file=? name=FUN_00465b68 */

void __cdecl FUN_00465b68(int *param_1,byte param_2)

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



/* @00465b94 file=? name=FUN_00465b94 */

undefined4 FUN_00465b94(void)

{
  FUN_004376a4();
  return 1;
}



/* @00465ba8 file=? name=FUN_00465ba8 */

void __cdecl FUN_00465ba8(int param_1,int param_2)

{
  byte local_d [4];
  undefined1 local_9;
  undefined1 local_8;
  byte local_7 [3];
  
  local_7[2] = *(undefined1 *)(param_1 + 0x18);
  local_7[0] = *(byte *)(param_2 + 0x10) | 0xb0;
  local_7[1] = 0;
  FUN_00486402(*(int *)(*(int *)(param_2 + 0x18) + 0x4c),local_7,3);
  local_9 = *(undefined1 *)(param_1 + 0x19);
  local_d[3] = *(byte *)(param_2 + 0x10) | 0xc0;
  local_8 = 0;
  FUN_00486402(*(int *)(*(int *)(param_2 + 0x18) + 0x4c),local_d + 3,2);
  local_d[0] = *(byte *)(param_2 + 0x10) | 0xb0;
  local_d[1] = 0x79;
  local_d[2] = 0x7f;
  FUN_00486402(*(int *)(*(int *)(param_2 + 0x18) + 0x4c),local_d,3);
  return;
}



/* @00465c34 file=? name=FUN_00465c34 */

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

{
  FUN_004376b8(param_1,param_2);
  *param_1 = &PTR_FUN_004f3cf8;
  return param_1;
}



/* @00465c54 file=? name=FUN_00465c54 */

void __cdecl FUN_00465c54(int *param_1,int param_2)

{
  FUN_00437774(param_1,param_2);
  return;
}



/* @00465c74 file=? name=FUN_00465c74 */

void __cdecl FUN_00465c74(int *param_1,byte param_2)

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



/* @00465ca0 file=? name=FUN_00465ca0 */

undefined4 FUN_00465ca0(void)

{
  FUN_004379a4();
  return 1;
}



/* @00465cb4 file=? name=FUN_00465cb4 */

void __cdecl FUN_00465cb4(int param_1,int param_2)

{
  FUN_00465ba8(*(int *)(param_1 + 0xc),param_2);
  return;
}



/* @00465ccc file=? name=FUN_00465ccc */

undefined4 __cdecl FUN_00465ccc(int param_1)

{
  return *(undefined4 *)(*(int *)(param_1 + 0xc) + 0x1c);
}



/* @00465d08 file=? name=FUN_00465d08 */

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

{
  int *piVar1;
  undefined4 *puVar2;
  int iVar3;
  int *local_8;
  
  FUN_0043e738(param_1,param_2,param_3);
  *param_1 = (int)&PTR_LAB_004f3fd4;
  puVar2 = (undefined4 *)FUN_00402298(0x10);
  if (puVar2 == (undefined4 *)0x0) {
    local_8 = (int *)0x0;
  }
  else {
    local_8 = (int *)FUN_004023f4(puVar2);
  }
  local_8[3] = local_8[3] + 1;
  FUN_00402aec(param_2,(int *)&local_8);
  iVar3 = FUN_0041bfc0(param_3,(char *)local_8[2]);
  param_1[0x20] = iVar3;
  (**(code **)(*param_2 + 0x1c))(param_2,param_1 + 0x21,4);
  (**(code **)(*param_2 + 0x1c))(param_2,param_1 + 0x22,4);
  (**(code **)(*param_2 + 0x1c))(param_2,param_1 + 0x23,4);
  FUN_00441ef5(param_1);
  piVar1 = local_8 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_8,3);
  }
  return param_1;
}



/* @00465dd0 file=munga_l4/l4audwtr.cpp name=FUN_00465dd0 */

void __cdecl FUN_00465dd0(int *param_1,int param_2)

{
  int *piVar1;
  undefined4 *puVar2;
  char *pcVar3;
  float local_14;
  int local_10;
  int local_c;
  int *local_8;
  
  FUN_00441d17(param_1,param_2);
  puVar2 = (undefined4 *)FUN_00402298(0x10);
  if (puVar2 == (undefined4 *)0x0) {
    local_8 = (int *)0x0;
  }
  else {
    local_8 = (int *)FUN_004023f4(puVar2);
  }
  local_8[3] = local_8[3] + 1;
  pcVar3 = (char *)FUN_00403ad0(param_2,s_normal_attribute_004f3d08);
  if (pcVar3 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3d19,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_normal_attribute_004f3d3e,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f3d4f,(char *)0x0);
    FUN_0040385c(s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3d51,
                 s_d__tesla_bt_munga_l4_L4AUDWTR_CP_004f3d91,0x75);
  }
  FUN_00402b3c(pcVar3,(int *)&local_8);
  FUN_004029b0(param_1,(int)local_8);
  piVar1 = local_8 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_8,3);
  }
  pcVar3 = (char *)FUN_00403ad0(param_2,s_trigger_state_004f3db3);
  if (pcVar3 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3dc1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_trigger_state_004f3de6,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f3df4,(char *)0x0);
    FUN_0040385c(s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3df6,
                 s_d__tesla_bt_munga_l4_L4AUDWTR_CP_004f3e36,0x7a);
  }
  FUN_00407ae0(pcVar3,&local_c);
  (**(code **)(*param_1 + 0x20))(param_1,&local_c,4);
  pcVar3 = (char *)FUN_00403ad0(param_2,s_control_ID_004f3e58);
  if (pcVar3 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3e63,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_control_ID_004f3e88,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f3e93,(char *)0x0);
    FUN_0040385c(s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3e95,
                 s_d__tesla_bt_munga_l4_L4AUDWTR_CP_004f3ed5,0x7b);
  }
  FUN_00407ae0(pcVar3,&local_10);
  (**(code **)(*param_1 + 0x20))(param_1,&local_10,4);
  pcVar3 = (char *)FUN_00403ad0(param_2,s_control_value_004f3ef7);
  if (pcVar3 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3f05,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_control_value_004f3f2a,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004f3f38,(char *)0x0);
    FUN_0040385c(s_DYN_MEM_STRM_WRITE_ENTRY____name_004f3f3a,
                 s_d__tesla_bt_munga_l4_L4AUDWTR_CP_004f3f7a,0x7c);
  }
  FUN_00407b78(pcVar3,&local_14);
  (**(code **)(*param_1 + 0x20))(param_1,&local_14,4);
  return;
}



/* @00466034 file=? name=FUN_00466034 */

undefined4 __cdecl FUN_00466034(int param_1)

{
  FUN_00441d86(param_1);
  return 1;
}



/* @00466048 file=? name=FUN_00466048 */

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

{
  int *piVar1;
  float local_10 [3];
  
  if (param_3 == *(int *)(param_1 + 0x84)) {
    piVar1 = (int *)FUN_00417ab4(param_1 + 0x74);
    local_10[0] = 0.0;
    local_10[1] = 0.0;
    local_10[2] = 0.0;
    FUN_00408644(local_10,local_10,*(float **)(param_1 + 0x80));
    FUN_00464a14((int)piVar1,local_10);
    (**(code **)(*piVar1 + 0x18))
              (piVar1,*(undefined4 *)(param_1 + 0x88),*(undefined4 *)(param_1 + 0x8c));
  }
  return;
}



/* @004660c0 file=? name=FUN_004660c0 */

void __cdecl FUN_004660c0(int param_1)

{
  float local_10 [3];
  
  local_10[0] = 0.0;
  local_10[1] = 0.0;
  local_10[2] = 0.0;
  FUN_00408644(local_10,local_10,*(float **)(param_1 + 0x80));
  return;
}



/* @004660f4 file=? name=FUN_004660f4 */

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

{
  FUN_00416fdc(param_1,param_2);
  *param_1 = &PTR_FUN_004f4150;
  param_1[10] = param_3;
  return param_1;
}



/* @0046611c file=? name=FUN_0046611c */

undefined4 * __cdecl FUN_0046611c(undefined4 *param_1)

{
  FUN_00416f88(param_1);
  *param_1 = &PTR_FUN_004f4150;
  param_1[10] = 0;
  return param_1;
}



/* @0046613c file=? name=FUN_0046613c */

void __cdecl FUN_0046613c(int *param_1,byte param_2)

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



/* @00466168 file=? name=FUN_00466168 */

undefined8 __cdecl FUN_00466168(int param_1)

{
  undefined8 uVar1;
  
  uVar1 = FUN_00417034(param_1);
  return CONCAT44((int)((ulonglong)uVar1 >> 0x20),1);
}



/* @00466184 file=? name=FUN_00466184 */

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

{
  undefined4 *puVar1;
  int *piVar2;
  
  if (param_2 < 0x43) {
    if (param_2 == 0x42) {
      piVar2 = (int *)FUN_00402298(0x4c);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e6b4(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    }
    switch(param_2) {
    case 0x1c:
      piVar2 = (int *)FUN_00402298(0x98);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e7d4(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x1d:
      piVar2 = (int *)FUN_00402298(100);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e004(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x27:
      piVar2 = (int *)FUN_00402298(0x68);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043dd24(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x2b:
      puVar1 = (undefined4 *)FUN_00402298(0x4c);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_004392d8(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x2c:
      piVar2 = (int *)FUN_00402298(0x4c);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e2e4(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x2d:
      puVar1 = (undefined4 *)FUN_00402298(0x40);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_00439a54(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x2e:
      puVar1 = (undefined4 *)FUN_00402298(0x4c);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_0043968c(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x2f:
      puVar1 = (undefined4 *)FUN_00402298(0x44);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_00439da4(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x34:
      puVar1 = (undefined4 *)FUN_00402298(0x24);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_00437a20(puVar1,param_1);
        return piVar2;
      }
      return (int *)0x0;
    case 0x35:
      piVar2 = (int *)FUN_00402298(0x48);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e44c(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x36:
      puVar1 = (undefined4 *)FUN_00402298(0x24);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_00438df4(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x3a:
      puVar1 = (undefined4 *)FUN_00402298(0x48);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_0043a248(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x3b:
      piVar2 = (int *)FUN_00402298(0x4c);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e350(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x3c:
      piVar2 = (int *)FUN_00402298(0x3c);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e534(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x3d:
      piVar2 = (int *)FUN_00402298(0x4c);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e630(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x3e:
      piVar2 = (int *)FUN_00402298(0x3c);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e4b0(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    }
  }
  else if (param_2 < 0x5b) {
    if (param_2 == 0x5a) {
      puVar1 = (undefined4 *)FUN_00402298(0x3c);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_00438d60(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    }
    switch(param_2) {
    case 0x49:
      puVar1 = (undefined4 *)FUN_00402298(0x1c);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_0043db88(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x4b:
      puVar1 = (undefined4 *)FUN_00402298(0x5c);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_0043ccec(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x4c:
      puVar1 = (undefined4 *)FUN_00402298(0x38);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_00438ff4(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x4f:
      puVar1 = (undefined4 *)FUN_00402298(0x4c);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_0043a68c(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x50:
      piVar2 = (int *)FUN_00402298(0x40);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e5b8(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x51:
      piVar2 = (int *)FUN_00402298(0x40);
      if (piVar2 != (int *)0x0) {
        piVar2 = FUN_0043e3d4(piVar2,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    case 0x59:
      puVar1 = (undefined4 *)FUN_00402298(0x3c);
      if (puVar1 != (undefined4 *)0x0) {
        piVar2 = FUN_00438808(puVar1,param_1,param_1[10]);
        return piVar2;
      }
      return (int *)0x0;
    }
  }
  else {
    switch(param_2) {
    case 1000:
      puVar1 = (undefined4 *)FUN_00402298(0xb0);
      if (puVar1 == (undefined4 *)0x0) {
        return (int *)0x0;
      }
      piVar2 = FUN_00463148(puVar1,param_1,param_1[10]);
      return piVar2;
    case 0x3e9:
      puVar1 = (undefined4 *)FUN_00402298(0xd8);
      if (puVar1 == (undefined4 *)0x0) {
        return (int *)0x0;
      }
      piVar2 = FUN_00463710(puVar1,param_1,param_1[10]);
      return piVar2;
    case 0x3ea:
      puVar1 = (undefined4 *)FUN_00402298(0xdc);
      if (puVar1 == (undefined4 *)0x0) {
        return (int *)0x0;
      }
      piVar2 = FUN_00463d4c(puVar1,param_1,param_1[10]);
      return piVar2;
    case 0x3ec:
      puVar1 = (undefined4 *)FUN_00402298(0x28);
      if (puVar1 == (undefined4 *)0x0) {
        return (int *)0x0;
      }
      piVar2 = FUN_00465c34(puVar1,param_1);
      return piVar2;
    case 0x3ed:
      puVar1 = (undefined4 *)FUN_00402298(0x108);
      if (puVar1 == (undefined4 *)0x0) {
        return (int *)0x0;
      }
      piVar2 = FUN_0046487c(puVar1,param_1,param_1[10]);
      return piVar2;
    case 0x3ee:
      piVar2 = (int *)FUN_00402298(0x90);
      if (piVar2 == (int *)0x0) {
        return (int *)0x0;
      }
      piVar2 = FUN_00465d08(piVar2,param_1,param_1[10]);
      return piVar2;
    case 0x3f3:
      puVar1 = (undefined4 *)FUN_00402298(0x20);
      if (puVar1 == (undefined4 *)0x0) {
        return (int *)0x0;
      }
      piVar2 = FUN_00465964(puVar1,param_1);
      return piVar2;
    }
  }
  piVar2 = (int *)FUN_0041639c();
  return piVar2;
}



/* @00466804 file=? name=FUN_00466804 */

void __cdecl FUN_00466804(int param_1,int param_2)

{
  int iVar1;
  
  iVar1 = *(int *)(param_2 + 4);
  if (((iVar1 != 0x34) && (iVar1 != 0x3ec)) && (iVar1 != 0x3f3)) {
    FUN_004170b0(param_1,param_2);
    return;
  }
  FUN_004170cc(param_1,param_2);
  return;
}



/* @00466844 file=? name=FUN_00466844 */

void __cdecl FUN_00466844(int *param_1,int param_2,int param_3)

{
  if (param_3 < 0x43) {
    if (param_3 == 0x42) {
      FUN_0043e70c(param_1,param_2);
      return;
    }
    switch(param_3) {
    case 0x1c:
      FUN_0043e8a4(param_1,param_2);
      return;
    case 0x1d:
      FUN_0043e080(param_1,param_2);
      return;
    case 0x27:
      FUN_0043dda0(param_1,param_2);
      return;
    case 0x2b:
      FUN_00439370(param_1,param_2);
      return;
    case 0x2c:
      FUN_0043f97c(param_1,param_2);
      return;
    case 0x2d:
      FUN_00439b00(param_1,param_2);
      return;
    case 0x2e:
      FUN_00439724(param_1,param_2);
      return;
    case 0x2f:
      FUN_00439e60(param_1,param_2);
      return;
    case 0x34:
      FUN_00437a98(param_1,param_2);
      return;
    case 0x35:
      FUN_00440b8d(param_1,param_2);
      return;
    case 0x36:
      FUN_00438e70(param_1,param_2);
      return;
    case 0x3a:
      FUN_0043a324(param_1,param_2);
      return;
    case 0x3b:
      FUN_0043e3a8(param_1,param_2);
      return;
    case 0x3c:
      FUN_0043e58c(param_1,param_2);
      return;
    case 0x3d:
      FUN_0043e688(param_1,param_2);
      return;
    case 0x3e:
      FUN_0043e508(param_1,param_2);
      return;
    }
  }
  else if (param_3 < 0x5b) {
    if (param_3 == 0x5a) {
      FUN_00438a48(param_1,param_2);
      return;
    }
    switch(param_3) {
    case 0x49:
      FUN_0043dc50(param_1,param_2);
      return;
    case 0x4b:
      FUN_0043cef8(param_1,param_2);
      return;
    case 0x4c:
      FUN_004390d0(param_1,param_2);
      return;
    case 0x4f:
      FUN_0043a770(param_1,param_2);
      return;
    case 0x50:
      FUN_0043e610(param_1,param_2);
      return;
    case 0x51:
      FUN_0043e42c(param_1,param_2);
      return;
    case 0x59:
      FUN_00438a48(param_1,param_2);
      return;
    }
  }
  else {
    switch(param_3) {
    case 1000:
      FUN_0043818c(param_1,param_2);
      return;
    case 0x3e9:
      FUN_00463754(param_1,param_2);
      return;
    case 0x3ea:
      FUN_00463648(param_1,param_2);
      return;
    case 0x3ec:
      FUN_00465c54(param_1,param_2);
      return;
    case 0x3ed:
      FUN_00464918(param_1,param_2);
      return;
    case 0x3ee:
      FUN_00465dd0(param_1,param_2);
      return;
    case 0x3f3:
      FUN_004659b8(param_1,param_2);
      return;
    }
  }
  FUN_00416db0();
  return;
}



/* @00466bc4 file=? name=FUN_00466bc4 */

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

{
  if (*(int *)(*param_4 + 4) != 0) {
    if (((param_2 == 0x34) || (param_2 == 0x3ec)) || (param_2 == 0x3f3)) {
      FUN_004171f0(param_1,param_3,param_4);
      return;
    }
    FUN_004171b4(param_1,param_3,param_4);
  }
  return;
}



/* @00466c10 file=? name=FUN_00466c10 */

undefined4 * __cdecl FUN_00466c10(undefined4 *param_1)

{
  FUN_004178cc(param_1,2);
  *param_1 = &PTR_FUN_004f4144;
  return param_1;
}



/* @00466c30 file=? name=FUN_00466c30 */

void __cdecl FUN_00466c30(int *param_1,byte param_2)

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



/* @00466c5c file=? name=FUN_00466c5c */

undefined4 FUN_00466c5c(void)

{
  FUN_00415f1c();
  return 1;
}



/* @00466c70 file=? name=FUN_00466c70 */

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

{
  undefined4 *puVar1;
  int iVar2;
  bool bVar3;
  int *piVar4;
  undefined3 extraout_var;
  int iVar5;
  int local_30 [11];
  
  piVar4 = FUN_00404720(param_2,s_AudioResources_004f3ff8,(char *)0x0);
  for (puVar1 = (undefined4 *)piVar4[1]; puVar1 != (undefined4 *)0x0; puVar1 = (undefined4 *)*puVar1
      ) {
    bVar3 = FUN_00403c20((int)puVar1,s_front_audio_resource_004f4007);
    if (CONCAT31(extraout_var,bVar3) == 0) {
      FUN_004627d8(param_3 + 0x80,(LPCSTR)puVar1[1]);
    }
    else {
      FUN_004627d8(param_3 + 0xc,(LPCSTR)puVar1[1]);
    }
  }
  if (piVar4 != (int *)0x0) {
    (**(code **)*piVar4)(piVar4,3);
  }
  iVar5 = FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),s_StaticAudioStream_004f401c,0xb,-1);
  iVar2 = *(int *)(iVar5 + 4);
  *(int *)(iVar5 + 4) = *(int *)(iVar5 + 4) + 1;
  if (iVar2 == 0) {
    FUN_00406cd0(iVar5);
  }
  FUN_004660f4(local_30,iVar5,0);
  (**(code **)(local_30[0] + 0x24))(local_30);
  *(int *)(iVar5 + 4) = *(int *)(iVar5 + 4) + -1;
  FUN_0046613c(local_30,2);
  return;
}



/* @00466d44 file=? name=FUN_00466d44 */

void __cdecl FUN_00466d44(undefined4 param_1,int param_2)

{
  FUN_004627f4(param_2 + 0xc);
  FUN_004627f4(param_2 + 0x80);
  return;
}



/* @00466d68 file=? name=FUN_00466d68 */

undefined4 __cdecl FUN_00466d68(int param_1)

{
  undefined4 *puVar1;
  undefined4 uVar2;
  int local_50 [11];
  int local_24 [8];
  
  FUN_00403e84(local_24,s_audio_static_scp_004f402e,1);
  FUN_0046611c(local_50);
  (**(code **)(local_50[0] + 0x28))(local_50,local_24,param_1);
  puVar1 = (undefined4 *)FUN_00406f3c(param_1,s_StaticAudioStream_004f403f,0xb,1,0,local_50,-1);
  uVar2 = *puVar1;
  FUN_0046613c(local_50,2);
  FUN_00403ecc(local_24,2);
  return uVar2;
}



/* @00466de4 file=? name=FUN_00466de4 */

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

{
  int iVar1;
  int *piVar2;
  int iVar3;
  int local_30 [11];
  
  piVar2 = (int *)FUN_00407064(*(int *)(DAT_004efc94 + 0x68),*(int *)(param_2 + 0x1bc),3);
  if (piVar2 != (int *)0x0) {
    iVar3 = 0xc;
    if (param_3 != 0) {
      iVar3 = 0xd;
    }
    iVar3 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),*piVar2,iVar3);
    if (iVar3 != 0) {
      iVar1 = *(int *)(iVar3 + 4);
      *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + 1;
      if (iVar1 == 0) {
        FUN_00406cd0(iVar3);
      }
      iVar1 = piVar2[1];
      piVar2[1] = piVar2[1] + 1;
      if (iVar1 == 0) {
        FUN_00406cd0((int)piVar2);
      }
      FUN_004660f4(local_30,iVar3,param_2);
      (**(code **)(local_30[0] + 0x24))(local_30);
      *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + -1;
      piVar2[1] = piVar2[1] + -1;
      FUN_0046613c(local_30,2);
    }
  }
  return;
}



/* @00466e90 file=? name=FUN_00466e90 */

void __cdecl FUN_00466e90(undefined4 param_1,int param_2)

{
  int *piVar1;
  int *this;
  int local_18 [5];
  
  FUN_00421560(local_18,param_2);
  while( true ) {
    this = local_18;
    piVar1 = (int *)(**(code **)(local_18[0] + 0x28))();
    if (piVar1 == (int *)0x0) break;
    (**(code **)(*piVar1 + 0x18))(piVar1,2,0);
    (**(code **)(*piVar1 + 0x18))(piVar1,0xb,0);
  }
  FUN_00417858(this,local_18,1);
  FUN_00421584(local_18,2);
  return;
}



/* @00466ef8 file=munga_l4/l4audres.cpp name=FUN_00466ef8 */

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

{
  uint *puVar1;
  int iVar2;
  int *piVar3;
  undefined4 *puVar4;
  undefined4 uVar5;
  int iVar6;
  int local_124 [11];
  int local_f8 [8];
  uint local_d8 [2];
  char *local_d0;
  int local_c8 [11];
  int local_9c [8];
  uint local_7c [2];
  char *local_74;
  int local_6c [3];
  char *local_60;
  char *local_5c;
  uint *local_58;
  uint *local_54;
  char *local_50;
  int *local_4c;
  uint *local_48;
  uint *local_44;
  uint *local_40;
  char *local_3c;
  uint *local_38;
  int *local_34;
  uint *local_30;
  uint *local_2c;
  char *local_28;
  int *local_24;
  uint *local_20;
  uint *local_1c;
  uint *local_18;
  char *local_14;
  uint *local_10;
  int *local_c;
  char *local_8;
  
  iVar6 = 0;
  local_8 = (char *)0x0;
  local_6c[0] = -1;
  local_6c[1] = 0xffffffff;
  local_6c[2] = 0xffffffff;
  iVar2 = FUN_00404088(param_3,s_audio_004f4051,s_external_004f4057,&local_8);
  if (iVar2 != 0) {
    local_c = (int *)FUN_00406ff8(param_1,local_8,0xd,-1);
    if (local_c == (int *)0x0) {
      local_14 = local_8;
      local_18 = (uint *)FUN_00402298(0x10);
      if (local_18 == (uint *)0x0) {
        local_10 = (uint *)0x0;
      }
      else {
        local_10 = FUN_00402460(local_18,local_14);
      }
      local_10[3] = local_10[3] + 1;
      local_20 = (uint *)FUN_00402298(0x10);
      if (local_20 == (uint *)0x0) {
        local_1c = (uint *)0x0;
      }
      else {
        local_1c = FUN_00402460(local_20,s_audio__004f4060);
      }
      local_1c[3] = local_1c[3] + 1;
      FUN_00402624(local_7c,(int)local_1c,(int)local_10);
      local_28 = local_74;
      local_30 = (uint *)FUN_00402298(0x10);
      if (local_30 == (uint *)0x0) {
        local_2c = (uint *)0x0;
      }
      else {
        local_2c = FUN_00402460(local_30,local_28);
      }
      local_2c[3] = local_2c[3] + 1;
      FUN_004024d8((int *)local_7c,2);
      FUN_00402a4c((int *)&local_24,(int *)&local_10,(int *)&local_2c);
      piVar3 = local_24 + 3;
      *piVar3 = *piVar3 + -1;
      if (*piVar3 == 0) {
        FUN_004024d8(local_24,3);
      }
      puVar1 = local_2c + 3;
      *puVar1 = *puVar1 - 1;
      if (*puVar1 == 0) {
        FUN_004024d8((int *)local_2c,3);
      }
      FUN_00403e84(local_9c,(char *)local_10[2],1);
      FUN_0046611c(local_c8);
      (**(code **)(local_c8[0] + 0x28))(local_c8,local_9c,param_1);
      local_c = (int *)FUN_00406f3c(param_1,local_8,0xd,1,0,local_c8,-1);
      FUN_0046613c(local_c8,2);
      FUN_00403ecc(local_9c,2);
      puVar1 = local_1c + 3;
      *puVar1 = *puVar1 - 1;
      if (*puVar1 == 0) {
        FUN_004024d8((int *)local_1c,3);
      }
      puVar1 = local_10 + 3;
      *puVar1 = *puVar1 - 1;
      if (*puVar1 == 0) {
        FUN_004024d8((int *)local_10,3);
      }
    }
    local_6c[0] = *local_c;
    iVar6 = 1;
  }
  iVar2 = FUN_00404088(param_3,s_audio_004f4067,s_internal_004f406d,&local_8);
  if (iVar2 != 0) {
    local_34 = (int *)FUN_00406ff8(param_1,local_8,0xc,-1);
    if (local_34 == (int *)0x0) {
      local_3c = local_8;
      local_40 = (uint *)FUN_00402298(0x10);
      if (local_40 == (uint *)0x0) {
        local_38 = (uint *)0x0;
      }
      else {
        local_38 = FUN_00402460(local_40,local_3c);
      }
      local_38[3] = local_38[3] + 1;
      local_48 = (uint *)FUN_00402298(0x10);
      if (local_48 == (uint *)0x0) {
        local_44 = (uint *)0x0;
      }
      else {
        local_44 = FUN_00402460(local_48,s_audio__004f4076);
      }
      local_44[3] = local_44[3] + 1;
      FUN_00402624(local_d8,(int)local_44,(int)local_38);
      local_50 = local_d0;
      local_58 = (uint *)FUN_00402298(0x10);
      if (local_58 == (uint *)0x0) {
        local_54 = (uint *)0x0;
      }
      else {
        local_54 = FUN_00402460(local_58,local_50);
      }
      local_54[3] = local_54[3] + 1;
      FUN_004024d8((int *)local_d8,2);
      FUN_00402a4c((int *)&local_4c,(int *)&local_38,(int *)&local_54);
      piVar3 = local_4c + 3;
      *piVar3 = *piVar3 + -1;
      if (*piVar3 == 0) {
        FUN_004024d8(local_4c,3);
      }
      puVar1 = local_54 + 3;
      *puVar1 = *puVar1 - 1;
      if (*puVar1 == 0) {
        FUN_004024d8((int *)local_54,3);
      }
      FUN_00403e84(local_f8,(char *)local_38[2],1);
      FUN_0046611c(local_124);
      (**(code **)(local_124[0] + 0x28))(local_124,local_f8,param_1);
      local_34 = (int *)FUN_00406f3c(param_1,local_8,0xc,1,0,local_124,-1);
      FUN_0046613c(local_124,2);
      FUN_00403ecc(local_f8,2);
      puVar1 = local_44 + 3;
      *puVar1 = *puVar1 - 1;
      if (*puVar1 == 0) {
        FUN_004024d8((int *)local_44,3);
      }
      puVar1 = local_38 + 3;
      *puVar1 = *puVar1 - 1;
      if (*puVar1 == 0) {
        FUN_004024d8((int *)local_38,3);
      }
    }
    local_6c[iVar6] = *local_34;
    iVar6 = iVar6 + 1;
  }
  local_5c = (char *)0x0;
  iVar2 = FUN_00404088(param_3,s_audio_004f407d,s_model_004f4083,&local_5c);
  if (iVar2 != 0) {
    piVar3 = (int *)FUN_00406ff8(param_1,local_5c,1,-1);
    if (piVar3 == (int *)0x0) {
      local_60 = local_5c;
      FUN_004dbb24(&DAT_00524e20,s_audio_entity_model____004f4089,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_60,(char *)0x0);
      FUN_0040385c(s_L4AudioResourceManager__CreateMo_004f40a0,
                   s_d__tesla_bt_munga_l4_L4AUDRES_CP_004f40e9,0x3e0);
    }
    local_6c[iVar6] = *piVar3;
    iVar6 = iVar6 + 1;
  }
  if (iVar6 == 0) {
    uVar5 = 0xffffffff;
  }
  else {
    puVar4 = (undefined4 *)FUN_00406ec4(param_1,param_2,3,1,0,local_6c,iVar6,-1);
    uVar5 = *puVar4;
  }
  return uVar5;
}



/* @0046739c file=? name=FUN_0046739c */

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

{
  FUN_00441f6c(param_1,param_2);
  *param_1 = &PTR_FUN_004f49b0;
  FUN_00462b38(param_1 + 0x1b);
  FUN_00466c10(param_1 + 0x58);
  FUN_004683b9(param_1 + 0x5c,0,0);
  FUN_00468587(param_1 + 0x62,0);
  FUN_004685d2(param_1 + 0x66,0,0);
  param_1[0x1a] = param_3;
  param_1[0x5b] = 0xffffffff;
  return param_1;
}



/* @00467418 file=? name=FUN_00467418 */

void __cdecl FUN_00467418(int *param_1,byte param_2)

{
  int *piVar1;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f49b0;
    piVar1 = param_1 + 0x1b;
    FUN_00466d44(param_1 + 0x58,(int)piVar1);
    FUN_00462c28((int)piVar1);
    FUN_004685f5(param_1 + 0x66,2);
    FUN_004685a6(param_1 + 0x62,2);
    FUN_004683dc(param_1 + 0x5c,2);
    FUN_00466c30(param_1 + 0x58,2);
    FUN_00462b6c(piVar1,2);
    FUN_00441fb4(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004674b0 file=? name=FUN_004674b0 */

undefined4 __cdecl FUN_004674b0(int param_1)

{
  FUN_00442010(param_1);
  return 1;
}



/* @004674c4 file=? name=FUN_004674c4 */

void FUN_004674c4(int param_1)

{
  int *piVar1;
  int iVar2;
  undefined4 *puVar3;
  int iVar4;
  int aiStack_74 [8];
  float fStack_54;
  float fStack_50;
  float fStack_4c;
  float fStack_48;
  float fStack_44;
  float fStack_40;
  float fStack_3c;
  float fStack_38;
  float fStack_34;
  float fStack_30;
  float fStack_2c;
  float fStack_28;
  float fStack_24;
  float fStack_20;
  float fStack_1c;
  float fStack_18;
  float fStack_14;
  int *piStack_10;
  int *piStack_c;
  int *piStack_8;
  
  FUN_00441ffc((int *)param_1);
  iVar2 = *(int *)(param_1 + 0x4c);
  puVar3 = (undefined4 *)FUN_00402298(0x10);
  if (puVar3 == (undefined4 *)0x0) {
    piStack_8 = (int *)0x0;
  }
  else {
    piStack_8 = (int *)FUN_004023f4(puVar3);
  }
  piStack_8[3] = piStack_8[3] + 1;
  if (*(int *)(param_1 + 0x68) == 0) {
    FUN_00402a98((int *)&piStack_10,(int *)&piStack_8,s_audio_audio_ini_004f419e);
    piVar1 = piStack_10 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piStack_10,3);
    }
  }
  else {
    FUN_00402a98((int *)&piStack_c,(int *)&piStack_8,s_audio_audiomr_ini_004f418c);
    piVar1 = piStack_c + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piStack_c,3);
    }
  }
  FUN_00403e84(aiStack_74,(char *)piStack_8[2],1);
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f41ae,s_clipping_radius_004f41bc,
                       &fStack_14);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___cl_004f41cc,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4206,0xa1);
  }
  FUN_00436c44(iVar2,fStack_14);
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f4228,s_distance_between_ears_004f4236,
                       &fStack_18);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___di_004f424c,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f428c,0xb3);
  }
  fStack_1c = fStack_18;
  *(float *)(iVar2 + 0x18) = fStack_18;
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f42ae,s_amplitude_rolloff_004f42bc,
                       &fStack_20);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___am_004f42ce,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f430a,200);
  }
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f432c,
                       s_amplitude_rolloff_distance_scale_004f433a,&fStack_28);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___am_004f435b,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f43a6,0xd1);
  }
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f43c8,s_amplitude_rolloff_knee_004f43d6,
                       &fStack_24);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___am_004f43ed,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f442e,0xda);
  }
  FUN_00436cc0(iVar2,fStack_20,fStack_24,fStack_28);
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f4450,s_high_frequency_rolloff_004f445e,
                       &fStack_2c);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___hi_004f4475,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f44b6,0xf4);
  }
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f44d8,
                       s_high_frequency_rolloff_knee_004f44e6,&fStack_30);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___hi_004f4502,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4548,0xfd);
  }
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f456a,
                       s_high_frequency_rolloff_distance__004f4578,&fStack_34);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___hi_004f459e,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f45ee,0x106);
  }
  FUN_00436cdc(iVar2,fStack_2c,fStack_30,fStack_34);
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f4610,s_doppler_range_004f461e,&fStack_38)
  ;
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___do_004f462c,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4664,0x11f);
  }
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f4686,s_speed_of_sound_004f4694,&fStack_3c
                      );
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___sp_004f46a3,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f46dc,0x128);
  }
  FUN_00436cac(iVar2,fStack_38,fStack_3c);
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f46fe,s_compression_exponent_004f470c,
                       &fStack_40);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___co_004f4721,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4760,0x140);
  }
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f4782,s_compression_scale_004f4790,
                       &fStack_44);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___co_004f47a2,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f47de,0x149);
  }
  FUN_00436cf8(iVar2,fStack_40,fStack_44);
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f4800,s_itd_difference_004f480e,&fStack_48
                      );
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___it_004f481d,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4856,0x160);
  }
  fStack_4c = fStack_48;
  *(float *)(iVar2 + 0x48) = fStack_48;
  iVar4 = FUN_00404118((int)aiStack_74,s_AudioRenderer_004f4878,s_global_reverb_scale_004f4886,
                       &fStack_50);
  if (iVar4 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___gl_004f489a,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f48d8,0x174);
  }
  fStack_54 = fStack_50;
  *(float *)(iVar2 + 0x4c) = fStack_50;
  FUN_00462bcc(param_1 + 0x6c);
  FUN_00466c70(param_1 + 0x160,(int)aiStack_74,param_1 + 0x6c);
  FUN_00403ecc(aiStack_74,2);
  piVar1 = piStack_8 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(piStack_8,3);
  }
  return;
}



/* @004674ca file=munga_l4/l4audrnd.cpp name=FUN_004674ca */

void FUN_004674ca(void)

{
  int *piVar1;
  int *piVar2;
  int iVar3;
  int *piVar4;
  undefined4 *puVar5;
  undefined4 uVar6;
  int iVar7;
  int unaff_EBP;
  
  piVar2 = *(int **)(unaff_EBP + 8);
  FUN_00441ffc(piVar2);
  iVar3 = piVar2[0x13];
  puVar5 = (undefined4 *)FUN_00402298(0x10);
  if (puVar5 == (undefined4 *)0x0) {
    uVar6 = 0;
  }
  else {
    uVar6 = FUN_004023f4(puVar5);
  }
  *(undefined4 *)(unaff_EBP + -4) = uVar6;
  piVar1 = (int *)(*(int *)(unaff_EBP + -4) + 0xc);
  *piVar1 = *piVar1 + 1;
  if (piVar2[0x1a] == 0) {
    FUN_00402a98((int *)(unaff_EBP + -0xc),(int *)(unaff_EBP + -4),s_audio_audio_ini_004f419e);
    piVar4 = *(int **)(unaff_EBP + -0xc);
    piVar1 = piVar4 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar4,3);
    }
  }
  else {
    FUN_00402a98((int *)(unaff_EBP + -8),(int *)(unaff_EBP + -4),s_audio_audiomr_ini_004f418c);
    piVar4 = *(int **)(unaff_EBP + -8);
    piVar1 = piVar4 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar4,3);
    }
  }
  FUN_00403e84((int *)(unaff_EBP + -0x70),*(char **)(*(int *)(unaff_EBP + -4) + 8),1);
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f41ae,s_clipping_radius_004f41bc,
                       (float *)(unaff_EBP + -0x10));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___cl_004f41cc,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4206,0xa1);
  }
  FUN_00436c44(iVar3,*(undefined4 *)(unaff_EBP + -0x10));
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f4228,s_distance_between_ears_004f4236,
                       (float *)(unaff_EBP + -0x14));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___di_004f424c,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f428c,0xb3);
  }
  *(undefined4 *)(unaff_EBP + -0x18) = *(undefined4 *)(unaff_EBP + -0x14);
  *(undefined4 *)(iVar3 + 0x18) = *(undefined4 *)(unaff_EBP + -0x18);
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f42ae,s_amplitude_rolloff_004f42bc,
                       (float *)(unaff_EBP + -0x1c));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___am_004f42ce,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f430a,200);
  }
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f432c,
                       s_amplitude_rolloff_distance_scale_004f433a,(float *)(unaff_EBP + -0x24));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___am_004f435b,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f43a6,0xd1);
  }
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f43c8,s_amplitude_rolloff_knee_004f43d6,
                       (float *)(unaff_EBP + -0x20));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___am_004f43ed,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f442e,0xda);
  }
  FUN_00436cc0(iVar3,*(undefined4 *)(unaff_EBP + -0x1c),*(undefined4 *)(unaff_EBP + -0x20),
               *(undefined4 *)(unaff_EBP + -0x24));
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f4450,s_high_frequency_rolloff_004f445e,
                       (float *)(unaff_EBP + -0x28));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___hi_004f4475,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f44b6,0xf4);
  }
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f44d8,
                       s_high_frequency_rolloff_knee_004f44e6,(float *)(unaff_EBP + -0x2c));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___hi_004f4502,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4548,0xfd);
  }
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f456a,
                       s_high_frequency_rolloff_distance__004f4578,(float *)(unaff_EBP + -0x30));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___hi_004f459e,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f45ee,0x106);
  }
  FUN_00436cdc(iVar3,*(undefined4 *)(unaff_EBP + -0x28),*(undefined4 *)(unaff_EBP + -0x2c),
               *(undefined4 *)(unaff_EBP + -0x30));
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f4610,s_doppler_range_004f461e,
                       (float *)(unaff_EBP + -0x34));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___do_004f462c,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4664,0x11f);
  }
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f4686,s_speed_of_sound_004f4694,
                       (float *)(unaff_EBP + -0x38));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___sp_004f46a3,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f46dc,0x128);
  }
  FUN_00436cac(iVar3,*(undefined4 *)(unaff_EBP + -0x34),*(undefined4 *)(unaff_EBP + -0x38));
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f46fe,s_compression_exponent_004f470c,
                       (float *)(unaff_EBP + -0x3c));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___co_004f4721,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4760,0x140);
  }
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f4782,s_compression_scale_004f4790,
                       (float *)(unaff_EBP + -0x40));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___co_004f47a2,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f47de,0x149);
  }
  FUN_00436cf8(iVar3,*(undefined4 *)(unaff_EBP + -0x3c),*(undefined4 *)(unaff_EBP + -0x40));
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f4800,s_itd_difference_004f480e,
                       (float *)(unaff_EBP + -0x44));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___it_004f481d,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f4856,0x160);
  }
  *(undefined4 *)(unaff_EBP + -0x48) = *(undefined4 *)(unaff_EBP + -0x44);
  *(undefined4 *)(iVar3 + 0x48) = *(undefined4 *)(unaff_EBP + -0x48);
  iVar7 = FUN_00404118(unaff_EBP + -0x70,s_AudioRenderer_004f4878,s_global_reverb_scale_004f4886,
                       (float *)(unaff_EBP + -0x4c));
  if (iVar7 == 0) {
    FUN_0040385c(s_L4AudioRenderer__Initialize___gl_004f489a,
                 s_d__tesla_bt_munga_l4_L4AUDRND_CP_004f48d8,0x174);
  }
  *(undefined4 *)(unaff_EBP + -0x50) = *(undefined4 *)(unaff_EBP + -0x4c);
  *(undefined4 *)(iVar3 + 0x4c) = *(undefined4 *)(unaff_EBP + -0x50);
  FUN_00462bcc((int)(piVar2 + 0x1b));
  FUN_00466c70(piVar2 + 0x58,unaff_EBP + -0x70,(int)(piVar2 + 0x1b));
  FUN_00403ecc((int *)(unaff_EBP + -0x70),2);
  piVar1 = *(int **)(unaff_EBP + -4);
  piVar2 = piVar1 + 3;
  *piVar2 = *piVar2 + -1;
  if (*piVar2 == 0) {
    FUN_004024d8(piVar1,3);
  }
  return;
}



/* @00467908 file=? name=FUN_00467908 */

void __cdecl FUN_00467908(int param_1,int *param_2)

{
  undefined4 uVar1;
  int iVar2;
  
  uVar1 = FUN_00417ab4(param_1 + 0x40);
  iVar2 = (**(code **)(*param_2 + 0x28))(param_2,uVar1);
  FUN_00466de4(param_1 + 0x160,(int)param_2,iVar2);
  return;
}



/* @00467940 file=? name=FUN_00467940 */

void __cdecl FUN_00467940(int param_1,int param_2)

{
  FUN_00466e90(param_1 + 0x160,param_2);
  return;
}



/* @0046795c file=? name=FUN_0046795c */

void FUN_0046795c(void)

{
  return;
}



/* @00467964 file=? name=FUN_00467964 */

void FUN_00467964(void)

{
  return;
}



/* @0046796c file=? name=FUN_0046796c */

void FUN_0046796c(void)

{
  return;
}



/* @00467974 file=? name=FUN_00467974 */

void FUN_00467974(void)

{
  return;
}



/* @0046797c file=? name=FUN_0046797c */

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

void __cdecl FUN_0046797c(int param_1,int *param_2)

{
  int *piVar1;
  int iVar2;
  float10 fVar3;
  int local_38 [8];
  int local_18;
  float local_14;
  float local_10;
  float local_c;
  int local_8;
  
  FUN_00463580(local_38);
  iVar2 = FUN_00468190(param_1,param_2,local_38);
  if (iVar2 == 0) {
    if (*(int *)(*(int *)(param_2[10] + 0xc) + 0x10) == 1) {
      FUN_0043ba04((int)param_2,1);
      (**(code **)(*(int *)(param_1 + 0x188) + 4))(param_1 + 0x188,param_2);
    }
  }
  else {
    local_8 = *(int *)(param_1 + 0x4c);
    piVar1 = (int *)param_2[9];
    if (piVar1[0x18] <= *(int *)(local_8 + 4)) {
      piVar1[0x18] = *(int *)(local_8 + 4) + piVar1[0x17];
      (**(code **)(*piVar1 + 0x1c))(piVar1,local_8);
    }
    FUN_004636cc((int)param_2,local_38);
    (**(code **)(*param_2 + 0x44))(param_2);
    FUN_0043ba04((int)param_2,2);
    fVar3 = (float10)(**(code **)(*param_2 + 0x1c))(param_2);
    local_c = (float)fVar3;
    local_14 = (_DAT_00467a98 - (float)param_2[0x1b]) - local_c;
    local_10 = local_14;
    (**(code **)(*(int *)(param_1 + 0x170) + 8))(param_1 + 0x170,param_2,&local_14);
    local_18 = param_2[0x1c];
    if (local_18 != 0) {
      (**(code **)(*(int *)(param_1 + 0x198) + 8))(param_1 + 0x198,param_2,&local_18);
    }
  }
  return;
}



/* @00467a9c file=? name=FUN_00467a9c */

void __cdecl FUN_00467a9c(int param_1,int *param_2)

{
  int local_14 [4];
  
  if ((param_2[0xb] == 1) || (param_2[0xb] == 3)) {
    FUN_0043ba04((int)param_2,0);
    FUN_00415f30(local_14,(int)param_2,0xffffffff);
    FUN_004161fc((int)local_14,param_1 + 0x188);
    FUN_00415f90(local_14,2);
  }
  else {
    FUN_00468098(param_1,param_2);
  }
  return;
}



/* @00467b04 file=? name=FUN_00467b04 */

void __cdecl FUN_00467b04(int param_1)

{
  FUN_00442054(param_1);
  FUN_00467b34(param_1);
  FUN_00467c0c(param_1);
  FUN_00467e9c(param_1);
  return;
}



/* @00467b34 file=? name=FUN_00467b34 */

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

void __cdecl FUN_00467b34(int param_1)

{
  float fVar1;
  int iVar2;
  int *piVar3;
  int iVar4;
  float10 fVar5;
  int local_30 [5];
  float local_1c;
  float local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  local_8 = 1.0;
  local_c = 0.0;
  iVar4 = 3;
  FUN_004658db(local_30,param_1 + 0x198);
  local_10 = *(float *)(*(int *)(param_1 + 0x4c) + 0x44);
  local_14 = *(float *)(*(int *)(param_1 + 0x4c) + 0x40);
  iVar2 = (**(code **)(local_30[0] + 0x30))();
  fVar1 = local_c;
  if (iVar2 != 0) {
    iVar4 = *(int *)(iVar2 + 0x70);
  }
  while (local_c = fVar1, piVar3 = (int *)(**(code **)(local_30[0] + 0x28))(), piVar3 != (int *)0x0)
  {
    iVar2 = piVar3[0x1c];
    if (iVar4 != iVar2) {
      fVar5 = FUN_004dce94((double)(local_10 * local_c),SUB84((double)local_14,0),
                           (uint)((ulonglong)(double)local_14 >> 0x20));
      local_8 = (float)((float10)_DAT_00467c08 - fVar5);
      iVar4 = iVar2;
    }
    local_18 = local_8;
    piVar3[0x1d] = (int)local_8;
    fVar5 = FUN_0043ba64(piVar3);
    local_1c = (float)fVar5;
    fVar1 = local_1c;
    if (local_1c < local_c) {
      fVar1 = local_c;
    }
  }
  FUN_00465938(local_30,2);
  return;
}



/* @00467c0c file=? name=FUN_00467c0c */

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

void FUN_00467c0c(int param_1)

{
  bool bVar1;
  undefined3 extraout_var;
  int *piVar2;
  float10 fVar3;
  int aiStack_70 [3];
  int aiStack_64 [4];
  int iStack_54;
  int aiStack_50 [4];
  float fStack_40;
  float fStack_3c;
  float fStack_38;
  float fStack_34;
  float fStack_30;
  float fStack_2c;
  float fStack_28;
  int iStack_24;
  float fStack_20;
  float fStack_1c;
  int iStack_18;
  int iStack_14;
  int iStack_10;
  int iStack_c;
  int iStack_8;
  
  FUN_00468587(aiStack_50,0);
  FUN_004657c9(aiStack_64,param_1 + 0x170);
LAB_00467deb:
  do {
    while( true ) {
      while( true ) {
        while( true ) {
          piVar2 = (int *)(**(code **)(aiStack_64[0] + 0x30))();
          if (piVar2 == (int *)0x0) {
            FUN_00465852(aiStack_70,(int)aiStack_50);
            while( true ) {
              piVar2 = (int *)(**(code **)(aiStack_70[0] + 0x28))();
              if (piVar2 == (int *)0x0) break;
              fVar3 = (float10)(**(code **)(*piVar2 + 0x1c))();
              fStack_38 = (float)fVar3;
              fStack_40 = (_DAT_00467e94 - (float)piVar2[0x1b]) - fStack_38;
              fStack_3c = fStack_40;
              (**(code **)(*(int *)(param_1 + 0x170) + 8))(param_1 + 0x170,piVar2);
            }
            FUN_004658af(aiStack_70,2);
            FUN_00465826(aiStack_64,2);
            FUN_004685a6(aiStack_50,2);
            return;
          }
          if (piVar2[0x27] <= *(int *)(*(int *)(param_1 + 0x4c) + 4)) break;
          (**(code **)(aiStack_64[0] + 0xc))();
        }
        bVar1 = FUN_00438348(piVar2[9],*(int *)(param_1 + 0x4c));
        if (CONCAT31(extraout_var,bVar1) == 0) break;
        if (*(int *)(*(int *)(piVar2[10] + 0xc) + 0x10) == 0) {
          FUN_00468098(param_1,piVar2);
        }
        else {
          FUN_00468108(param_1,piVar2);
        }
      }
      if (piVar2[0x14] == 0) {
        bVar1 = false;
      }
      else {
        FUN_004373e8(&iStack_8);
        bVar1 = piVar2[0x17] < iStack_8;
      }
      if (!bVar1) break;
      FUN_00468098(param_1,piVar2);
    }
    if (*(int *)(*(int *)(piVar2[10] + 0xc) + 0x10) == 1) {
      iStack_c = FUN_00437404();
      FUN_004373e8(&iStack_10);
      iStack_18 = iStack_10 - piVar2[0x16];
      iStack_14 = iStack_18;
      if (iStack_c < iStack_18) {
        (**(code **)(*piVar2 + 0x4c))();
        FUN_0043ba04((int)piVar2,3);
        (**(code **)(*piVar2 + 0x50))();
        FUN_0043ba04((int)piVar2,2);
        (**(code **)(aiStack_64[0] + 0xc))();
        goto LAB_00467deb;
      }
    }
    (**(code **)(*piVar2 + 0x14))();
    fStack_1c = *(float *)(iStack_54 + 0x1c);
    fVar3 = (float10)(**(code **)(*piVar2 + 0x1c))();
    fStack_20 = (float)fVar3;
    iStack_24 = piVar2[0x1b];
    fStack_34 = (_DAT_00467e94 - (float)iStack_24) - fStack_20;
    fStack_30 = fStack_1c;
    fStack_2c = fStack_34;
    fStack_28 = fStack_34;
    fVar3 = FUN_004dcd00((double)(fStack_34 - fStack_1c));
    if (fVar3 <= (float10)_DAT_00467e98) {
      (**(code **)(aiStack_64[0] + 0xc))();
    }
    else {
      (**(code **)(aiStack_64[0] + 0x48))();
      (**(code **)(aiStack_50[0] + 4))(aiStack_50);
    }
  } while( true );
}



/* @00467c12 file=? name=FUN_00467c12 */

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

void FUN_00467c12(void)

{
  int iVar1;
  bool bVar2;
  undefined3 extraout_var;
  undefined4 uVar3;
  int *piVar4;
  int unaff_EBP;
  float10 fVar5;
  
  iVar1 = *(int *)(unaff_EBP + 8);
  FUN_00468587((undefined4 *)(unaff_EBP + -0x4c),0);
  FUN_004657c9((undefined4 *)(unaff_EBP + -0x60),iVar1 + 0x170);
LAB_00467deb:
  do {
    while( true ) {
      while( true ) {
        while( true ) {
          piVar4 = (int *)(**(code **)(*(int *)(unaff_EBP + -0x60) + 0x30))();
          if (piVar4 == (int *)0x0) {
            FUN_00465852((undefined4 *)(unaff_EBP + -0x6c),unaff_EBP + -0x4c);
            while( true ) {
              piVar4 = (int *)(**(code **)(*(int *)(unaff_EBP + -0x6c) + 0x28))();
              if (piVar4 == (int *)0x0) break;
              fVar5 = (float10)(**(code **)(*piVar4 + 0x1c))();
              *(float *)(unaff_EBP + -0x34) = (float)fVar5;
              *(int *)(unaff_EBP + -0x70) = piVar4[0x1b];
              *(float *)(unaff_EBP + -0x38) =
                   (_DAT_00467e94 - (float)*(int *)(unaff_EBP + -0x70)) -
                   *(float *)(unaff_EBP + -0x34);
              *(undefined4 *)(unaff_EBP + -0x3c) = *(undefined4 *)(unaff_EBP + -0x38);
              (**(code **)(*(int *)(iVar1 + 0x170) + 8))(iVar1 + 0x170,piVar4);
            }
            FUN_004658af((int *)(unaff_EBP + -0x6c),2);
            FUN_00465826((int *)(unaff_EBP + -0x60),2);
            FUN_004685a6((int *)(unaff_EBP + -0x4c),2);
            return;
          }
          if (piVar4[0x27] <= *(int *)(*(int *)(iVar1 + 0x4c) + 4)) break;
          (**(code **)(*(int *)(unaff_EBP + -0x60) + 0xc))();
        }
        bVar2 = FUN_00438348(piVar4[9],*(int *)(iVar1 + 0x4c));
        if (CONCAT31(extraout_var,bVar2) == 0) break;
        if (*(int *)(*(int *)(piVar4[10] + 0xc) + 0x10) == 0) {
          FUN_00468098(iVar1,piVar4);
        }
        else {
          FUN_00468108(iVar1,piVar4);
        }
      }
      if (piVar4[0x14] == 0) {
        bVar2 = false;
      }
      else {
        FUN_004373e8((undefined4 *)(unaff_EBP + -4));
        bVar2 = piVar4[0x17] < *(int *)(unaff_EBP + -4);
      }
      if (!bVar2) break;
      FUN_00468098(iVar1,piVar4);
    }
    if (*(int *)(*(int *)(piVar4[10] + 0xc) + 0x10) == 1) {
      uVar3 = FUN_00437404();
      *(undefined4 *)(unaff_EBP + -8) = uVar3;
      FUN_004373e8((undefined4 *)(unaff_EBP + -0xc));
      *(int *)(unaff_EBP + -0x10) = *(int *)(unaff_EBP + -0xc) - piVar4[0x16];
      *(undefined4 *)(unaff_EBP + -0x14) = *(undefined4 *)(unaff_EBP + -0x10);
      if (*(int *)(unaff_EBP + -8) < *(int *)(unaff_EBP + -0x14)) {
        (**(code **)(*piVar4 + 0x4c))();
        FUN_0043ba04((int)piVar4,3);
        (**(code **)(*piVar4 + 0x50))();
        FUN_0043ba04((int)piVar4,2);
        (**(code **)(*(int *)(unaff_EBP + -0x60) + 0xc))();
        goto LAB_00467deb;
      }
    }
    (**(code **)(*piVar4 + 0x14))();
    *(undefined4 *)(unaff_EBP + -0x18) = *(undefined4 *)(*(int *)(unaff_EBP + -0x50) + 0x1c);
    fVar5 = (float10)(**(code **)(*piVar4 + 0x1c))();
    *(float *)(unaff_EBP + -0x1c) = (float)fVar5;
    *(int *)(unaff_EBP + -0x20) = piVar4[0x1b];
    *(float *)(unaff_EBP + -0x24) =
         (_DAT_00467e94 - (float)*(int *)(unaff_EBP + -0x20)) - *(float *)(unaff_EBP + -0x1c);
    *(undefined4 *)(unaff_EBP + -0x28) = *(undefined4 *)(unaff_EBP + -0x24);
    *(undefined4 *)(unaff_EBP + -0x2c) = *(undefined4 *)(unaff_EBP + -0x18);
    *(undefined4 *)(unaff_EBP + -0x30) = *(undefined4 *)(unaff_EBP + -0x28);
    fVar5 = FUN_004dcd00((double)(*(float *)(unaff_EBP + -0x30) - *(float *)(unaff_EBP + -0x2c)));
    if (fVar5 <= (float10)_DAT_00467e98) {
      (**(code **)(*(int *)(unaff_EBP + -0x60) + 0xc))();
    }
    else {
      (**(code **)(*(int *)(unaff_EBP + -0x60) + 0x48))();
      (**(code **)(*(int *)(unaff_EBP + -0x4c) + 4))(unaff_EBP + -0x4c);
    }
  } while( true );
}



/* @00467e9c file=? name=FUN_00467e9c */

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

void __cdecl FUN_00467e9c(int param_1)

{
  int *piVar1;
  bool bVar2;
  undefined3 extraout_var;
  int *piVar3;
  int iVar4;
  float10 fVar5;
  int local_84 [4];
  int local_74 [8];
  int local_54 [4];
  int local_44;
  int local_40 [3];
  int local_34 [6];
  int local_1c;
  int local_18;
  undefined4 local_14;
  float local_10;
  float local_c;
  float local_8;
  
  FUN_004683b9(local_34,0,0);
  FUN_00465852(local_40,param_1 + 0x188);
  while( true ) {
    piVar3 = (int *)(**(code **)(local_40[0] + 0x28))(local_40);
    if (piVar3 == (int *)0x0) break;
    if (piVar3[0x28] <= *(int *)(*(int *)(param_1 + 0x4c) + 4)) {
      bVar2 = FUN_00438348(piVar3[9],*(int *)(param_1 + 0x4c));
      if (CONCAT31(extraout_var,bVar2) == 0) {
        fVar5 = (float10)(**(code **)(*piVar3 + 0x1c))(piVar3);
        local_8 = (float)fVar5;
        local_10 = (_DAT_00468094 - (float)piVar3[0x1b]) - local_8;
        local_c = local_10;
        (**(code **)(local_34[0] + 8))(local_34,piVar3,&local_10);
      }
    }
  }
  FUN_004657c9(local_54,(int)local_34);
  while( true ) {
    piVar3 = (int *)(**(code **)(local_54[0] + 0x30))(local_54);
    if (piVar3 == (int *)0x0) break;
    FUN_00463580(local_74);
    iVar4 = FUN_00468190(param_1,piVar3,local_74);
    if (iVar4 == 0) break;
    FUN_00415f30(local_84,(int)piVar3,0xffffffff);
    FUN_004161fc((int)local_84,param_1 + 0x188);
    local_14 = *(undefined4 *)(local_44 + 0x1c);
    (**(code **)(local_54[0] + 0x48))(local_54);
    local_18 = *(int *)(param_1 + 0x4c);
    piVar1 = (int *)piVar3[9];
    if (piVar1[0x18] <= *(int *)(local_18 + 4)) {
      piVar1[0x18] = *(int *)(local_18 + 4) + piVar1[0x17];
      (**(code **)(*piVar1 + 0x1c))(piVar1,local_18);
    }
    FUN_004636cc((int)piVar3,local_74);
    (**(code **)(*piVar3 + 0x50))(piVar3);
    FUN_0043ba04((int)piVar3,2);
    (**(code **)(*(int *)(param_1 + 0x170) + 8))(param_1 + 0x170,piVar3,&local_14);
    if (piVar3[0x1c] != 0) {
      local_1c = piVar3[0x1c];
      (**(code **)(*(int *)(param_1 + 0x198) + 8))(param_1 + 0x198,piVar3,&local_1c);
    }
    FUN_00415f90(local_84,2);
  }
  FUN_00465826(local_54,2);
  FUN_004658af(local_40,2);
  FUN_004683dc(local_34,2);
  return;
}



/* @00468098 file=? name=FUN_00468098 */

void __cdecl FUN_00468098(int param_1,int *param_2)

{
  int local_14 [4];
  
  (**(code **)(*param_2 + 0x48))(param_2);
  FUN_0043ba04((int)param_2,0);
  FUN_004636fc((int)param_2);
  FUN_00415f30(local_14,(int)param_2,0xffffffff);
  FUN_004161fc((int)local_14,param_1 + 0x170);
  FUN_004161fc((int)local_14,param_1 + 0x198);
  FUN_00415f90(local_14,2);
  return;
}



/* @00468108 file=? name=FUN_00468108 */

void __cdecl FUN_00468108(int param_1,int *param_2)

{
  int local_14 [4];
  
  (**(code **)(*param_2 + 0x4c))(param_2);
  FUN_0043ba04((int)param_2,3);
  FUN_004636fc((int)param_2);
  FUN_00415f30(local_14,(int)param_2,0xffffffff);
  FUN_004161fc((int)local_14,param_1 + 0x170);
  FUN_004161fc((int)local_14,param_1 + 0x198);
  (**(code **)(*(int *)(param_1 + 0x188) + 4))(param_1 + 0x188,param_2);
  FUN_00415f90(local_14,2);
  return;
}



/* @00468190 file=? name=FUN_00468190 */

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

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

{
  bool bVar1;
  undefined3 extraout_var;
  int iVar2;
  int *piVar3;
  undefined3 extraout_var_00;
  undefined3 extraout_var_01;
  int *piVar4;
  float10 fVar5;
  int local_2c [4];
  int local_1c;
  float local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  bVar1 = FUN_00438348(param_2[9],*(int *)(param_1 + 0x4c));
  if (CONCAT31(extraout_var,bVar1) == 0) {
    piVar3 = (int *)FUN_004636ec((int)param_2);
    piVar4 = param_3;
    for (iVar2 = 8; iVar2 != 0; iVar2 = iVar2 + -1) {
      *piVar4 = *piVar3;
      piVar3 = piVar3 + 1;
      piVar4 = piVar4 + 1;
    }
    bVar1 = FUN_004682f4(param_1,*(int *)(*(int *)(param_2[10] + 0xc) + 0xc),param_3);
    iVar2 = CONCAT31(extraout_var_00,bVar1);
    if (iVar2 == 0) {
      FUN_004657c9(local_2c,param_1 + 0x170);
      local_8 = 0.0;
      (**(code **)(local_2c[0] + 8))(local_2c);
      piVar3 = (int *)(**(code **)(local_2c[0] + 0x30))(local_2c);
      fVar5 = (float10)(**(code **)(*param_2 + 0x1c))(param_2);
      local_c = (float)fVar5;
      local_14 = (_DAT_004682f0 - (float)param_2[0x1b]) - local_c;
      local_10 = local_14;
      local_8 = local_14;
      while (((iVar2 == 0 && (piVar3 != (int *)0x0)) &&
             (local_18 = *(float *)(local_1c + 0x1c), local_8 < local_18))) {
        if (*(int *)(*(int *)(piVar3[10] + 0xc) + 0x10) == 0) {
          FUN_00468098(param_1,piVar3);
        }
        else {
          FUN_00468108(param_1,piVar3);
        }
        bVar1 = FUN_004682f4(param_1,*(int *)(*(int *)(param_2[10] + 0xc) + 0xc),param_3);
        iVar2 = CONCAT31(extraout_var_01,bVar1);
        (**(code **)(local_2c[0] + 8))(local_2c);
        piVar3 = (int *)(**(code **)(local_2c[0] + 0x30))(local_2c);
      }
      FUN_00465826(local_2c,2);
    }
  }
  else {
    iVar2 = 0;
  }
  return iVar2;
}



/* @004682f4 file=? name=FUN_004682f4 */

bool __cdecl FUN_004682f4(int param_1,int param_2,int *param_3)

{
  bool bVar1;
  int iVar2;
  
  bVar1 = false;
  if (param_3[4] != 0) {
    iVar2 = FUN_00462a1c(param_1 + 0x78,param_2);
    if (iVar2 == 0) goto LAB_0046839b;
    *param_3 = iVar2;
  }
  if (param_3[5] != 0) {
    iVar2 = FUN_00462a1c(param_1 + 0x78,param_2);
    if (iVar2 == 0) goto LAB_0046839b;
    param_3[1] = iVar2;
  }
  if (param_3[6] != 0) {
    iVar2 = FUN_00462a1c(param_1 + 0xec,param_2);
    if (iVar2 == 0) goto LAB_0046839b;
    param_3[2] = iVar2;
  }
  if (param_3[7] != 0) {
    iVar2 = FUN_00462a1c(param_1 + 0xec,param_2);
    if (iVar2 == 0) goto LAB_0046839b;
    param_3[3] = iVar2;
  }
  bVar1 = true;
LAB_0046839b:
  if (!bVar1) {
    FUN_004635e0(param_3);
  }
  return bVar1;
}



/* @004683b9 file=? name=FUN_004683b9 */

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

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



/* @004683dc file=? name=FUN_004683dc */

void __cdecl FUN_004683dc(int *param_1,byte param_2)

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



/* @00468408 file=? name=FUN_00468408 */

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

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

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



/* @0046853c file=? name=FUN_0046853c */

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

void __cdecl FUN_0046853c(undefined4 *param_1)

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



/* @00468587 file=? name=FUN_00468587 */

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

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



/* @004685a6 file=? name=FUN_004685a6 */

void __cdecl FUN_004685a6(int *param_1,byte param_2)

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



/* @004685d2 file=? name=FUN_004685d2 */

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

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



/* @004685f5 file=? name=FUN_004685f5 */

void __cdecl FUN_004685f5(int *param_1,byte param_2)

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



/* @00468621 file=? name=FUN_00468621 */

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

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



/* @00468650 file=? name=FUN_00468650 */

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

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



/* @0046867c file=? name=FUN_0046867c */

void FUN_0046867c(void)

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



/* @004686cc file=? name=FUN_004686cc */

void __cdecl FUN_004686cc(undefined4 *param_1)

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



/* @00468717 file=? name=FUN_00468717 */

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

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



/* @00468747 file=? name=FUN_00468747 */

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

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



/* @00468778 file=? name=FUN_00468778 */

undefined4 * __cdecl FUN_00468778(undefined4 *param_1)

{
  FUN_00442990(param_1);
  *param_1 = &PTR_FUN_004f4a10;
  FUN_00468812(param_1 + 0x16);
  return param_1;
}



/* @0046879c file=? name=FUN_0046879c */

void __cdecl FUN_0046879c(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f4a10;
    FUN_0046882b(param_1 + 0x16,2);
    FUN_004429c0(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004687d8 file=? name=FUN_004687d8 */

void __cdecl FUN_004687d8(int param_1)

{
  FUN_004689f4(param_1 + 0x58);
  FUN_00442a14(param_1);
  return;
}



/* @004687f4 file=? name=FUN_004687f4 */

void FUN_004687f4(void)

{
  FUN_00442a3c();
  return;
}



/* @00468803 file=? name=FUN_00468803 */

void FUN_00468803(void)

{
  FUN_004428b0();
  return;
}



/* @00468812 file=? name=FUN_00468812 */

undefined4 * __cdecl FUN_00468812(undefined4 *param_1)

{
  FUN_00442848(param_1);
  *param_1 = &PTR_FUN_004f4a04;
  return param_1;
}



/* @0046882b file=? name=FUN_0046882b */

void __cdecl FUN_0046882b(int *param_1,byte param_2)

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



/* @0046885e file=? name=FUN_0046885e */

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

{
  int iVar1;
  undefined4 *puVar2;
  
  iVar1 = FUN_004428bc(param_1,param_2);
  if (iVar1 == 0) {
    iVar1 = FUN_0046eb64();
    if (iVar1 == 0) {
      iVar1 = 0;
    }
    else {
      puVar2 = (undefined4 *)FUN_00402298(0x3c);
      if (puVar2 == (undefined4 *)0x0) {
        puVar2 = (undefined4 *)0x0;
      }
      else {
        puVar2 = FUN_00468a42(puVar2,param_2,iVar1,param_3);
      }
      (**(code **)(*(int *)(param_1 + 0xc) + 4))(param_1 + 0xc,puVar2);
    }
  }
  else {
    *(int *)(iVar1 + 0x30) = *(int *)(iVar1 + 0x30) + 1;
    iVar1 = *(int *)(iVar1 + 0x38);
  }
  return iVar1;
}



/* @004688ce file=? name=FUN_004688ce */

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

{
  int iVar1;
  int *piVar2;
  undefined4 *puVar3;
  
  iVar1 = FUN_0044292c(param_1,param_2);
  if (iVar1 == 0) {
    piVar2 = FUN_0046eb6c(param_2);
    if (piVar2 == (int *)0x0) {
      piVar2 = (int *)0x0;
    }
    else {
      puVar3 = (undefined4 *)FUN_00402298(0x3c);
      if (puVar3 == (undefined4 *)0x0) {
        puVar3 = (undefined4 *)0x0;
      }
      else {
        puVar3 = FUN_00468a6b(puVar3,param_2,piVar2,param_3);
      }
      (**(code **)(*(int *)(param_1 + 0xc) + 4))(param_1 + 0xc,puVar3);
    }
  }
  else {
    *(int *)(iVar1 + 0x30) = *(int *)(iVar1 + 0x30) + 1;
    piVar2 = *(int **)(iVar1 + 0x38);
  }
  return piVar2;
}



/* @0046893e file=? name=FUN_0046893e */

undefined4 __cdecl FUN_0046893e(int param_1,char *param_2)

{
  int iVar1;
  
  iVar1 = FUN_004428bc(param_1,param_2);
  if (iVar1 != 0) {
    *(int *)(iVar1 + 0x30) = *(int *)(iVar1 + 0x30) + 1;
    return *(undefined4 *)(iVar1 + 0x38);
  }
  return 0;
}



/* @00468961 file=? name=FUN_00468961 */

undefined4 __cdecl FUN_00468961(int param_1,int param_2)

{
  int iVar1;
  
  iVar1 = FUN_0044292c(param_1,param_2);
  if (iVar1 != 0) {
    *(int *)(iVar1 + 0x30) = *(int *)(iVar1 + 0x30) + 1;
    return *(undefined4 *)(iVar1 + 0x38);
  }
  return 0;
}



/* @00468984 file=? name=FUN_00468984 */

void __cdecl FUN_00468984(int param_1,char *param_2)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_004428bc(param_1,param_2);
  if ((((puVar1 != (undefined4 *)0x0) && (puVar1[0xc] = puVar1[0xc] + -1, (int)puVar1[0xc] < 1)) &&
      (puVar1[0xd] == 0)) && (puVar1 != (undefined4 *)0x0)) {
    (**(code **)*puVar1)(puVar1,3);
  }
  return;
}



/* @004689bc file=? name=FUN_004689bc */

void __cdecl FUN_004689bc(int param_1,int param_2)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_0044292c(param_1,param_2);
  if ((((puVar1 != (undefined4 *)0x0) && (puVar1[0xc] = puVar1[0xc] + -1, (int)puVar1[0xc] < 1)) &&
      (puVar1[0xd] == 0)) && (puVar1 != (undefined4 *)0x0)) {
    (**(code **)*puVar1)(puVar1,3);
  }
  return;
}



/* @004689f4 file=? name=FUN_004689f4 */

void __cdecl FUN_004689f4(int param_1)

{
  undefined4 *puVar1;
  int local_10 [3];
  
  FUN_0044316d(local_10,param_1 + 0xc);
  while( true ) {
    puVar1 = (undefined4 *)(**(code **)(local_10[0] + 0x28))(local_10);
    if (puVar1 == (undefined4 *)0x0) break;
    if (puVar1 != (undefined4 *)0x0) {
      (**(code **)*puVar1)(puVar1,3);
    }
  }
  FUN_004431ab(local_10,2);
  return;
}



/* @00468a42 file=? name=FUN_00468a42 */

undefined4 * __cdecl
FUN_00468a42(undefined4 *param_1,char *param_2,undefined4 param_3,undefined4 param_4)

{
  FUN_00442780(param_1,param_2,param_4);
  *param_1 = &PTR_FUN_004f4a00;
  param_1[0xe] = param_3;
  return param_1;
}



/* @00468a6b file=? name=FUN_00468a6b */

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

{
  FUN_004427dc(param_1,param_2,param_4);
  *param_1 = &PTR_FUN_004f4a00;
  param_1[0xe] = param_3;
  return param_1;
}



/* @00468a94 file=? name=FUN_00468a94 */

void __cdecl FUN_00468a94(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f4a00;
    FUN_0046ecdc((int *)param_1[0xe],3);
    param_1[0xe] = 0;
    FUN_00442810(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00468ad3 file=? name=FUN_00468ad3 */

void FUN_00468ad3(void)

{
  FUN_0044283c();
  return;
}



/* @00468ae4 file=? name=FUN_00468ae4 */

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

{
  int *piVar1;
  undefined4 uVar2;
  undefined2 *puVar3;
  int iVar4;
  
  FUN_0044a078(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f4b00;
  piVar1 = (int *)FUN_00402298(0xc);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_00449c88(piVar1,param_2,param_3);
  }
  param_1[0xb] = piVar1;
  param_1[6] = 1;
  param_1[8] = param_3;
  param_1[7] = param_2;
  param_1[10] = param_1[8] + -1;
  param_1[9] = param_1[7] + -1;
  uVar2 = FUN_004022b0(param_1[8] * 2);
  param_1[0xc] = uVar2;
  param_1[5] = 1;
  puVar3 = (undefined2 *)param_1[0xc];
  for (iVar4 = param_1[8]; 0 < iVar4; iVar4 = iVar4 + -1) {
    *puVar3 = 0;
    puVar3 = puVar3 + 1;
  }
  return param_1;
}



/* @00468b7c file=? name=FUN_00468b7c */

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

{
  int iVar1;
  undefined2 *puVar2;
  
  FUN_0044a078(param_1,*param_2,param_2[1]);
  *param_1 = &PTR_FUN_004f4b00;
  param_1[0xb] = param_2;
  param_1[6] = 0;
  param_1[8] = *(undefined4 *)(param_1[0xb] + 4);
  param_1[7] = *(undefined4 *)param_1[0xb];
  param_1[10] = param_1[8] + -1;
  param_1[9] = param_1[7] + -1;
  iVar1 = FUN_004022b0(param_1[8] * 2);
  param_1[0xc] = iVar1;
  if (iVar1 == 0) {
    param_1[5] = 0;
  }
  else {
    param_1[5] = 1;
    puVar2 = (undefined2 *)param_1[0xc];
    for (iVar1 = param_1[8]; 0 < iVar1; iVar1 = iVar1 + -1) {
      *puVar2 = 0;
      puVar2 = puVar2 + 1;
    }
  }
  return param_1;
}



/* @00468c04 file=? name=FUN_00468c04 */

void __cdecl FUN_00468c04(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f4b00;
    if ((int *)param_1[0xc] != (int *)0x0) {
      FUN_004022d0((int *)param_1[0xc]);
      param_1[0xc] = 0;
    }
    if (param_1[6] != 0) {
      if ((int *)param_1[0xb] != (int *)0x0) {
        FUN_00449d0c((int *)param_1[0xb],3);
        param_1[0xb] = 0;
      }
      param_1[6] = 0;
    }
    FUN_0044a0ac(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00468c68 file=? name=FUN_00468c68 */

undefined4 FUN_00468c68(void)

{
  return 1;
}



/* @00468c74 file=? name=FUN_00468c74 */

void __cdecl FUN_00468c74(int param_1,char *param_2)

{
  char cVar1;
  int *piVar2;
  uint uVar3;
  uint uVar4;
  char *pcVar5;
  char *pcVar6;
  undefined8 uVar7;
  char local_54 [80];
  
  FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_Video8BitBuffered__004f4a18,(char *)0x0);
  uVar3 = 0xffffffff;
  do {
    pcVar5 = param_2;
    if (uVar3 == 0) break;
    uVar3 = uVar3 - 1;
    pcVar5 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar5;
  } while (cVar1 != '\0');
  uVar3 = ~uVar3;
  pcVar5 = pcVar5 + -uVar3;
  pcVar6 = local_54;
  for (uVar4 = uVar3 >> 2; uVar4 != 0; uVar4 = uVar4 - 1) {
    *(undefined4 *)pcVar6 = *(undefined4 *)pcVar5;
    pcVar5 = pcVar5 + 4;
    pcVar6 = pcVar6 + 4;
  }
  for (uVar3 = uVar3 & 3; uVar3 != 0; uVar3 = uVar3 - 1) {
    *pcVar6 = *pcVar5;
    pcVar5 = pcVar5 + 1;
    pcVar6 = pcVar6 + 1;
  }
  FUN_004d49b8(local_54,&DAT_004f4a2c);
  uVar3 = *(uint *)(param_1 + 0x1c);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_width___004f4a30,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4a3d,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x20);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_height___004f4a3f,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4a4c,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x24);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_maximumX___004f4a4e,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4a5b,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x28);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_maximumY___004f4a5d,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4a6a,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x30);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_changedLine__004f4a6c,(char *)0x0);
  uVar7 = FUN_004dbd4c(&DAT_00524e20,uVar3);
  FUN_004dbb24((int *)uVar7,&DAT_004f4a79,(char *)0x0);
  FUN_00449d50(*(uint **)(param_1 + 0x2c),local_54);
  FUN_0044a0cc(param_1,local_54);
  return;
}



/* @00468e78 file=? name=FUN_00468e78 */

void __cdecl FUN_00468e78(int param_1,int param_2,int param_3,int *param_4)

{
  *param_4 = *(int *)(*(int *)(param_1 + 0x2c) + 8) + param_2 + param_3 * *(int *)(param_1 + 0x1c);
  return;
}



/* @00468e9c file=? name=FUN_00468e9c */

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

{
  short *psVar1;
  int iVar2;
  
  iVar2 = param_3;
  if (param_3 < param_2) {
    iVar2 = param_2;
    param_2 = param_3;
  }
  psVar1 = (short *)(*(int *)(param_1 + 0x30) + param_2 * 2);
  *psVar1 = *psVar1 + 1;
  if (iVar2 < *(int *)(param_1 + 0x28)) {
    psVar1 = (short *)(*(int *)(param_1 + 0x30) + 2 + iVar2 * 2);
    *psVar1 = *psVar1 + -1;
  }
  return;
}



/* @00468ecc file=? name=FUN_00468ecc */

void __cdecl
FUN_00468ecc(int param_1,byte param_2,undefined4 param_3,int param_4,int param_5,int param_6)

{
  int iVar1;
  byte *local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar1 = *(int *)(param_1 + 0x28) - param_6;
    FUN_00468e9c(param_1,iVar1,iVar1);
    FUN_00468e78(param_1,param_5,iVar1,(int *)&local_8);
    if (param_4 == 0) {
      *local_8 = param_2;
    }
    else if (param_4 == 1) {
      *local_8 = *local_8 & param_2;
    }
    else if (param_4 == 2) {
      *local_8 = *local_8 | param_2;
    }
    else if (param_4 == 3) {
      *local_8 = *local_8 ^ param_2;
    }
  }
  return;
}



/* @00468f40 file=? name=FUN_00468f40 */

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

{
  int iVar1;
  int iVar2;
  int iVar3;
  bool bVar4;
  byte *local_10;
  int local_c;
  uint local_8;
  
  if (param_1[5] != 0) {
    if ((param_7 == param_5) && (param_6 == param_8)) {
      if (param_9 != 0) {
        (**(code **)(*param_1 + 0x14))(param_1,param_2,0,param_4,param_5,param_6);
      }
    }
    else {
      iVar2 = param_1[10] - param_6;
      iVar1 = param_1[10] - param_8;
      FUN_00468e9c((int)param_1,iVar2,iVar1);
      iVar3 = param_7 - param_5;
      bVar4 = iVar3 < 0;
      if (bVar4) {
        iVar3 = -iVar3;
      }
      local_8 = (uint)bVar4;
      local_c = iVar1 - iVar2;
      if (local_c < 0) {
        local_8 = local_8 | 2;
        local_c = -local_c;
      }
      if (local_c < iVar3) {
        local_8 = local_8 | 4;
      }
      FUN_00468e78((int)param_1,param_5,iVar2,(int *)&local_10);
      iVar1 = 0x400;
      switch(local_8) {
      case 0:
        iVar2 = local_c;
        if (param_9 == 0) {
          iVar2 = local_c + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = (byte)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (byte)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (byte)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (byte)param_2;
          }
          local_10 = local_10 + param_1[7];
          iVar1 = iVar1 + (iVar3 << 0xb) / local_c;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + 1;
          }
        }
        break;
      case 1:
        iVar2 = local_c;
        if (param_9 == 0) {
          iVar2 = local_c + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = (byte)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (byte)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (byte)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (byte)param_2;
          }
          local_10 = local_10 + param_1[7];
          iVar1 = iVar1 + (iVar3 << 0xb) / local_c;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + -1;
          }
        }
        break;
      case 2:
        iVar2 = local_c;
        if (param_9 == 0) {
          iVar2 = local_c + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = (byte)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (byte)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (byte)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (byte)param_2;
          }
          local_10 = local_10 + -param_1[7];
          iVar1 = iVar1 + (iVar3 << 0xb) / local_c;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + 1;
          }
        }
        break;
      case 3:
        iVar2 = local_c;
        if (param_9 == 0) {
          iVar2 = local_c + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = (byte)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (byte)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (byte)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (byte)param_2;
          }
          local_10 = local_10 + -param_1[7];
          iVar1 = iVar1 + (iVar3 << 0xb) / local_c;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + -1;
          }
        }
        break;
      case 4:
        iVar2 = iVar3;
        if (param_9 == 0) {
          iVar2 = iVar3 + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = (byte)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (byte)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (byte)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (byte)param_2;
          }
          local_10 = local_10 + 1;
          iVar1 = iVar1 + (local_c << 0xb) / iVar3;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + param_1[7];
          }
        }
        break;
      case 5:
        iVar2 = iVar3;
        if (param_9 == 0) {
          iVar2 = iVar3 + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = (byte)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (byte)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (byte)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (byte)param_2;
          }
          local_10 = local_10 + -1;
          iVar1 = iVar1 + (local_c << 0xb) / iVar3;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + param_1[7];
          }
        }
        break;
      case 6:
        iVar2 = iVar3;
        if (param_9 == 0) {
          iVar2 = iVar3 + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = (byte)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (byte)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (byte)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (byte)param_2;
          }
          local_10 = local_10 + 1;
          iVar1 = iVar1 + (local_c << 0xb) / iVar3;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + -param_1[7];
          }
        }
        break;
      case 7:
        iVar2 = iVar3;
        if (param_9 == 0) {
          iVar2 = iVar3 + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = (byte)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (byte)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (byte)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (byte)param_2;
          }
          local_10 = local_10 + -1;
          iVar1 = iVar1 + (local_c << 0xb) / iVar3;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + -param_1[7];
          }
        }
      }
    }
  }
  return;
}



/* @004693e0 file=? name=FUN_004693e0 */

void __cdecl
FUN_004693e0(int param_1,byte param_2,undefined4 param_3,int param_4,int param_5,int param_6,
            int param_7,int param_8)

{
  int iVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  byte *local_8;
  
  iVar3 = param_5;
  if (*(int *)(param_1 + 0x14) != 0) {
    param_8 = *(int *)(param_1 + 0x28) - param_8;
    iVar2 = *(int *)(param_1 + 0x28) - param_6;
    if (param_7 < param_5) {
      param_5 = param_7;
      param_7 = iVar3;
    }
    iVar3 = iVar2;
    if (param_8 < iVar2) {
      iVar3 = param_8;
      param_8 = iVar2;
    }
    FUN_00468e9c(param_1,iVar3,param_8);
    FUN_00468e78(param_1,param_5,iVar3,(int *)&local_8);
    iVar4 = (param_7 - param_5) + 1;
    iVar3 = (param_8 - iVar3) + 1;
    iVar2 = *(int *)(param_1 + 0x1c) - iVar4;
    if (param_4 == 0) {
      for (; iVar1 = iVar4, 0 < iVar3; iVar3 = iVar3 + -1) {
        for (; 0 < iVar1; iVar1 = iVar1 + -1) {
          *local_8 = param_2;
          local_8 = local_8 + 1;
        }
        local_8 = local_8 + iVar2;
      }
    }
    else if (param_4 == 1) {
      for (; iVar1 = iVar4, 0 < iVar3; iVar3 = iVar3 + -1) {
        for (; 0 < iVar1; iVar1 = iVar1 + -1) {
          *local_8 = *local_8 & param_2;
          local_8 = local_8 + 1;
        }
        local_8 = local_8 + iVar2;
      }
    }
    else if (param_4 == 2) {
      for (; iVar1 = iVar4, 0 < iVar3; iVar3 = iVar3 + -1) {
        for (; 0 < iVar1; iVar1 = iVar1 + -1) {
          *local_8 = *local_8 | param_2;
          local_8 = local_8 + 1;
        }
        local_8 = local_8 + iVar2;
      }
    }
    else if (param_4 == 3) {
      for (; iVar1 = iVar4, 0 < iVar3; iVar3 = iVar3 + -1) {
        for (; 0 < iVar1; iVar1 = iVar1 + -1) {
          *local_8 = *local_8 ^ param_2;
          local_8 = local_8 + 1;
        }
        local_8 = local_8 + iVar2;
      }
    }
  }
  return;
}



/* @00469518 file=? name=FUN_00469518 */

undefined4 __cdecl FUN_00469518(int param_1)

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



/* @00469528 file=? name=FUN_00469528 */

void __cdecl
FUN_00469528(int param_1,byte param_2,undefined4 param_3,int param_4,int param_5,int param_6,
            int param_7,int param_8,int param_9,int param_10,int param_11,int param_12)

{
  byte *pbVar1;
  uint uVar2;
  int iVar3;
  int iVar4;
  int iVar5;
  ushort *puVar6;
  byte *local_18;
  ushort *local_14;
  uint local_10;
  uint local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar3 = *(int *)(param_1 + 0x28) - param_7;
    iVar4 = *(int *)(param_8 + 0x10) + -1;
    iVar5 = iVar4 - param_10;
    local_8 = (param_11 - param_9) + 1;
    iVar4 = (iVar5 - (iVar4 - param_12)) + 1;
    local_14 = (ushort *)
               (*(int *)(param_8 + 0x18) + (param_9 >> 4) * 2 + *(int *)(param_8 + 0x14) * iVar5 * 2
               );
    local_10 = 1 << (0xf - ((byte)param_9 & 0xf) & 0x1f);
    FUN_00468e78(param_1,param_6,iVar3,(int *)&local_18);
    if (param_5 == 0x5a) {
      FUN_00468e9c(param_1,iVar3,iVar3 + local_8);
      for (; 0 < iVar4; iVar4 = iVar4 + -1) {
        iVar3 = *(int *)(param_8 + 0x14);
        pbVar1 = local_18 + 1;
        local_c = (uint)*local_14;
        puVar6 = local_14 + 1;
        uVar2 = local_10;
        for (iVar5 = local_8; 0 < iVar5; iVar5 = iVar5 + -1) {
          if (uVar2 == 0) {
            local_c = (uint)*puVar6;
            puVar6 = puVar6 + 1;
            uVar2 = 0x8000;
          }
          if ((local_c & uVar2) != 0) {
            if (param_4 == 0) {
              *local_18 = param_2;
            }
            else if (param_4 == 1) {
              *local_18 = *local_18 & param_2;
            }
            else if (param_4 == 2) {
              *local_18 = *local_18 | param_2;
            }
            else if (param_4 == 3) {
              *local_18 = *local_18 ^ param_2;
            }
          }
          uVar2 = (int)uVar2 >> 1;
          local_18 = local_18 + *(int *)(param_1 + 0x1c);
        }
        local_18 = pbVar1;
        local_14 = local_14 + -iVar3;
      }
    }
    else if (param_5 == 0xb4) {
      FUN_00468e9c(param_1,iVar3,iVar3 + iVar4);
      for (; 0 < iVar4; iVar4 = iVar4 + -1) {
        iVar3 = *(int *)(param_8 + 0x14);
        pbVar1 = local_18 + *(int *)(param_1 + 0x1c);
        local_c = (uint)*local_14;
        puVar6 = local_14 + 1;
        uVar2 = local_10;
        for (iVar5 = local_8; 0 < iVar5; iVar5 = iVar5 + -1) {
          if (uVar2 == 0) {
            local_c = (uint)*puVar6;
            puVar6 = puVar6 + 1;
            uVar2 = 0x8000;
          }
          if ((local_c & uVar2) != 0) {
            if (param_4 == 0) {
              *local_18 = param_2;
            }
            else if (param_4 == 1) {
              *local_18 = *local_18 & param_2;
            }
            else if (param_4 == 2) {
              *local_18 = *local_18 | param_2;
            }
            else if (param_4 == 3) {
              *local_18 = *local_18 ^ param_2;
            }
          }
          local_18 = local_18 + -1;
          uVar2 = (int)uVar2 >> 1;
        }
        local_18 = pbVar1;
        local_14 = local_14 + -iVar3;
      }
    }
    else if (param_5 == 0x10e) {
      FUN_00468e9c(param_1,iVar3 - (local_8 + -1),iVar3);
      for (; 0 < iVar4; iVar4 = iVar4 + -1) {
        iVar3 = *(int *)(param_8 + 0x14);
        pbVar1 = local_18 + -1;
        local_c = (uint)*local_14;
        puVar6 = local_14 + 1;
        uVar2 = local_10;
        for (iVar5 = local_8; 0 < iVar5; iVar5 = iVar5 + -1) {
          if (uVar2 == 0) {
            local_c = (uint)*puVar6;
            puVar6 = puVar6 + 1;
            uVar2 = 0x8000;
          }
          if ((local_c & uVar2) != 0) {
            if (param_4 == 0) {
              *local_18 = param_2;
            }
            else if (param_4 == 1) {
              *local_18 = *local_18 & param_2;
            }
            else if (param_4 == 2) {
              *local_18 = *local_18 | param_2;
            }
            else if (param_4 == 3) {
              *local_18 = *local_18 ^ param_2;
            }
          }
          uVar2 = (int)uVar2 >> 1;
          local_18 = local_18 + -*(int *)(param_1 + 0x1c);
        }
        local_18 = pbVar1;
        local_14 = local_14 + -iVar3;
      }
    }
    else {
      FUN_00468e9c(param_1,(iVar3 - iVar4) + 1,iVar3);
      for (; 0 < iVar4; iVar4 = iVar4 + -1) {
        iVar3 = *(int *)(param_8 + 0x14);
        pbVar1 = local_18 + -*(int *)(param_1 + 0x1c);
        local_c = (uint)*local_14;
        puVar6 = local_14 + 1;
        uVar2 = local_10;
        for (iVar5 = local_8; 0 < iVar5; iVar5 = iVar5 + -1) {
          if (uVar2 == 0) {
            local_c = (uint)*puVar6;
            puVar6 = puVar6 + 1;
            uVar2 = 0x8000;
          }
          if ((local_c & uVar2) != 0) {
            if (param_4 == 0) {
              *local_18 = param_2;
            }
            else if (param_4 == 1) {
              *local_18 = *local_18 & param_2;
            }
            else if (param_4 == 2) {
              *local_18 = *local_18 | param_2;
            }
            else if (param_4 == 3) {
              *local_18 = *local_18 ^ param_2;
            }
          }
          local_18 = local_18 + 1;
          uVar2 = (int)uVar2 >> 1;
        }
        local_18 = pbVar1;
        local_14 = local_14 + -iVar3;
      }
    }
  }
  return;
}



/* @004698a4 file=? name=FUN_004698a4 */

void __cdecl
FUN_004698a4(int param_1,byte param_2,byte param_3,undefined4 param_4,int param_5,int param_6,
            int param_7,int param_8,int param_9,int param_10,int param_11,int param_12,int param_13)

{
  byte *pbVar1;
  uint uVar2;
  byte bVar3;
  int iVar4;
  int iVar5;
  int iVar6;
  byte *local_1c;
  ushort *local_18;
  ushort *local_14;
  uint local_10;
  uint local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar4 = *(int *)(param_1 + 0x28) - param_8;
    iVar5 = *(int *)(param_9 + 0x10) + -1;
    iVar6 = iVar5 - param_11;
    local_8 = (param_12 - param_10) + 1;
    iVar5 = (iVar6 - (iVar5 - param_13)) + 1;
    local_14 = (ushort *)
               (*(int *)(param_9 + 0x18) + (param_10 >> 4) * 2 +
               *(int *)(param_9 + 0x14) * iVar6 * 2);
    local_10 = 1 << (0xf - ((byte)param_10 & 0xf) & 0x1f);
    FUN_00468e78(param_1,param_7,iVar4,(int *)&local_1c);
    if (param_6 == 0x5a) {
      FUN_00468e9c(param_1,iVar4,iVar4 + local_8);
      for (; 0 < iVar5; iVar5 = iVar5 + -1) {
        iVar4 = *(int *)(param_9 + 0x14);
        pbVar1 = local_1c + 1;
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar2 = local_10;
        for (iVar6 = local_8; 0 < iVar6; iVar6 = iVar6 + -1) {
          if (uVar2 == 0) {
            uVar2 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          bVar3 = param_3;
          if ((local_c & uVar2) != 0) {
            bVar3 = param_2;
          }
          if (param_5 == 0) {
            *local_1c = bVar3;
          }
          else if (param_5 == 1) {
            *local_1c = *local_1c & bVar3;
          }
          else if (param_5 == 2) {
            *local_1c = *local_1c | bVar3;
          }
          else if (param_5 == 3) {
            *local_1c = *local_1c ^ bVar3;
          }
          uVar2 = (int)uVar2 >> 1;
          local_1c = local_1c + *(int *)(param_1 + 0x1c);
        }
        local_1c = pbVar1;
        local_14 = local_14 + -iVar4;
      }
    }
    else if (param_6 == 0xb4) {
      FUN_00468e9c(param_1,iVar4,iVar4 + iVar5);
      for (; 0 < iVar5; iVar5 = iVar5 + -1) {
        iVar4 = *(int *)(param_9 + 0x14);
        pbVar1 = local_1c + *(int *)(param_1 + 0x1c);
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar2 = local_10;
        for (iVar6 = local_8; 0 < iVar6; iVar6 = iVar6 + -1) {
          if (uVar2 == 0) {
            uVar2 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          bVar3 = param_3;
          if ((local_c & uVar2) != 0) {
            bVar3 = param_2;
          }
          if (param_5 == 0) {
            *local_1c = bVar3;
          }
          else if (param_5 == 1) {
            *local_1c = *local_1c & bVar3;
          }
          else if (param_5 == 2) {
            *local_1c = *local_1c | bVar3;
          }
          else if (param_5 == 3) {
            *local_1c = *local_1c ^ bVar3;
          }
          local_1c = local_1c + -1;
          uVar2 = (int)uVar2 >> 1;
        }
        local_1c = pbVar1;
        local_14 = local_14 + -iVar4;
      }
    }
    else if (param_6 == 0x10e) {
      FUN_00468e9c(param_1,iVar4 - (local_8 + -1),iVar4);
      for (; 0 < iVar5; iVar5 = iVar5 + -1) {
        iVar4 = *(int *)(param_9 + 0x14);
        pbVar1 = local_1c + -1;
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar2 = local_10;
        for (iVar6 = local_8; 0 < iVar6; iVar6 = iVar6 + -1) {
          if (uVar2 == 0) {
            uVar2 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          bVar3 = param_3;
          if ((local_c & uVar2) != 0) {
            bVar3 = param_2;
          }
          if (param_5 == 0) {
            *local_1c = bVar3;
          }
          else if (param_5 == 1) {
            *local_1c = *local_1c & bVar3;
          }
          else if (param_5 == 2) {
            *local_1c = *local_1c | bVar3;
          }
          else if (param_5 == 3) {
            *local_1c = *local_1c ^ bVar3;
          }
          uVar2 = (int)uVar2 >> 1;
          local_1c = local_1c + -*(int *)(param_1 + 0x1c);
        }
        local_1c = pbVar1;
        local_14 = local_14 + -iVar4;
      }
    }
    else {
      FUN_00468e9c(param_1,(iVar4 - iVar5) + 1,iVar4);
      for (; 0 < iVar5; iVar5 = iVar5 + -1) {
        iVar4 = *(int *)(param_9 + 0x14);
        pbVar1 = local_1c + -*(int *)(param_1 + 0x1c);
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar2 = local_10;
        for (iVar6 = local_8; 0 < iVar6; iVar6 = iVar6 + -1) {
          if (uVar2 == 0) {
            uVar2 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          bVar3 = param_3;
          if ((local_c & uVar2) != 0) {
            bVar3 = param_2;
          }
          if (param_5 == 0) {
            *local_1c = bVar3;
          }
          else if (param_5 == 1) {
            *local_1c = *local_1c & bVar3;
          }
          else if (param_5 == 2) {
            *local_1c = *local_1c | bVar3;
          }
          else if (param_5 == 3) {
            *local_1c = *local_1c ^ bVar3;
          }
          local_1c = local_1c + 1;
          uVar2 = (int)uVar2 >> 1;
        }
        local_1c = pbVar1;
        local_14 = local_14 + -iVar4;
      }
    }
  }
  return;
}



/* @00469c3c file=? name=FUN_00469c3c */

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

{
  byte *pbVar1;
  byte *pbVar2;
  byte bVar3;
  int iVar4;
  int iVar5;
  int iVar6;
  byte *local_10;
  byte *local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar4 = *(int *)(param_1 + 0x28) - param_8;
    iVar5 = (param_9[1] + -1) - param_11;
    local_8 = (param_12 - param_10) + 1;
    iVar6 = (iVar5 - ((param_9[1] + -1) - param_13)) + 1;
    local_c = (byte *)(param_10 + param_9[2] + *param_9 * iVar5);
    FUN_00468e78(param_1,param_7,iVar4,(int *)&local_10);
    if (param_5 == 0) {
      if (param_6 == 0x5a) {
        FUN_00468e9c(param_1,iVar4,iVar4 + local_8);
        for (; 0 < iVar6; iVar6 = iVar6 + -1) {
          pbVar1 = local_c + -*param_9;
          pbVar2 = local_10 + 1;
          for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
            bVar3 = *local_c;
            local_c = local_c + 1;
            if (bVar3 != 0) {
              if (param_4 == 0) {
                *local_10 = bVar3;
              }
              else if (param_4 == 1) {
                *local_10 = *local_10 & bVar3;
              }
              else if (param_4 == 2) {
                *local_10 = *local_10 | bVar3;
              }
              else if (param_4 == 3) {
                *local_10 = *local_10 ^ bVar3;
              }
            }
            local_10 = local_10 + *(int *)(param_1 + 0x1c);
          }
          local_10 = pbVar2;
          local_c = pbVar1;
        }
      }
      else if (param_6 == 0xb4) {
        FUN_00468e9c(param_1,iVar4,iVar4 + iVar6);
        for (; 0 < iVar6; iVar6 = iVar6 + -1) {
          pbVar1 = local_c + -*param_9;
          pbVar2 = local_10 + *(int *)(param_1 + 0x1c);
          for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
            bVar3 = *local_c;
            local_c = local_c + 1;
            if (bVar3 != 0) {
              if (param_4 == 0) {
                *local_10 = bVar3;
              }
              else if (param_4 == 1) {
                *local_10 = *local_10 & bVar3;
              }
              else if (param_4 == 2) {
                *local_10 = *local_10 | bVar3;
              }
              else if (param_4 == 3) {
                *local_10 = *local_10 ^ bVar3;
              }
            }
            local_10 = local_10 + -1;
          }
          local_10 = pbVar2;
          local_c = pbVar1;
        }
      }
      else if (param_6 == 0x10e) {
        FUN_00468e9c(param_1,iVar4 - (local_8 + -1),iVar4);
        for (; 0 < iVar6; iVar6 = iVar6 + -1) {
          pbVar1 = local_c + -*param_9;
          pbVar2 = local_10 + -1;
          for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
            bVar3 = *local_c;
            local_c = local_c + 1;
            if (bVar3 != 0) {
              if (param_4 == 0) {
                *local_10 = bVar3;
              }
              else if (param_4 == 1) {
                *local_10 = *local_10 & bVar3;
              }
              else if (param_4 == 2) {
                *local_10 = *local_10 | bVar3;
              }
              else if (param_4 == 3) {
                *local_10 = *local_10 ^ bVar3;
              }
            }
            local_10 = local_10 + -*(int *)(param_1 + 0x1c);
          }
          local_10 = pbVar2;
          local_c = pbVar1;
        }
      }
      else {
        FUN_00468e9c(param_1,(iVar4 - iVar6) + 1,iVar4);
        for (; 0 < iVar6; iVar6 = iVar6 + -1) {
          pbVar1 = local_c + -*param_9;
          pbVar2 = local_10 + -*(int *)(param_1 + 0x1c);
          for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
            bVar3 = *local_c;
            local_c = local_c + 1;
            if (bVar3 != 0) {
              if (param_4 == 0) {
                *local_10 = bVar3;
              }
              else if (param_4 == 1) {
                *local_10 = *local_10 & bVar3;
              }
              else if (param_4 == 2) {
                *local_10 = *local_10 | bVar3;
              }
              else if (param_4 == 3) {
                *local_10 = *local_10 ^ bVar3;
              }
            }
            local_10 = local_10 + 1;
          }
          local_10 = pbVar2;
          local_c = pbVar1;
        }
      }
    }
    else if (param_6 == 0x5a) {
      FUN_00468e9c(param_1,iVar4,iVar4 + local_8);
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        pbVar1 = local_c + -*param_9;
        pbVar2 = local_10 + 1;
        for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
          bVar3 = *local_c;
          local_c = local_c + 1;
          if (param_4 == 0) {
            *local_10 = bVar3;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & bVar3;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | bVar3;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ bVar3;
          }
          local_10 = local_10 + *(int *)(param_1 + 0x1c);
        }
        local_10 = pbVar2;
        local_c = pbVar1;
      }
    }
    else if (param_6 == 0xb4) {
      FUN_00468e9c(param_1,iVar4,iVar4 + iVar6);
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        pbVar1 = local_c + -*param_9;
        pbVar2 = local_10 + *(int *)(param_1 + 0x1c);
        for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
          bVar3 = *local_c;
          local_c = local_c + 1;
          if (param_4 == 0) {
            *local_10 = bVar3;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & bVar3;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | bVar3;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ bVar3;
          }
          local_10 = local_10 + -1;
        }
        local_10 = pbVar2;
        local_c = pbVar1;
      }
    }
    else if (param_6 == 0x10e) {
      FUN_00468e9c(param_1,iVar4 - (local_8 + -1),iVar4);
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        pbVar1 = local_c + -*param_9;
        pbVar2 = local_10 + -1;
        for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
          bVar3 = *local_c;
          local_c = local_c + 1;
          if (param_4 == 0) {
            *local_10 = bVar3;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & bVar3;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | bVar3;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ bVar3;
          }
          local_10 = local_10 + -*(int *)(param_1 + 0x1c);
        }
        local_10 = pbVar2;
        local_c = pbVar1;
      }
    }
    else {
      FUN_00468e9c(param_1,(iVar4 - iVar6) + 1,iVar4);
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        pbVar1 = local_c + -*param_9;
        pbVar2 = local_10 + -*(int *)(param_1 + 0x1c);
        for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
          bVar3 = *local_c;
          local_c = local_c + 1;
          if (param_4 == 0) {
            *local_10 = bVar3;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & bVar3;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | bVar3;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ bVar3;
          }
          local_10 = local_10 + 1;
        }
        local_10 = pbVar2;
        local_c = pbVar1;
      }
    }
  }
  return;
}



/* @0046a0e4 file=? name=FUN_0046a0e4 */

void __cdecl
FUN_0046a0e4(int param_1,byte param_2,undefined4 param_3,int param_4,int param_5,int param_6,
            int param_7,int *param_8,int param_9,int param_10,int param_11,int param_12)

{
  char *pcVar1;
  byte *pbVar2;
  char cVar3;
  int iVar4;
  int iVar5;
  int iVar6;
  byte *local_10;
  char *local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar4 = *(int *)(param_1 + 0x28) - param_7;
    iVar5 = (param_8[1] + -1) - param_10;
    local_8 = (param_11 - param_9) + 1;
    iVar6 = (iVar5 - ((param_8[1] + -1) - param_12)) + 1;
    local_c = (char *)(param_8[2] + param_9 + *param_8 * iVar5);
    FUN_00468e78(param_1,param_6,iVar4,(int *)&local_10);
    if (param_5 == 0x5a) {
      FUN_00468e9c(param_1,iVar4,iVar4 + local_8);
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        pcVar1 = local_c + -*param_8;
        pbVar2 = local_10 + 1;
        for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
          cVar3 = *local_c;
          local_c = local_c + 1;
          if (cVar3 != '\0') {
            if (param_4 == 0) {
              *local_10 = param_2;
            }
            else if (param_4 == 1) {
              *local_10 = *local_10 & param_2;
            }
            else if (param_4 == 2) {
              *local_10 = *local_10 | param_2;
            }
            else if (param_4 == 3) {
              *local_10 = *local_10 ^ param_2;
            }
          }
          local_10 = local_10 + *(int *)(param_1 + 0x1c);
        }
        local_10 = pbVar2;
        local_c = pcVar1;
      }
    }
    else if (param_5 == 0xb4) {
      FUN_00468e9c(param_1,iVar4,iVar4 + iVar6);
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        pcVar1 = local_c + -*param_8;
        pbVar2 = local_10 + *(int *)(param_1 + 0x1c);
        for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
          cVar3 = *local_c;
          local_c = local_c + 1;
          if (cVar3 != '\0') {
            if (param_4 == 0) {
              *local_10 = param_2;
            }
            else if (param_4 == 1) {
              *local_10 = *local_10 & param_2;
            }
            else if (param_4 == 2) {
              *local_10 = *local_10 | param_2;
            }
            else if (param_4 == 3) {
              *local_10 = *local_10 ^ param_2;
            }
          }
          local_10 = local_10 + -1;
        }
        local_10 = pbVar2;
        local_c = pcVar1;
      }
    }
    else if (param_5 == 0x10e) {
      FUN_00468e9c(param_1,iVar4 - local_8,iVar4);
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        pcVar1 = local_c + -*param_8;
        pbVar2 = local_10 + -1;
        for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
          cVar3 = *local_c;
          local_c = local_c + 1;
          if (cVar3 != '\0') {
            if (param_4 == 0) {
              *local_10 = param_2;
            }
            else if (param_4 == 1) {
              *local_10 = *local_10 & param_2;
            }
            else if (param_4 == 2) {
              *local_10 = *local_10 | param_2;
            }
            else if (param_4 == 3) {
              *local_10 = *local_10 ^ param_2;
            }
          }
          local_10 = local_10 + -*(int *)(param_1 + 0x1c);
        }
        local_10 = pbVar2;
        local_c = pcVar1;
      }
    }
    else {
      FUN_00468e9c(param_1,(iVar4 - iVar6) + 1,iVar4);
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        pcVar1 = local_c + -*param_8;
        pbVar2 = local_10 + -*(int *)(param_1 + 0x1c);
        for (iVar4 = local_8; 0 < iVar4; iVar4 = iVar4 + -1) {
          cVar3 = *local_c;
          local_c = local_c + 1;
          if (cVar3 != '\0') {
            if (param_4 == 0) {
              *local_10 = param_2;
            }
            else if (param_4 == 1) {
              *local_10 = *local_10 & param_2;
            }
            else if (param_4 == 2) {
              *local_10 = *local_10 | param_2;
            }
            else if (param_4 == 3) {
              *local_10 = *local_10 ^ param_2;
            }
          }
          local_10 = local_10 + 1;
        }
        local_10 = pbVar2;
        local_c = pcVar1;
      }
    }
  }
  return;
}



/* @0046a3a8 file=? name=FUN_0046a3a8 */

undefined4 * __cdecl
FUN_0046a3a8(undefined4 *param_1,undefined4 *param_2,char *param_3,undefined4 param_4)

{
  FUN_0044a2d0(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f4ad0;
  param_1[10] = param_4;
  param_1[0xb] = param_1[3] - param_1[1];
  param_1[0xc] = param_1[4] - param_1[2];
  if (((param_1[10] == 0x5a) || (param_1[10] == 0x10e)) && (param_2 != (undefined4 *)0x0)) {
    param_1[1] = param_2[2];
    param_1[2] = param_2[1];
    param_1[3] = param_2[4];
    param_1[4] = param_2[3];
  }
  return param_1;
}



/* @0046a418 file=? name=FUN_0046a418 */

void __cdecl FUN_0046a418(int *param_1,byte param_2)

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



/* @0046a444 file=? name=FUN_0046a444 */

undefined4 FUN_0046a444(void)

{
  return 1;
}



/* @0046a450 file=? name=FUN_0046a450 */

void __cdecl FUN_0046a450(int param_1,char *param_2)

{
  char cVar1;
  int *piVar2;
  uint uVar3;
  uint uVar4;
  char *pcVar5;
  char *pcVar6;
  uint *puVar7;
  char local_54 [80];
  
  FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_L4BytePort__004f4a7b,(char *)0x0);
  uVar3 = 0xffffffff;
  do {
    pcVar5 = param_2;
    if (uVar3 == 0) break;
    uVar3 = uVar3 - 1;
    pcVar5 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar5;
  } while (cVar1 != '\0');
  uVar3 = ~uVar3;
  pcVar5 = pcVar5 + -uVar3;
  pcVar6 = local_54;
  for (uVar4 = uVar3 >> 2; uVar4 != 0; uVar4 = uVar4 - 1) {
    *(undefined4 *)pcVar6 = *(undefined4 *)pcVar5;
    pcVar5 = pcVar5 + 4;
    pcVar6 = pcVar6 + 4;
  }
  for (uVar3 = uVar3 & 3; uVar3 != 0; uVar3 = uVar3 - 1) {
    *pcVar6 = *pcVar5;
    pcVar5 = pcVar5 + 1;
    pcVar6 = pcVar6 + 1;
  }
  FUN_004d49b8(local_54,&DAT_004f4a88);
  uVar3 = *(uint *)(param_1 + 0x28);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_baseRotation___004f4a8c,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4a9b,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x2c);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_maximumX___004f4a9d,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4aac,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x30);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_maximumY___004f4aae,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4abd,(char *)0x0);
  puVar7 = (uint *)(param_1 + 4);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_bounds___004f4abf,(char *)0x0);
  piVar2 = (int *)FUN_00407d78(&DAT_00524e20,puVar7);
  FUN_004dbb24(piVar2,&DAT_004f4ace,(char *)0x0);
  FUN_004d9c70(&DAT_00524e20);
  FUN_0044a374(param_1,local_54);
  return;
}



/* @0046a604 file=? name=FUN_0046a604 */

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

{
  int local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    FUN_0046aa18(param_1,&local_8,&local_c,param_4,param_5);
    (**(code **)(**(int **)(param_1 + 0x14) + 0x14))
              (*(int **)(param_1 + 0x14),param_2,0,param_3,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8));
  }
  return;
}



/* @0046a65c file=? name=FUN_0046a65c */

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

{
  int local_14;
  int local_10;
  int local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    FUN_0046aa18(param_1,&local_8,&local_c,param_4,param_5);
    FUN_0046aa18(param_1,&local_10,&local_14,param_6,param_7);
    (**(code **)(**(int **)(param_1 + 0x14) + 0x18))
              (*(int **)(param_1 + 0x14),param_2,0,param_3,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8),local_10 + *(int *)(param_1 + 4),
               local_14 + *(int *)(param_1 + 8),param_8);
  }
  return;
}



/* @0046a6dc file=? name=FUN_0046a6dc */

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

{
  int local_14;
  int local_10;
  int local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    FUN_0046aa18(param_1,&local_8,&local_c,param_4,param_5);
    FUN_0046aa18(param_1,&local_10,&local_14,param_6,param_7);
    (**(code **)(**(int **)(param_1 + 0x14) + 0x1c))
              (*(int **)(param_1 + 0x14),param_2,0,param_3,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8),local_10 + *(int *)(param_1 + 4),
               local_14 + *(int *)(param_1 + 8));
  }
  return;
}



/* @0046a758 file=? name=FUN_0046a758 */

void FUN_0046a758(void)

{
  return;
}



/* @0046a760 file=? name=FUN_0046a760 */

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

{
  int iVar1;
  int local_c;
  int local_8;
  
  if (((*(int *)(param_1 + 0x14) != 0) && (param_7 != 0)) && (*(int *)(param_7 + 0x18) != 0)) {
    FUN_0046aa18(param_1,&local_8,&local_c,param_5,param_6);
    for (iVar1 = param_4 + *(int *)(param_1 + 0x28); iVar1 < 0; iVar1 = iVar1 + 0x168) {
    }
    for (; 0x167 < iVar1; iVar1 = iVar1 + -0x168) {
    }
    (**(code **)(**(int **)(param_1 + 0x14) + 0x24))
              (*(int **)(param_1 + 0x14),param_2,0,param_3,iVar1,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8),param_7,param_8,param_9,param_10,param_11);
  }
  return;
}



/* @0046a80c file=? name=FUN_0046a80c */

void __cdecl
FUN_0046a80c(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,int param_5,
            int param_6,int param_7,int param_8,undefined4 param_9,undefined4 param_10,
            undefined4 param_11,undefined4 param_12)

{
  int iVar1;
  int local_c;
  int local_8;
  
  if (((*(int *)(param_1 + 0x14) != 0) && (param_8 != 0)) && (*(int *)(param_8 + 0x18) != 0)) {
    FUN_0046aa18(param_1,&local_8,&local_c,param_6,param_7);
    for (iVar1 = param_5 + *(int *)(param_1 + 0x28); iVar1 < 0; iVar1 = iVar1 + 0x168) {
    }
    for (; 0x167 < iVar1; iVar1 = iVar1 + -0x168) {
    }
    (**(code **)(**(int **)(param_1 + 0x14) + 0x28))
              (*(int **)(param_1 + 0x14),param_2,param_3,0,param_4,iVar1,
               local_8 + *(int *)(param_1 + 4),local_c + *(int *)(param_1 + 8),param_8,param_9,
               param_10,param_11,param_12);
  }
  return;
}



/* @0046a8bc file=? name=FUN_0046a8bc */

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

{
  int iVar1;
  int local_c;
  int local_8;
  
  if (((*(int *)(param_1 + 0x14) != 0) && (param_7 != 0)) && (*(int *)(param_7 + 8) != 0)) {
    FUN_0046aa18(param_1,&local_8,&local_c,param_5,param_6);
    for (iVar1 = param_4 + *(int *)(param_1 + 0x28); iVar1 < 0; iVar1 = iVar1 + 0x168) {
    }
    for (; 0x167 < iVar1; iVar1 = iVar1 + -0x168) {
    }
    (**(code **)(**(int **)(param_1 + 0x14) + 0x2c))
              (*(int **)(param_1 + 0x14),0,0,param_2,param_3,iVar1,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8),param_7,param_8,param_9,param_10,param_11);
  }
  return;
}



/* @0046a96c file=? name=FUN_0046a96c */

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

{
  int iVar1;
  int local_c;
  int local_8;
  
  if (((*(int *)(param_1 + 0x14) != 0) && (param_7 != 0)) && (*(int *)(param_7 + 8) != 0)) {
    FUN_0046aa18(param_1,&local_8,&local_c,param_5,param_6);
    for (iVar1 = param_4 + *(int *)(param_1 + 0x28); iVar1 < 0; iVar1 = iVar1 + 0x168) {
    }
    for (; 0x167 < iVar1; iVar1 = iVar1 + -0x168) {
    }
    (**(code **)(**(int **)(param_1 + 0x14) + 0x30))
              (*(int **)(param_1 + 0x14),param_2,0,param_3,iVar1,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8),param_7,param_8,param_9,param_10,param_11);
  }
  return;
}



/* @0046aa18 file=? name=FUN_0046aa18 */

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

{
  int iVar1;
  
  iVar1 = *(int *)(param_1 + 0x28);
  if (iVar1 == 0x5a) {
    *param_2 = param_5;
    *param_3 = *(int *)(param_1 + 0x30) - param_4;
  }
  else if (iVar1 == 0xb4) {
    *param_2 = *(int *)(param_1 + 0x2c) - param_4;
    *param_3 = *(int *)(param_1 + 0x30) - param_5;
  }
  else if (iVar1 == 0x10e) {
    *param_2 = *(int *)(param_1 + 0x2c) - param_5;
    *param_3 = param_4;
  }
  else {
    *param_2 = param_4;
    *param_3 = param_5;
  }
  return;
}



/* @0046aa78 file=? name=FUN_0046aa78 */

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

{
  param_1[2] = param_2;
  param_1[1] = param_3;
  *param_1 = 0;
  return;
}



/* @0046aa90 file=? name=FUN_0046aa90 */

void __cdecl FUN_0046aa90(uint *param_1)

{
  *param_1 = *param_1 & ~param_1[2];
  return;
}



/* @0046aaa0 file=? name=FUN_0046aaa0 */

void __cdecl FUN_0046aaa0(uint *param_1)

{
  *param_1 = *param_1 & param_1[2];
  return;
}



/* @0046aab0 file=? name=FUN_0046aab0 */

undefined4 __cdecl FUN_0046aab0(uint *param_1)

{
  uint uVar1;
  uint uVar2;
  
  uVar2 = param_1[1];
  uVar1 = 1;
  while( true ) {
    if ((int)uVar2 < 1) {
      return 0;
    }
    if (((param_1[2] & uVar1) != 0) && (*param_1 = *param_1 ^ uVar1, (*param_1 & uVar1) != 0))
    break;
    uVar2 = uVar2 - 1;
    uVar1 = uVar1 * 2;
  }
  return 1;
}



/* @0046aae0 file=? name=FUN_0046aae0 */

undefined4 __cdecl FUN_0046aae0(uint *param_1)

{
  uint uVar1;
  uint uVar2;
  
  uVar1 = 1;
  uVar2 = param_1[1];
  while( true ) {
    if ((int)uVar2 < 1) {
      return 0;
    }
    if (((uVar1 & ~param_1[2]) != 0) && (*param_1 = *param_1 ^ uVar1, (*param_1 & uVar1) != 0))
    break;
    uVar2 = uVar2 - 1;
    uVar1 = uVar1 * 2;
  }
  return 1;
}



/* @0046ab18 file=? name=FUN_0046ab18 */

int __cdecl FUN_0046ab18(int param_1)

{
  uint uVar1;
  int iVar2;
  
  iVar2 = 0;
  for (uVar1 = *(uint *)(param_1 + 8); uVar1 != 0; uVar1 = uVar1 & uVar1 - 1) {
    iVar2 = iVar2 + 1;
  }
  return iVar2;
}



/* @0046ab38 file=? name=FUN_0046ab38 */

int __cdecl FUN_0046ab38(int param_1)

{
  int iVar1;
  
  iVar1 = FUN_0046ab18(param_1);
  return *(int *)(param_1 + 4) - iVar1;
}



/* @0046ab50 file=? name=FUN_0046ab50 */

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

{
  undefined4 uVar1;
  undefined4 *puVar2;
  int iVar3;
  
  FUN_0044a078(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f4d70;
  FUN_00449ed0(param_1 + 0xb,param_2,param_3);
  param_1[8] = param_3;
  param_1[6] = param_2;
  param_1[7] = param_2 >> 5;
  iVar3 = param_1[8] * (param_2 >> 5);
  param_1[10] = param_1[8] + -1;
  param_1[9] = param_1[6] + -1;
  uVar1 = FUN_004022b0(param_1[8]);
  param_1[0xe] = uVar1;
  uVar1 = FUN_004022b0(iVar3 * 4);
  param_1[0xf] = uVar1;
  if ((param_1[0xe] == 0) || (param_1[0xf] == 0)) {
    param_1[5] = 0;
  }
  else {
    param_1[5] = 1;
    FUN_004d4988((undefined4 *)param_1[0xe],0,param_1[8]);
    puVar2 = (undefined4 *)param_1[0xf];
    for (; 0 < iVar3; iVar3 = iVar3 + -1) {
      *puVar2 = 0;
      puVar2 = puVar2 + 1;
    }
  }
  return param_1;
}



/* @0046ac08 file=? name=FUN_0046ac08 */

void __cdecl FUN_0046ac08(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f4d70;
    if ((int *)param_1[0xe] != (int *)0x0) {
      FUN_004022d0((int *)param_1[0xe]);
      param_1[0xe] = 0;
    }
    if ((int *)param_1[0xf] != (int *)0x0) {
      FUN_004022d0((int *)param_1[0xf]);
      param_1[0xf] = 0;
    }
    FUN_00449f30(param_1 + 0xb,2);
    FUN_0044a0ac(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0046ac68 file=? name=FUN_0046ac68 */

undefined4 FUN_0046ac68(void)

{
  return 1;
}



/* @0046ac74 file=? name=FUN_0046ac74 */

void __cdecl FUN_0046ac74(int param_1,char *param_2)

{
  char cVar1;
  int *piVar2;
  uint uVar3;
  uint uVar4;
  char *pcVar5;
  char *pcVar6;
  undefined8 uVar7;
  char local_54 [80];
  
  FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_Video16BitBuffered__004f4b3c,(char *)0x0);
  uVar3 = 0xffffffff;
  do {
    pcVar5 = param_2;
    if (uVar3 == 0) break;
    uVar3 = uVar3 - 1;
    pcVar5 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar5;
  } while (cVar1 != '\0');
  uVar3 = ~uVar3;
  pcVar5 = pcVar5 + -uVar3;
  pcVar6 = local_54;
  for (uVar4 = uVar3 >> 2; uVar4 != 0; uVar4 = uVar4 - 1) {
    *(undefined4 *)pcVar6 = *(undefined4 *)pcVar5;
    pcVar5 = pcVar5 + 4;
    pcVar6 = pcVar6 + 4;
  }
  for (uVar3 = uVar3 & 3; uVar3 != 0; uVar3 = uVar3 - 1) {
    *pcVar6 = *pcVar5;
    pcVar5 = pcVar5 + 1;
    pcVar6 = pcVar6 + 1;
  }
  FUN_004d49b8(local_54,&DAT_004f4b51);
  uVar3 = *(uint *)(param_1 + 0x18);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_width___004f4b55,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4b62,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x20);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_height___004f4b64,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4b71,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x24);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_maximumX___004f4b73,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4b80,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x28);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_maximumY___004f4b82,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4b8f,(char *)0x0);
  pcVar5 = *(char **)(param_1 + 0x38);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_changedLine__004f4b91,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,pcVar5,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,&DAT_004f4b9e,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x3c);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_changedBit___004f4ba0,(char *)0x0);
  uVar7 = FUN_004dbd4c(&DAT_00524e20,uVar3);
  FUN_004dbb24((int *)uVar7,&DAT_004f4bad,(char *)0x0);
  FUN_00449f74((uint *)(param_1 + 0x2c),local_54);
  FUN_0044a0cc(param_1,local_54);
  return;
}



/* @0046aec4 file=? name=FUN_0046aec4 */

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

{
  *param_4 = param_2 * 2 + *(int *)(param_1 + 0x34) + param_3 * *(int *)(param_1 + 0x18) * 2;
  *param_5 = (param_2 >> 5) * 4 + *(int *)(param_1 + 0x3c) + param_3 * *(int *)(param_1 + 0x1c) * 4;
  *param_6 = 1 << (0x1f - ((byte)param_2 & 0x1f) & 0x1f);
  return;
}



/* @0046af20 file=? name=FUN_0046af20 */

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

{
  int iVar1;
  
  iVar1 = param_2;
  if (param_3 < param_2) {
    iVar1 = param_3;
    param_3 = param_2;
  }
  FUN_004d4988((undefined4 *)(iVar1 + *(int *)(param_1 + 0x38)),1,(param_3 - iVar1) + 1);
  return;
}



/* @0046af50 file=? name=FUN_0046af50 */

void __cdecl
FUN_0046af50(int param_1,ushort param_2,ushort param_3,int param_4,int param_5,int param_6)

{
  int iVar1;
  uint local_10;
  uint *local_c;
  ushort *local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar1 = *(int *)(param_1 + 0x28) - param_6;
    FUN_0046af20(param_1,iVar1,iVar1);
    FUN_0046aec4(param_1,param_5,iVar1,(int *)&local_8,(int *)&local_c,(int *)&local_10);
    if (param_4 == 0) {
      *local_8 = *local_8 & ~param_3 | param_2;
    }
    else if (param_4 == 1) {
      *local_8 = *local_8 & param_2;
    }
    else if (param_4 == 2) {
      *local_8 = *local_8 | param_2;
    }
    else if (param_4 == 3) {
      *local_8 = *local_8 ^ param_2;
    }
    *local_c = *local_c | local_10;
    DAT_00522cbc = DAT_00522cbc + 1;
  }
  return;
}



/* @0046aff8 file=? name=FUN_0046aff8 */

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

{
  int iVar1;
  int iVar2;
  int iVar3;
  bool bVar4;
  uint local_18;
  uint *local_14;
  ushort *local_10;
  int local_c;
  uint local_8;
  
  if (param_1[5] != 0) {
    if ((param_7 == param_5) && (param_6 == param_8)) {
      if (param_9 != 0) {
        (**(code **)(*param_1 + 0x14))(param_1,param_2,param_3,param_4,param_5,param_6);
      }
    }
    else {
      iVar2 = param_1[10] - param_6;
      iVar1 = param_1[10] - param_8;
      FUN_0046af20((int)param_1,iVar2,iVar1);
      param_3._0_2_ = ~(ushort)param_3;
      iVar3 = param_7 - param_5;
      bVar4 = iVar3 < 0;
      if (bVar4) {
        iVar3 = -iVar3;
      }
      local_8 = (uint)bVar4;
      local_c = iVar1 - iVar2;
      if (local_c < 0) {
        local_8 = local_8 | 2;
        local_c = -local_c;
      }
      if (local_c < iVar3) {
        local_8 = local_8 | 4;
      }
      FUN_0046aec4((int)param_1,param_5,iVar2,(int *)&local_10,(int *)&local_14,(int *)&local_18);
      iVar1 = 0x400;
      switch(local_8) {
      case 0:
        iVar2 = local_c;
        if (param_9 == 0) {
          iVar2 = local_c + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = *local_10 & (ushort)param_3 | (ushort)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (ushort)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (ushort)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (ushort)param_2;
          }
          *local_14 = *local_14 | local_18;
          DAT_00522cbc = DAT_00522cbc + 1;
          local_10 = local_10 + param_1[6];
          local_14 = local_14 + param_1[7];
          iVar1 = iVar1 + (iVar3 << 0xb) / local_c;
          if (0x800 < iVar1) {
            local_10 = local_10 + 1;
            local_18 = local_18 >> 1;
            iVar1 = iVar1 + -0x800;
            if (local_18 == 0) {
              local_14 = local_14 + 1;
              local_18 = 0x80000000;
            }
          }
        }
        break;
      case 1:
        iVar2 = local_c;
        if (param_9 == 0) {
          iVar2 = local_c + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = *local_10 & (ushort)param_3 | (ushort)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (ushort)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (ushort)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (ushort)param_2;
          }
          *local_14 = *local_14 | local_18;
          DAT_00522cbc = DAT_00522cbc + 1;
          local_10 = local_10 + param_1[6];
          local_14 = local_14 + param_1[7];
          iVar1 = iVar1 + (iVar3 << 0xb) / local_c;
          if (0x800 < iVar1) {
            local_10 = local_10 + -1;
            local_18 = local_18 << 1;
            iVar1 = iVar1 + -0x800;
            if (local_18 == 0) {
              local_14 = local_14 + -1;
              local_18 = 1;
            }
          }
        }
        break;
      case 2:
        iVar2 = local_c;
        if (param_9 == 0) {
          iVar2 = local_c + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = *local_10 & (ushort)param_3 | (ushort)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (ushort)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (ushort)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (ushort)param_2;
          }
          *local_14 = *local_14 | local_18;
          DAT_00522cbc = DAT_00522cbc + 1;
          local_10 = local_10 + -param_1[6];
          local_14 = local_14 + -param_1[7];
          iVar1 = iVar1 + (iVar3 << 0xb) / local_c;
          if (0x800 < iVar1) {
            local_10 = local_10 + 1;
            local_18 = local_18 >> 1;
            iVar1 = iVar1 + -0x800;
            if (local_18 == 0) {
              local_14 = local_14 + 1;
              local_18 = 0x80000000;
            }
          }
        }
        break;
      case 3:
        iVar2 = local_c;
        if (param_9 == 0) {
          iVar2 = local_c + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = *local_10 & (ushort)param_3 | (ushort)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (ushort)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (ushort)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (ushort)param_2;
          }
          *local_14 = *local_14 | local_18;
          DAT_00522cbc = DAT_00522cbc + 1;
          local_10 = local_10 + -param_1[6];
          local_14 = local_14 + -param_1[7];
          iVar1 = iVar1 + (iVar3 << 0xb) / local_c;
          if (0x800 < iVar1) {
            local_10 = local_10 + -1;
            local_18 = local_18 << 1;
            iVar1 = iVar1 + -0x800;
            if (local_18 == 0) {
              local_14 = local_14 + -1;
              local_18 = 1;
            }
          }
        }
        break;
      case 4:
        iVar2 = iVar3;
        if (param_9 == 0) {
          iVar2 = iVar3 + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = *local_10 & (ushort)param_3 | (ushort)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (ushort)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (ushort)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (ushort)param_2;
          }
          *local_14 = *local_14 | local_18;
          local_10 = local_10 + 1;
          local_18 = local_18 >> 1;
          DAT_00522cbc = DAT_00522cbc + 1;
          if (local_18 == 0) {
            local_14 = local_14 + 1;
            local_18 = 0x80000000;
          }
          iVar1 = iVar1 + (local_c << 0xb) / iVar3;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + param_1[6];
            local_14 = local_14 + param_1[7];
          }
        }
        break;
      case 5:
        iVar2 = iVar3;
        if (param_9 == 0) {
          iVar2 = iVar3 + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = *local_10 & (ushort)param_3 | (ushort)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (ushort)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (ushort)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (ushort)param_2;
          }
          *local_14 = *local_14 | local_18;
          local_10 = local_10 + -1;
          local_18 = local_18 << 1;
          DAT_00522cbc = DAT_00522cbc + 1;
          if (local_18 == 0) {
            local_14 = local_14 + -1;
            local_18 = 1;
          }
          iVar1 = iVar1 + (local_c << 0xb) / iVar3;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + param_1[6];
            local_14 = local_14 + param_1[7];
          }
        }
        break;
      case 6:
        iVar2 = iVar3;
        if (param_9 == 0) {
          iVar2 = iVar3 + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = *local_10 & (ushort)param_3 | (ushort)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (ushort)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (ushort)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (ushort)param_2;
          }
          *local_14 = *local_14 | local_18;
          local_10 = local_10 + 1;
          local_18 = local_18 >> 1;
          DAT_00522cbc = DAT_00522cbc + 1;
          if (local_18 == 0) {
            local_14 = local_14 + 1;
            local_18 = 0x80000000;
          }
          iVar1 = iVar1 + (local_c << 0xb) / iVar3;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + -param_1[6];
            local_14 = local_14 + -param_1[7];
          }
        }
        break;
      case 7:
        iVar2 = iVar3;
        if (param_9 == 0) {
          iVar2 = iVar3 + -1;
        }
        for (; 0 < iVar2; iVar2 = iVar2 + -1) {
          if (param_4 == 0) {
            *local_10 = *local_10 & (ushort)param_3 | (ushort)param_2;
          }
          else if (param_4 == 1) {
            *local_10 = *local_10 & (ushort)param_2;
          }
          else if (param_4 == 2) {
            *local_10 = *local_10 | (ushort)param_2;
          }
          else if (param_4 == 3) {
            *local_10 = *local_10 ^ (ushort)param_2;
          }
          *local_14 = *local_14 | local_18;
          local_10 = local_10 + -1;
          local_18 = local_18 << 1;
          DAT_00522cbc = DAT_00522cbc + 1;
          if (local_18 == 0) {
            local_14 = local_14 + -1;
            local_18 = 1;
          }
          iVar1 = iVar1 + (local_c << 0xb) / iVar3;
          if (0x800 < iVar1) {
            iVar1 = iVar1 + -0x800;
            local_10 = local_10 + -param_1[6];
            local_14 = local_14 + -param_1[7];
          }
        }
      }
    }
  }
  return;
}



/* @0046b6d4 file=? name=FUN_0046b6d4 */

void __cdecl
FUN_0046b6d4(int param_1,ushort param_2,ushort param_3,int param_4,int param_5,int param_6,
            int param_7,int param_8)

{
  uint *puVar1;
  int iVar2;
  uint uVar3;
  int iVar4;
  int iVar5;
  int iVar6;
  uint local_10;
  uint *local_c;
  ushort *local_8;
  
  iVar6 = param_5;
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar2 = *(int *)(param_1 + 0x28) - param_8;
    iVar4 = *(int *)(param_1 + 0x28) - param_6;
    if (param_7 < param_5) {
      param_5 = param_7;
      param_7 = iVar6;
    }
    iVar6 = iVar4;
    if (iVar2 < iVar4) {
      iVar6 = iVar2;
      iVar2 = iVar4;
    }
    FUN_0046af20(param_1,iVar6,iVar2);
    param_3 = ~param_3;
    FUN_0046aec4(param_1,param_5,iVar6,(int *)&local_8,(int *)&local_c,(int *)&local_10);
    iVar6 = (iVar2 - iVar6) + 1;
    iVar2 = (param_7 - param_5) + 1;
    iVar4 = *(int *)(param_1 + 0x18) - iVar2;
    if (param_4 == 0) {
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        puVar1 = local_c + *(int *)(param_1 + 0x1c);
        uVar3 = local_10;
        for (iVar5 = iVar2; 0 < iVar5; iVar5 = iVar5 + -1) {
          *local_8 = *local_8 & param_3 | param_2;
          local_8 = local_8 + 1;
          *local_c = *local_c | uVar3;
          DAT_00522cbc = DAT_00522cbc + 1;
          uVar3 = uVar3 >> 1;
          if (uVar3 == 0) {
            local_c = local_c + 1;
            uVar3 = 0x80000000;
          }
        }
        local_8 = local_8 + iVar4;
        local_c = puVar1;
      }
    }
    else if (param_4 == 1) {
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        puVar1 = local_c + *(int *)(param_1 + 0x1c);
        uVar3 = local_10;
        for (iVar5 = iVar2; 0 < iVar5; iVar5 = iVar5 + -1) {
          *local_8 = *local_8 & param_2;
          local_8 = local_8 + 1;
          *local_c = *local_c | uVar3;
          DAT_00522cbc = DAT_00522cbc + 1;
          uVar3 = uVar3 >> 1;
          if (uVar3 == 0) {
            local_c = local_c + 1;
            uVar3 = 0x80000000;
          }
        }
        local_8 = local_8 + iVar4;
        local_c = puVar1;
      }
    }
    else if (param_4 == 2) {
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        puVar1 = local_c + *(int *)(param_1 + 0x1c);
        uVar3 = local_10;
        for (iVar5 = iVar2; 0 < iVar5; iVar5 = iVar5 + -1) {
          *local_8 = *local_8 | param_2;
          local_8 = local_8 + 1;
          *local_c = *local_c | uVar3;
          DAT_00522cbc = DAT_00522cbc + 1;
          uVar3 = uVar3 >> 1;
          if (uVar3 == 0) {
            local_c = local_c + 1;
            uVar3 = 0x80000000;
          }
        }
        local_8 = local_8 + iVar4;
        local_c = puVar1;
      }
    }
    else if (param_4 == 3) {
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        puVar1 = local_c + *(int *)(param_1 + 0x1c);
        uVar3 = local_10;
        for (iVar5 = iVar2; 0 < iVar5; iVar5 = iVar5 + -1) {
          *local_8 = *local_8 ^ param_2;
          local_8 = local_8 + 1;
          *local_c = *local_c | uVar3;
          DAT_00522cbc = DAT_00522cbc + 1;
          uVar3 = uVar3 >> 1;
          if (uVar3 == 0) {
            local_c = local_c + 1;
            uVar3 = 0x80000000;
          }
        }
        local_8 = local_8 + iVar4;
        local_c = puVar1;
      }
    }
  }
  return;
}



/* @0046b91c file=? name=FUN_0046b91c */

undefined4 __cdecl FUN_0046b91c(int param_1)

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



/* @0046b92c file=? name=FUN_0046b92c */

void __cdecl
FUN_0046b92c(int param_1,ushort param_2,ushort param_3,int param_4,int param_5,int param_6,
            int param_7,int param_8,int param_9,int param_10,int param_11,int param_12)

{
  ushort *puVar1;
  uint *puVar2;
  uint uVar3;
  uint uVar4;
  int iVar5;
  int iVar6;
  int iVar7;
  uint *local_28;
  uint *local_24;
  uint local_20;
  ushort *local_1c;
  ushort *local_18;
  ushort *local_14;
  uint local_10;
  uint local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar5 = *(int *)(param_1 + 0x28) - param_7;
    iVar6 = *(int *)(param_8 + 0x10) + -1;
    iVar7 = iVar6 - param_10;
    local_8 = (param_11 - param_9) + 1;
    param_3 = ~param_3;
    iVar6 = (iVar7 - (iVar6 - param_12)) + 1;
    local_14 = (ushort *)
               (*(int *)(param_8 + 0x18) + (param_9 >> 4) * 2 + *(int *)(param_8 + 0x14) * iVar7 * 2
               );
    local_10 = 1 << (0xf - ((byte)param_9 & 0xf) & 0x1f);
    FUN_0046aec4(param_1,param_6,iVar5,(int *)&local_1c,(int *)&local_24,(int *)&local_20);
    if (param_5 == 0x5a) {
      FUN_0046af20(param_1,iVar5,iVar5 + local_8);
      puVar2 = local_24;
      uVar4 = local_20;
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        iVar5 = *(int *)(param_8 + 0x14);
        local_20 = uVar4 >> 1;
        local_24 = puVar2;
        if (local_20 == 0) {
          local_24 = puVar2 + 1;
          local_20 = 0x80000000;
        }
        puVar1 = local_1c + 1;
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar3 = local_10;
        for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
          if (uVar3 == 0) {
            uVar3 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          if ((local_c & uVar3) != 0) {
            if (param_4 == 0) {
              *local_1c = *local_1c & param_3 | param_2;
            }
            else if (param_4 == 1) {
              *local_1c = *local_1c & param_2;
            }
            else if (param_4 == 2) {
              *local_1c = *local_1c | param_2;
            }
            else if (param_4 == 3) {
              *local_1c = *local_1c ^ param_2;
            }
            *puVar2 = *puVar2 | uVar4;
            DAT_00522cbc = DAT_00522cbc + 1;
          }
          uVar3 = (int)uVar3 >> 1;
          puVar2 = puVar2 + *(int *)(param_1 + 0x1c);
          local_1c = local_1c + *(int *)(param_1 + 0x18);
        }
        puVar2 = local_24;
        uVar4 = local_20;
        local_1c = puVar1;
        local_14 = local_14 + -iVar5;
      }
    }
    else if (param_5 == 0xb4) {
      FUN_0046af20(param_1,iVar5,iVar5 + iVar6);
      local_28 = local_24;
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        iVar5 = *(int *)(param_8 + 0x14);
        puVar2 = local_28 + *(int *)(param_1 + 0x1c);
        puVar1 = local_1c + *(int *)(param_1 + 0x18);
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar4 = local_20;
        uVar3 = local_10;
        for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
          if (uVar3 == 0) {
            uVar3 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          if ((local_c & uVar3) != 0) {
            if (param_4 == 0) {
              *local_1c = *local_1c & param_3 | param_2;
            }
            else if (param_4 == 1) {
              *local_1c = *local_1c & param_2;
            }
            else if (param_4 == 2) {
              *local_1c = *local_1c | param_2;
            }
            else if (param_4 == 3) {
              *local_1c = *local_1c ^ param_2;
            }
            *local_28 = *local_28 | uVar4;
            DAT_00522cbc = DAT_00522cbc + 1;
          }
          uVar4 = uVar4 * 2;
          if (uVar4 == 0) {
            local_28 = local_28 + -1;
            uVar4 = 1;
          }
          local_1c = local_1c + -1;
          uVar3 = (int)uVar3 >> 1;
        }
        local_28 = puVar2;
        local_1c = puVar1;
        local_14 = local_14 + -iVar5;
      }
    }
    else if (param_5 == 0x10e) {
      if (-1 < param_6 - iVar6) {
        FUN_0046af20(param_1,iVar5 - (local_8 + -1),iVar5);
        puVar2 = local_24;
        uVar4 = local_20;
        for (; 0 < iVar6; iVar6 = iVar6 + -1) {
          iVar5 = *(int *)(param_8 + 0x14);
          local_20 = uVar4 << 1;
          local_24 = puVar2;
          if (local_20 == 0) {
            local_24 = puVar2 + -1;
            local_20 = 1;
          }
          puVar1 = local_1c + -1;
          local_c = (uint)*local_14;
          local_18 = local_14 + 1;
          uVar3 = local_10;
          for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
            if (uVar3 == 0) {
              uVar3 = 0x8000;
              local_c = (uint)*local_18;
              local_18 = local_18 + 1;
            }
            if ((local_c & uVar3) != 0) {
              if (param_4 == 0) {
                *local_1c = *local_1c & param_3 | param_2;
              }
              else if (param_4 == 1) {
                *local_1c = *local_1c & param_2;
              }
              else if (param_4 == 2) {
                *local_1c = *local_1c | param_2;
              }
              else if (param_4 == 3) {
                *local_1c = *local_1c ^ param_2;
              }
              *puVar2 = *puVar2 | uVar4;
              DAT_00522cbc = DAT_00522cbc + 1;
            }
            uVar3 = (int)uVar3 >> 1;
            puVar2 = puVar2 + -*(int *)(param_1 + 0x1c);
            local_1c = local_1c + -*(int *)(param_1 + 0x18);
          }
          puVar2 = local_24;
          uVar4 = local_20;
          local_1c = puVar1;
          local_14 = local_14 + -iVar5;
        }
      }
    }
    else {
      FUN_0046af20(param_1,(iVar5 - iVar6) + 1,iVar5);
      local_28 = local_24;
      for (; 0 < iVar6; iVar6 = iVar6 + -1) {
        iVar5 = *(int *)(param_8 + 0x14);
        puVar2 = local_28 + -*(int *)(param_1 + 0x1c);
        puVar1 = local_1c + -*(int *)(param_1 + 0x18);
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar4 = local_20;
        uVar3 = local_10;
        for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
          if (uVar3 == 0) {
            uVar3 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          if ((local_c & uVar3) != 0) {
            if (param_4 == 0) {
              *local_1c = *local_1c & param_3 | param_2;
            }
            else if (param_4 == 1) {
              *local_1c = *local_1c & param_2;
            }
            else if (param_4 == 2) {
              *local_1c = *local_1c | param_2;
            }
            else if (param_4 == 3) {
              *local_1c = *local_1c ^ param_2;
            }
            *local_28 = *local_28 | uVar4;
            DAT_00522cbc = DAT_00522cbc + 1;
          }
          uVar4 = uVar4 >> 1;
          if (uVar4 == 0) {
            local_28 = local_28 + 1;
            uVar4 = 0x80000000;
          }
          local_1c = local_1c + 1;
          uVar3 = (int)uVar3 >> 1;
        }
        local_28 = puVar2;
        local_1c = puVar1;
        local_14 = local_14 + -iVar5;
      }
    }
  }
  return;
}



/* @0046bdfc file=? name=FUN_0046bdfc */

void __cdecl
FUN_0046bdfc(int param_1,ushort param_2,ushort param_3,ushort param_4,int param_5,int param_6,
            int param_7,int param_8,int param_9,int param_10,int param_11,int param_12,int param_13)

{
  ushort *puVar1;
  uint *puVar2;
  uint uVar3;
  ushort uVar4;
  uint uVar5;
  int iVar6;
  int iVar7;
  int iVar8;
  uint *local_2c;
  uint *local_28;
  uint local_24 [2];
  ushort *local_1c;
  ushort *local_18;
  ushort *local_14;
  uint local_10;
  uint local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar6 = *(int *)(param_1 + 0x28) - param_8;
    iVar7 = *(int *)(param_9 + 0x10) + -1;
    iVar8 = iVar7 - param_11;
    local_8 = (param_12 - param_10) + 1;
    param_4 = ~param_4;
    iVar7 = (iVar8 - (iVar7 - param_13)) + 1;
    local_14 = (ushort *)
               (*(int *)(param_9 + 0x18) + (param_10 >> 4) * 2 +
               *(int *)(param_9 + 0x14) * iVar8 * 2);
    local_10 = 1 << (0xf - ((byte)param_10 & 0xf) & 0x1f);
    FUN_0046aec4(param_1,param_7,iVar6,(int *)&local_1c,(int *)&local_28,(int *)local_24);
    if (param_6 == 0x5a) {
      FUN_0046af20(param_1,iVar6,iVar6 + local_8);
      puVar2 = local_28;
      uVar5 = local_24[0];
      for (; 0 < iVar7; iVar7 = iVar7 + -1) {
        iVar6 = *(int *)(param_9 + 0x14);
        local_24[0] = uVar5 >> 1;
        local_28 = puVar2;
        if (local_24[0] == 0) {
          local_28 = puVar2 + 1;
          local_24[0] = 0x80000000;
        }
        puVar1 = local_1c + 1;
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar3 = local_10;
        for (iVar8 = local_8; 0 < iVar8; iVar8 = iVar8 + -1) {
          if (uVar3 == 0) {
            uVar3 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          uVar4 = param_3;
          if ((local_c & uVar3) != 0) {
            uVar4 = param_2;
          }
          if (param_5 == 0) {
            *local_1c = uVar4 | *local_1c & param_4;
          }
          else if (param_5 == 1) {
            *local_1c = *local_1c & uVar4;
          }
          else if (param_5 == 2) {
            *local_1c = *local_1c | uVar4;
          }
          else if (param_5 == 3) {
            *local_1c = *local_1c ^ uVar4;
          }
          uVar3 = (int)uVar3 >> 1;
          *puVar2 = *puVar2 | uVar5;
          DAT_00522cbc = DAT_00522cbc + 1;
          puVar2 = puVar2 + *(int *)(param_1 + 0x1c);
          local_1c = local_1c + *(int *)(param_1 + 0x18);
        }
        puVar2 = local_28;
        uVar5 = local_24[0];
        local_1c = puVar1;
        local_14 = local_14 + -iVar6;
      }
    }
    else if (param_6 == 0xb4) {
      FUN_0046af20(param_1,iVar6,iVar6 + iVar7);
      local_2c = local_28;
      for (; 0 < iVar7; iVar7 = iVar7 + -1) {
        iVar6 = *(int *)(param_9 + 0x14);
        puVar2 = local_2c + *(int *)(param_1 + 0x1c);
        puVar1 = local_1c + *(int *)(param_1 + 0x18);
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar5 = local_24[0];
        uVar3 = local_10;
        for (iVar8 = local_8; 0 < iVar8; iVar8 = iVar8 + -1) {
          if (uVar3 == 0) {
            uVar3 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          uVar4 = param_3;
          if ((local_c & uVar3) != 0) {
            uVar4 = param_2;
          }
          if (param_5 == 0) {
            *local_1c = uVar4 | *local_1c & param_4;
          }
          else if (param_5 == 1) {
            *local_1c = *local_1c & uVar4;
          }
          else if (param_5 == 2) {
            *local_1c = *local_1c | uVar4;
          }
          else if (param_5 == 3) {
            *local_1c = *local_1c ^ uVar4;
          }
          *local_2c = *local_2c | uVar5;
          DAT_00522cbc = DAT_00522cbc + 1;
          uVar5 = uVar5 * 2;
          if (uVar5 == 0) {
            local_2c = local_2c + -1;
            uVar5 = 1;
          }
          local_1c = local_1c + -1;
          uVar3 = (int)uVar3 >> 1;
        }
        local_2c = puVar2;
        local_1c = puVar1;
        local_14 = local_14 + -iVar6;
      }
    }
    else if (param_6 == 0x10e) {
      FUN_0046af20(param_1,iVar6 - (local_8 + -1),iVar6);
      puVar2 = local_28;
      uVar5 = local_24[0];
      for (; 0 < iVar7; iVar7 = iVar7 + -1) {
        iVar6 = *(int *)(param_9 + 0x14);
        local_24[0] = uVar5 << 1;
        local_28 = puVar2;
        if (local_24[0] == 0) {
          local_28 = puVar2 + -1;
          local_24[0] = 1;
        }
        puVar1 = local_1c + -1;
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar3 = local_10;
        for (iVar8 = local_8; 0 < iVar8; iVar8 = iVar8 + -1) {
          if (uVar3 == 0) {
            uVar3 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          uVar4 = param_3;
          if ((local_c & uVar3) != 0) {
            uVar4 = param_2;
          }
          if (param_5 == 0) {
            *local_1c = uVar4 | *local_1c & param_4;
          }
          else if (param_5 == 1) {
            *local_1c = *local_1c & uVar4;
          }
          else if (param_5 == 2) {
            *local_1c = *local_1c | uVar4;
          }
          else if (param_5 == 3) {
            *local_1c = *local_1c ^ uVar4;
          }
          uVar3 = (int)uVar3 >> 1;
          *puVar2 = *puVar2 | uVar5;
          DAT_00522cbc = DAT_00522cbc + 1;
          puVar2 = puVar2 + -*(int *)(param_1 + 0x1c);
          local_1c = local_1c + -*(int *)(param_1 + 0x18);
        }
        puVar2 = local_28;
        uVar5 = local_24[0];
        local_1c = puVar1;
        local_14 = local_14 + -iVar6;
      }
    }
    else {
      FUN_0046af20(param_1,(iVar6 - iVar7) + 1,iVar6);
      local_2c = local_28;
      for (; 0 < iVar7; iVar7 = iVar7 + -1) {
        iVar6 = *(int *)(param_9 + 0x14);
        puVar2 = local_2c + -*(int *)(param_1 + 0x1c);
        puVar1 = local_1c + -*(int *)(param_1 + 0x18);
        local_c = (uint)*local_14;
        local_18 = local_14 + 1;
        uVar5 = local_24[0];
        uVar3 = local_10;
        for (iVar8 = local_8; 0 < iVar8; iVar8 = iVar8 + -1) {
          if (uVar3 == 0) {
            uVar3 = 0x8000;
            local_c = (uint)*local_18;
            local_18 = local_18 + 1;
          }
          uVar4 = param_3;
          if ((local_c & uVar3) != 0) {
            uVar4 = param_2;
          }
          if (param_5 == 0) {
            *local_1c = uVar4 | *local_1c & param_4;
          }
          else if (param_5 == 1) {
            *local_1c = *local_1c & uVar4;
          }
          else if (param_5 == 2) {
            *local_1c = *local_1c | uVar4;
          }
          else if (param_5 == 3) {
            *local_1c = *local_1c ^ uVar4;
          }
          *local_2c = *local_2c | uVar5;
          DAT_00522cbc = DAT_00522cbc + 1;
          uVar5 = uVar5 >> 1;
          if (uVar5 == 0) {
            local_2c = local_2c + 1;
            uVar5 = 0x80000000;
          }
          local_1c = local_1c + 1;
          uVar3 = (int)uVar3 >> 1;
        }
        local_2c = puVar2;
        local_1c = puVar1;
        local_14 = local_14 + -iVar6;
      }
    }
  }
  return;
}



/* @0046c324 file=? name=FUN_0046c324 */

void __cdecl
FUN_0046c324(int param_1,int param_2,ushort param_3,int param_4,int param_5,int param_6,int param_7,
            int param_8,int *param_9,int param_10,int param_11,int param_12,int param_13)

{
  byte *pbVar1;
  ushort *puVar2;
  byte bVar3;
  ushort uVar4;
  uint *puVar5;
  uint uVar6;
  int iVar7;
  int iVar8;
  int iVar9;
  uint *local_20;
  uint *local_1c;
  uint local_18;
  ushort *local_14 [2];
  byte *local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar7 = *(int *)(param_1 + 0x28) - param_8;
    iVar8 = (param_9[1] + -1) - param_11;
    local_8 = (param_12 - param_10) + 1;
    param_3 = ~param_3;
    iVar9 = (iVar8 - ((param_9[1] + -1) - param_13)) + 1;
    local_c = (byte *)(param_10 + param_9[2] + *param_9 * iVar8);
    FUN_0046aec4(param_1,param_7,iVar7,(int *)local_14,(int *)&local_1c,(int *)&local_18);
    if (param_5 == 0) {
      if (param_6 == 0x5a) {
        FUN_0046af20(param_1,iVar7,iVar7 + local_8);
        puVar5 = local_1c;
        uVar6 = local_18;
        for (; 0 < iVar9; iVar9 = iVar9 + -1) {
          pbVar1 = local_c + -*param_9;
          local_18 = uVar6 >> 1;
          local_1c = puVar5;
          if (local_18 == 0) {
            local_1c = puVar5 + 1;
            local_18 = 0x80000000;
          }
          puVar2 = local_14[0] + 1;
          for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
            bVar3 = *local_c;
            local_c = local_c + 1;
            if (bVar3 != 0) {
              uVar4 = *(ushort *)(param_2 + (uint)bVar3 * 4);
              if (param_4 == 0) {
                *local_14[0] = uVar4 | *local_14[0] & param_3;
              }
              else if (param_4 == 1) {
                *local_14[0] = *local_14[0] & uVar4;
              }
              else if (param_4 == 2) {
                *local_14[0] = *local_14[0] | uVar4;
              }
              else if (param_4 == 3) {
                *local_14[0] = *local_14[0] ^ uVar4;
              }
              *puVar5 = *puVar5 | uVar6;
              DAT_00522cbc = DAT_00522cbc + 1;
            }
            puVar5 = puVar5 + *(int *)(param_1 + 0x1c);
            local_14[0] = local_14[0] + *(int *)(param_1 + 0x18);
          }
          puVar5 = local_1c;
          uVar6 = local_18;
          local_14[0] = puVar2;
          local_c = pbVar1;
        }
      }
      else if (param_6 == 0xb4) {
        FUN_0046af20(param_1,iVar7,iVar7 + iVar9);
        local_20 = local_1c;
        for (; 0 < iVar9; iVar9 = iVar9 + -1) {
          pbVar1 = local_c + -*param_9;
          puVar5 = local_20 + *(int *)(param_1 + 0x1c);
          puVar2 = local_14[0] + *(int *)(param_1 + 0x18);
          uVar6 = local_18;
          for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
            bVar3 = *local_c;
            local_c = local_c + 1;
            if (bVar3 != 0) {
              uVar4 = *(ushort *)(param_2 + (uint)bVar3 * 4);
              if (param_4 == 0) {
                *local_14[0] = uVar4 | *local_14[0] & param_3;
              }
              else if (param_4 == 1) {
                *local_14[0] = *local_14[0] & uVar4;
              }
              else if (param_4 == 2) {
                *local_14[0] = *local_14[0] | uVar4;
              }
              else if (param_4 == 3) {
                *local_14[0] = *local_14[0] ^ uVar4;
              }
              *local_20 = *local_20 | uVar6;
              DAT_00522cbc = DAT_00522cbc + 1;
            }
            uVar6 = uVar6 * 2;
            if (uVar6 == 0) {
              local_20 = local_20 + -1;
              uVar6 = 1;
            }
            local_14[0] = local_14[0] + -1;
          }
          local_20 = puVar5;
          local_14[0] = puVar2;
          local_c = pbVar1;
        }
      }
      else if (param_6 == 0x10e) {
        FUN_0046af20(param_1,iVar7 - (local_8 + -1),iVar7);
        puVar5 = local_1c;
        uVar6 = local_18;
        for (; 0 < iVar9; iVar9 = iVar9 + -1) {
          pbVar1 = local_c + -*param_9;
          local_18 = uVar6 << 1;
          local_1c = puVar5;
          if (local_18 == 0) {
            local_1c = puVar5 + -1;
            local_18 = 1;
          }
          puVar2 = local_14[0] + -1;
          for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
            bVar3 = *local_c;
            local_c = local_c + 1;
            if (bVar3 != 0) {
              uVar4 = *(ushort *)(param_2 + (uint)bVar3 * 4);
              if (param_4 == 0) {
                *local_14[0] = uVar4 | *local_14[0] & param_3;
              }
              else if (param_4 == 1) {
                *local_14[0] = *local_14[0] & uVar4;
              }
              else if (param_4 == 2) {
                *local_14[0] = *local_14[0] | uVar4;
              }
              else if (param_4 == 3) {
                *local_14[0] = *local_14[0] ^ uVar4;
              }
              *puVar5 = *puVar5 | uVar6;
              DAT_00522cbc = DAT_00522cbc + 1;
            }
            puVar5 = puVar5 + -*(int *)(param_1 + 0x1c);
            local_14[0] = local_14[0] + -*(int *)(param_1 + 0x18);
          }
          puVar5 = local_1c;
          uVar6 = local_18;
          local_14[0] = puVar2;
          local_c = pbVar1;
        }
      }
      else {
        FUN_0046af20(param_1,(iVar7 - iVar9) + 1,iVar7);
        local_20 = local_1c;
        for (; 0 < iVar9; iVar9 = iVar9 + -1) {
          pbVar1 = local_c + -*param_9;
          puVar5 = local_20 + -*(int *)(param_1 + 0x1c);
          puVar2 = local_14[0] + -*(int *)(param_1 + 0x18);
          uVar6 = local_18;
          for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
            bVar3 = *local_c;
            local_c = local_c + 1;
            if (bVar3 != 0) {
              uVar4 = *(ushort *)(param_2 + (uint)bVar3 * 4);
              if (param_4 == 0) {
                *local_14[0] = uVar4 | *local_14[0] & param_3;
              }
              else if (param_4 == 1) {
                *local_14[0] = *local_14[0] & uVar4;
              }
              else if (param_4 == 2) {
                *local_14[0] = *local_14[0] | uVar4;
              }
              else if (param_4 == 3) {
                *local_14[0] = *local_14[0] ^ uVar4;
              }
              *local_20 = *local_20 | uVar6;
              DAT_00522cbc = DAT_00522cbc + 1;
            }
            uVar6 = uVar6 >> 1;
            if (uVar6 == 0) {
              local_20 = local_20 + 1;
              uVar6 = 0x80000000;
            }
            local_14[0] = local_14[0] + 1;
          }
          local_20 = puVar5;
          local_14[0] = puVar2;
          local_c = pbVar1;
        }
      }
    }
    else if (param_6 == 0x5a) {
      FUN_0046af20(param_1,iVar7,iVar7 + local_8);
      puVar5 = local_1c;
      uVar6 = local_18;
      for (; 0 < iVar9; iVar9 = iVar9 + -1) {
        pbVar1 = local_c + -*param_9;
        local_18 = uVar6 >> 1;
        local_1c = puVar5;
        if (local_18 == 0) {
          local_1c = puVar5 + 1;
          local_18 = 0x80000000;
        }
        puVar2 = local_14[0] + 1;
        for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
          bVar3 = *local_c;
          local_c = local_c + 1;
          uVar4 = *(ushort *)(param_2 + (uint)bVar3 * 4);
          if (param_4 == 0) {
            *local_14[0] = uVar4 | *local_14[0] & param_3;
          }
          else if (param_4 == 1) {
            *local_14[0] = *local_14[0] & uVar4;
          }
          else if (param_4 == 2) {
            *local_14[0] = *local_14[0] | uVar4;
          }
          else if (param_4 == 3) {
            *local_14[0] = *local_14[0] ^ uVar4;
          }
          *puVar5 = *puVar5 | uVar6;
          DAT_00522cbc = DAT_00522cbc + 1;
          puVar5 = puVar5 + *(int *)(param_1 + 0x1c);
          local_14[0] = local_14[0] + *(int *)(param_1 + 0x18);
        }
        puVar5 = local_1c;
        uVar6 = local_18;
        local_14[0] = puVar2;
        local_c = pbVar1;
      }
    }
    else if (param_6 == 0xb4) {
      FUN_0046af20(param_1,iVar7,iVar7 + iVar9);
      local_20 = local_1c;
      for (; 0 < iVar9; iVar9 = iVar9 + -1) {
        pbVar1 = local_c + -*param_9;
        puVar5 = local_20 + *(int *)(param_1 + 0x1c);
        puVar2 = local_14[0] + *(int *)(param_1 + 0x18);
        uVar6 = local_18;
        for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
          bVar3 = *local_c;
          local_c = local_c + 1;
          uVar4 = *(ushort *)(param_2 + (uint)bVar3 * 4);
          if (param_4 == 0) {
            *local_14[0] = uVar4 | *local_14[0] & param_3;
          }
          else if (param_4 == 1) {
            *local_14[0] = *local_14[0] & uVar4;
          }
          else if (param_4 == 2) {
            *local_14[0] = *local_14[0] | uVar4;
          }
          else if (param_4 == 3) {
            *local_14[0] = *local_14[0] ^ uVar4;
          }
          *local_20 = *local_20 | uVar6;
          DAT_00522cbc = DAT_00522cbc + 1;
          uVar6 = uVar6 * 2;
          if (uVar6 == 0) {
            local_20 = local_20 + -1;
            uVar6 = 1;
          }
          local_14[0] = local_14[0] + -1;
        }
        local_20 = puVar5;
        local_14[0] = puVar2;
        local_c = pbVar1;
      }
    }
    else if (param_6 == 0x10e) {
      FUN_0046af20(param_1,iVar7 - (local_8 + -1),iVar7);
      puVar5 = local_1c;
      uVar6 = local_18;
      for (; 0 < iVar9; iVar9 = iVar9 + -1) {
        pbVar1 = local_c + -*param_9;
        local_18 = uVar6 << 1;
        local_1c = puVar5;
        if (local_18 == 0) {
          local_1c = puVar5 + -1;
          local_18 = 1;
        }
        puVar2 = local_14[0] + -1;
        for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
          bVar3 = *local_c;
          local_c = local_c + 1;
          uVar4 = *(ushort *)(param_2 + (uint)bVar3 * 4);
          if (param_4 == 0) {
            *local_14[0] = uVar4 | *local_14[0] & param_3;
          }
          else if (param_4 == 1) {
            *local_14[0] = *local_14[0] & uVar4;
          }
          else if (param_4 == 2) {
            *local_14[0] = *local_14[0] | uVar4;
          }
          else if (param_4 == 3) {
            *local_14[0] = *local_14[0] ^ uVar4;
          }
          *puVar5 = *puVar5 | uVar6;
          DAT_00522cbc = DAT_00522cbc + 1;
          puVar5 = puVar5 + -*(int *)(param_1 + 0x1c);
          local_14[0] = local_14[0] + -*(int *)(param_1 + 0x18);
        }
        puVar5 = local_1c;
        uVar6 = local_18;
        local_14[0] = puVar2;
        local_c = pbVar1;
      }
    }
    else {
      FUN_0046af20(param_1,(iVar7 - iVar9) + 1,iVar7);
      local_20 = local_1c;
      for (; 0 < iVar9; iVar9 = iVar9 + -1) {
        pbVar1 = local_c + -*param_9;
        puVar5 = local_20 + -*(int *)(param_1 + 0x1c);
        puVar2 = local_14[0] + -*(int *)(param_1 + 0x18);
        uVar6 = local_18;
        for (iVar7 = local_8; 0 < iVar7; iVar7 = iVar7 + -1) {
          bVar3 = *local_c;
          local_c = local_c + 1;
          uVar4 = *(ushort *)(param_2 + (uint)bVar3 * 4);
          if (param_4 == 0) {
            *local_14[0] = uVar4 | *local_14[0] & param_3;
          }
          else if (param_4 == 1) {
            *local_14[0] = *local_14[0] & uVar4;
          }
          else if (param_4 == 2) {
            *local_14[0] = *local_14[0] | uVar4;
          }
          else if (param_4 == 3) {
            *local_14[0] = *local_14[0] ^ uVar4;
          }
          *local_20 = *local_20 | uVar6;
          DAT_00522cbc = DAT_00522cbc + 1;
          uVar6 = uVar6 >> 1;
          if (uVar6 == 0) {
            local_20 = local_20 + 1;
            uVar6 = 0x80000000;
          }
          local_14[0] = local_14[0] + 1;
        }
        local_20 = puVar5;
        local_14[0] = puVar2;
        local_c = pbVar1;
      }
    }
  }
  return;
}



/* @0046cac4 file=? name=FUN_0046cac4 */

void __cdecl
FUN_0046cac4(int param_1,ushort param_2,ushort param_3,int param_4,int param_5,int param_6,
            int param_7,int *param_8,int param_9,int param_10,int param_11,int param_12)

{
  char *pcVar1;
  ushort *puVar2;
  char cVar3;
  uint *puVar4;
  uint uVar5;
  int iVar6;
  int iVar7;
  int iVar8;
  uint *local_20;
  uint *local_1c;
  uint local_18;
  ushort *local_14;
  char *local_10;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    iVar6 = *(int *)(param_1 + 0x28) - param_7;
    iVar7 = (param_8[1] + -1) - param_10;
    local_8 = (param_11 - param_9) + 1;
    param_3 = ~param_3;
    iVar8 = (iVar7 - ((param_8[1] + -1) - param_12)) + 1;
    local_10 = (char *)(param_9 + param_8[2] + *param_8 * iVar7);
    FUN_0046aec4(param_1,param_6,iVar6,(int *)&local_14,(int *)&local_1c,(int *)&local_18);
    if (param_5 == 0x5a) {
      FUN_0046af20(param_1,iVar6,iVar6 + local_8);
      puVar4 = local_1c;
      uVar5 = local_18;
      for (; 0 < iVar8; iVar8 = iVar8 + -1) {
        pcVar1 = local_10 + -*param_8;
        local_18 = uVar5 >> 1;
        local_1c = puVar4;
        if (local_18 == 0) {
          local_1c = puVar4 + 1;
          local_18 = 0x80000000;
        }
        puVar2 = local_14 + 1;
        for (iVar6 = local_8; 0 < iVar6; iVar6 = iVar6 + -1) {
          cVar3 = *local_10;
          local_10 = local_10 + 1;
          if (cVar3 != '\0') {
            if (param_4 == 0) {
              *local_14 = *local_14 & param_3 | param_2;
            }
            else if (param_4 == 1) {
              *local_14 = *local_14 & param_2;
            }
            else if (param_4 == 2) {
              *local_14 = *local_14 | param_2;
            }
            else if (param_4 == 3) {
              *local_14 = *local_14 ^ param_2;
            }
            *puVar4 = *puVar4 | uVar5;
            DAT_00522cbc = DAT_00522cbc + 1;
          }
          puVar4 = puVar4 + *(int *)(param_1 + 0x1c);
          local_14 = local_14 + *(int *)(param_1 + 0x18);
        }
        puVar4 = local_1c;
        uVar5 = local_18;
        local_14 = puVar2;
        local_10 = pcVar1;
      }
    }
    else if (param_5 == 0xb4) {
      FUN_0046af20(param_1,iVar6,iVar6 + iVar8);
      local_20 = local_1c;
      for (; 0 < iVar8; iVar8 = iVar8 + -1) {
        pcVar1 = local_10 + -*param_8;
        puVar4 = local_20 + *(int *)(param_1 + 0x1c);
        puVar2 = local_14 + *(int *)(param_1 + 0x18);
        uVar5 = local_18;
        for (iVar6 = local_8; 0 < iVar6; iVar6 = iVar6 + -1) {
          cVar3 = *local_10;
          local_10 = local_10 + 1;
          if (cVar3 != '\0') {
            if (param_4 == 0) {
              *local_14 = *local_14 & param_3 | param_2;
            }
            else if (param_4 == 1) {
              *local_14 = *local_14 & param_2;
            }
            else if (param_4 == 2) {
              *local_14 = *local_14 | param_2;
            }
            else if (param_4 == 3) {
              *local_14 = *local_14 ^ param_2;
            }
            *local_20 = *local_20 | uVar5;
            DAT_00522cbc = DAT_00522cbc + 1;
          }
          uVar5 = uVar5 * 2;
          if (uVar5 == 0) {
            local_20 = local_20 + -1;
            uVar5 = 1;
          }
          local_14 = local_14 + -1;
        }
        local_20 = puVar4;
        local_14 = puVar2;
        local_10 = pcVar1;
      }
    }
    else if (param_5 == 0x10e) {
      FUN_0046af20(param_1,iVar6 - local_8,iVar6);
      puVar4 = local_1c;
      uVar5 = local_18;
      for (; 0 < iVar8; iVar8 = iVar8 + -1) {
        pcVar1 = local_10 + -*param_8;
        local_18 = uVar5 << 1;
        local_1c = puVar4;
        if (local_18 == 0) {
          local_1c = puVar4 + -1;
          local_18 = 1;
        }
        puVar2 = local_14 + -1;
        for (iVar6 = local_8; 0 < iVar6; iVar6 = iVar6 + -1) {
          cVar3 = *local_10;
          local_10 = local_10 + 1;
          if (cVar3 != '\0') {
            if (param_4 == 0) {
              *local_14 = *local_14 & param_3 | param_2;
            }
            else if (param_4 == 1) {
              *local_14 = *local_14 & param_2;
            }
            else if (param_4 == 2) {
              *local_14 = *local_14 | param_2;
            }
            else if (param_4 == 3) {
              *local_14 = *local_14 ^ param_2;
            }
            *puVar4 = *puVar4 | uVar5;
            DAT_00522cbc = DAT_00522cbc + 1;
          }
          puVar4 = puVar4 + -*(int *)(param_1 + 0x1c);
          local_14 = local_14 + -*(int *)(param_1 + 0x18);
        }
        puVar4 = local_1c;
        uVar5 = local_18;
        local_14 = puVar2;
        local_10 = pcVar1;
      }
    }
    else {
      FUN_0046af20(param_1,(iVar6 - iVar8) + 1,iVar6);
      local_20 = local_1c;
      for (; 0 < iVar8; iVar8 = iVar8 + -1) {
        pcVar1 = local_10 + -*param_8;
        puVar4 = local_20 + -*(int *)(param_1 + 0x1c);
        puVar2 = local_14 + -*(int *)(param_1 + 0x18);
        uVar5 = local_18;
        for (iVar6 = local_8; 0 < iVar6; iVar6 = iVar6 + -1) {
          cVar3 = *local_10;
          local_10 = local_10 + 1;
          if (cVar3 != '\0') {
            if (param_4 == 0) {
              *local_14 = *local_14 & param_3 | param_2;
            }
            else if (param_4 == 1) {
              *local_14 = *local_14 & param_2;
            }
            else if (param_4 == 2) {
              *local_14 = *local_14 | param_2;
            }
            else if (param_4 == 3) {
              *local_14 = *local_14 ^ param_2;
            }
            *local_20 = *local_20 | uVar5;
            DAT_00522cbc = DAT_00522cbc + 1;
          }
          uVar5 = uVar5 >> 1;
          if (uVar5 == 0) {
            local_20 = local_20 + 1;
            uVar5 = 0x80000000;
          }
          local_14 = local_14 + 1;
        }
        local_20 = puVar4;
        local_14 = puVar2;
        local_10 = pcVar1;
      }
    }
  }
  return;
}



/* @0046ced4 file=? name=FUN_0046ced4 */

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

{
  int *piVar1;
  undefined4 extraout_ECX;
  undefined4 extraout_EDX;
  int iVar2;
  int *piVar3;
  short *psVar4;
  int local_8;
  
  FUN_0046ab50(param_1,param_3,param_4);
  *param_1 = (int)&PTR_FUN_004f4d3c;
  piVar3 = param_1 + 0x20;
  FUN_004de998(piVar3,0x31c,4,1,FUN_0046e6ec);
  param_1[0x10] = param_5 << 10;
  param_1[0x11] = param_5 / param_6;
  param_1[0x12] = param_7;
  param_1[0x13] = param_8;
  param_1[0x14] = param_9;
  param_1[0x15] = -1;
  FUN_0047d70c(param_2,param_1[0x13]);
  FUN_0047d7da(extraout_ECX,extraout_EDX,1);
  FUN_0046d4a0((int)param_1,0.0);
  psVar4 = &DAT_004f4b34;
  local_8 = 0;
  do {
    *(short *)piVar3 = *psVar4;
    piVar3[1] = 0;
    piVar3[0xc3] = 0;
    piVar3[0xc4] = 0;
    piVar3[0xc6] = -1;
    piVar1 = piVar3 + 0xc5;
    iVar2 = 0;
    do {
      *(undefined1 *)piVar1 = 0xff;
      iVar2 = iVar2 + 1;
      piVar1 = (int *)((int)piVar1 + 1);
    } while (iVar2 < 4);
    if (*psVar4 != 0x3c6) {
      FUN_0047d8cb(0,iVar2,*psVar4);
    }
    psVar4 = psVar4 + 1;
    local_8 = local_8 + 1;
    piVar3 = piVar3 + 199;
  } while (local_8 < 4);
  param_1[0x15] = -1;
  FUN_0046d404((int)param_1);
  DAT_00522cbc = 0;
  DAT_00522cc0 = 0;
  DAT_00522cc4 = 0;
  (**(code **)(*param_1 + 0x1c))(param_1,0,0xffff,0,0,0,param_1[9],param_1[10]);
  (**(code **)(*param_1 + 8))(param_1,0);
  return param_1;
}



/* @0046d050 file=? name=FUN_0046d050 */

void __cdecl FUN_0046d050(int *param_1,byte param_2)

{
  uint uVar1;
  uint uVar2;
  uint uVar3;
  int *piVar4;
  undefined4 extraout_ECX;
  undefined4 extraout_EDX;
  double local_c;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f4d3c;
    FUN_0047d70c(3,0);
    uVar3 = DAT_00522cc4;
    uVar2 = DAT_00522cc0;
    uVar1 = DAT_00522cbc;
    if (DAT_00522cc0 == 0) {
      local_c = 0.0;
    }
    else {
      local_c = (double)(int)DAT_00522cbc / (double)(int)DAT_00522cc0;
    }
    FUN_004dbb24(&DAT_00524e20,s_SVGA16___SVGA16__pixel_managemen_004f4baf,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_Number_of_dirty_pixels___004f4be9,(char *)0x0);
    piVar4 = FUN_004db78c(&DAT_00524e20,uVar1);
    FUN_004dbb24(piVar4,s_Number_of_transferred_pixels__004f4c08,(char *)0x0);
    piVar4 = FUN_004db78c(piVar4,uVar2);
    FUN_004dbb24(piVar4,s_Times_overflowed___004f4c27,(char *)0x0);
    piVar4 = FUN_004db78c(piVar4,uVar3);
    FUN_004dbb24(piVar4,s_Ratio___004f4c46,(char *)0x0);
    piVar4 = FUN_004db634(piVar4,(float10)local_c);
    FUN_004dbb24(piVar4,s__________________________________004f4c4f,(char *)0x0);
    FUN_0047d7da(extraout_ECX,extraout_EDX,0);
    FUN_004de8d4(param_1 + 0x20,0x31c,4,1,FUN_0046e702);
    FUN_0046ac08(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0046d1a8 file=? name=FUN_0046d1a8 */

void FUN_0046d1a8(void)

{
  FUN_0046ac68();
  return;
}



/* @0046d1b8 file=? name=FUN_0046d1b8 */

void __cdecl FUN_0046d1b8(int param_1,char *param_2)

{
  char cVar1;
  uint uVar2;
  uint uVar3;
  char *pcVar4;
  char *pcVar5;
  char local_54 [80];
  
  FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_SVGA16__004f4c89,(char *)0x0);
  uVar2 = 0xffffffff;
  do {
    pcVar4 = param_2;
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    pcVar4 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar4;
  } while (cVar1 != '\0');
  uVar2 = ~uVar2;
  pcVar4 = pcVar4 + -uVar2;
  pcVar5 = local_54;
  for (uVar3 = uVar2 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {
    *(undefined4 *)pcVar5 = *(undefined4 *)pcVar4;
    pcVar4 = pcVar4 + 4;
    pcVar5 = pcVar5 + 4;
  }
  for (uVar2 = uVar2 & 3; uVar2 != 0; uVar2 = uVar2 - 1) {
    *pcVar5 = *pcVar4;
    pcVar4 = pcVar4 + 1;
    pcVar5 = pcVar5 + 1;
  }
  FUN_004d49b8(local_54,&DAT_004f4c92);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_SVGA16__004f4c96,(char *)0x0);
  FUN_0046ac74(param_1,local_54);
  return;
}



/* @0046d260 file=? name=FUN_0046d260 */

undefined4 __cdecl FUN_0046d260(int param_1,int param_2)

{
  char cVar1;
  int iVar2;
  undefined1 *puVar3;
  int iVar4;
  undefined4 *puVar5;
  undefined4 uVar6;
  char *this;
  int iVar7;
  undefined8 uVar8;
  int local_14;
  int local_10;
  char *local_c;
  
  if (*(int *)(param_1 + 0x14) == 0) {
    uVar6 = 0;
  }
  else {
    if (param_2 != 0) {
      FUN_004d4988(*(undefined4 **)(param_1 + 0x38),1,*(uint *)(param_1 + 0x20));
    }
    iVar2 = *(int *)(param_1 + 0x5c);
    if (*(int *)(param_1 + 0x50) == 0) {
      local_c = (char *)0x40;
      local_10 = *(int *)(param_1 + 0x18) * 2;
    }
    else {
      local_c = (char *)0x20;
      local_10 = *(int *)(param_1 + 0x18);
    }
    local_14 = 0xf;
    do {
      this = *(char **)(param_1 + 100);
      puVar3 = *(undefined1 **)(param_1 + 100);
      cVar1 = *this;
      *(int *)(param_1 + 100) = *(int *)(param_1 + 100) + 1;
      *puVar3 = 0;
      if (cVar1 == '\0') {
        *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + *(int *)(param_1 + 0x1c) * 4;
        *(int *)(param_1 + 0x68) = *(int *)(param_1 + 0x68) + *(int *)(param_1 + 0x18) * 2;
        *(int *)(param_1 + 0x60) = *(int *)(param_1 + 0x60) + local_10;
        if (*(int *)(param_1 + 0x40) <= *(int *)(param_1 + 0x60)) {
          *(int *)(param_1 + 0x60) = *(int *)(param_1 + 0x60) - *(int *)(param_1 + 0x40);
          *(int *)(param_1 + 0x58) = *(int *)(param_1 + 0x58) + *(int *)(param_1 + 0x44);
        }
      }
      else {
        local_14 = local_14 + -1;
        for (iVar7 = 0; iVar7 < *(int *)(param_1 + 0x1c); iVar7 = iVar7 + 1) {
          iVar4 = **(int **)(param_1 + 0x6c);
          puVar5 = *(undefined4 **)(param_1 + 0x6c);
          *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 4;
          *puVar5 = 0;
          if (iVar4 != 0) {
            if (*(uint *)(param_1 + 0x58) != *(uint *)(param_1 + 0x54)) {
              FUN_0047d7f6(this,*(uint *)(param_1 + 0x58));
              this = *(char **)(param_1 + 0x58);
              *(char **)(param_1 + 0x54) = this;
            }
            if (*(int *)(param_1 + 0x50) == 0) {
              uVar8 = FUN_0047d848(this,*(undefined4 *)(param_1 + 0x60),
                                   (undefined2 *)*(undefined4 *)(param_1 + 0x60),
                                   *(undefined2 **)(param_1 + 0x68),iVar4);
              DAT_00522cc0 = DAT_00522cc0 + (int)uVar8;
            }
            else {
              uVar8 = FUN_0047d88b(*(undefined4 *)(param_1 + 0x60),*(undefined4 *)(param_1 + 0x68),
                                   (undefined1 *)*(undefined4 *)(param_1 + 0x60),
                                   (undefined2 *)*(undefined4 *)(param_1 + 0x68),iVar4);
              DAT_00522cc0 = DAT_00522cc0 + (int)uVar8;
            }
          }
          *(int *)(param_1 + 0x68) = *(int *)(param_1 + 0x68) + 0x40;
          *(int *)(param_1 + 0x60) = (int)(local_c + *(int *)(param_1 + 0x60));
          this = local_c;
          if (*(int *)(param_1 + 0x40) <= *(int *)(param_1 + 0x60)) {
            *(int *)(param_1 + 0x60) = *(int *)(param_1 + 0x60) - *(int *)(param_1 + 0x40);
            this = *(char **)(param_1 + 0x44);
            *(int *)(param_1 + 0x58) = (int)(this + *(int *)(param_1 + 0x58));
          }
        }
      }
      if ((0x10000000 < DAT_00522cc0) || (0x10000000 < DAT_00522cbc)) {
        DAT_00522cc0 = DAT_00522cc0 >> 1;
        DAT_00522cbc = DAT_00522cbc >> 1;
        DAT_00522cc4 = DAT_00522cc4 + 1;
      }
      *(int *)(param_1 + 0x5c) = *(int *)(param_1 + 0x5c) + 1;
      if (*(int *)(param_1 + 0x20) <= *(int *)(param_1 + 0x5c)) {
        FUN_0046d404(param_1);
      }
      if (*(int *)(param_1 + 0x5c) == iVar2) {
        return 0;
      }
    } while (0 < local_14);
    uVar6 = 1;
  }
  return uVar6;
}



/* @0046d404 file=? name=FUN_0046d404 */

void __cdecl FUN_0046d404(int param_1)

{
  *(undefined4 *)(param_1 + 0x5c) = 0;
  *(undefined4 *)(param_1 + 0x68) = *(undefined4 *)(param_1 + 0x34);
  *(undefined4 *)(param_1 + 100) = *(undefined4 *)(param_1 + 0x38);
  *(undefined4 *)(param_1 + 0x6c) = *(undefined4 *)(param_1 + 0x3c);
  *(undefined4 *)(param_1 + 0x58) = 0;
  *(undefined4 *)(param_1 + 0x60) = 0;
  return;
}



/* @0046d430 file=? name=FUN_0046d430 */

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

void __cdecl FUN_0046d430(int param_1,float param_2)

{
  undefined4 *puVar1;
  float10 fVar2;
  
  puVar1 = (undefined4 *)FUN_00414b60();
  *(undefined4 *)(param_1 + 0x7c) = *puVar1;
  *(undefined4 *)(param_1 + 0x70) = 3;
  fVar2 = FUN_004dcd00((double)param_2);
  if ((float10)_DAT_0046d498 < fVar2) {
    *(float *)(param_1 + 0x78) = _DAT_0046d49c / param_2;
  }
  else {
    *(undefined4 *)(param_1 + 0x78) = 0;
    *(undefined4 *)(param_1 + 0x74) = 0x3f800000;
  }
  return;
}



/* @0046d4a0 file=? name=FUN_0046d4a0 */

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

void __cdecl FUN_0046d4a0(int param_1,float param_2)

{
  undefined4 *puVar1;
  float10 fVar2;
  
  puVar1 = (undefined4 *)FUN_00414b60();
  *(undefined4 *)(param_1 + 0x7c) = *puVar1;
  *(undefined4 *)(param_1 + 0x70) = 1;
  fVar2 = FUN_004dcd00((double)param_2);
  if ((float10)_DAT_0046d504 < fVar2) {
    *(float *)(param_1 + 0x78) = _DAT_0046d508 / param_2;
  }
  else {
    *(undefined4 *)(param_1 + 0x78) = 0;
    *(undefined4 *)(param_1 + 0x74) = 0;
  }
  return;
}



/* @0046d50c file=? name=FUN_0046d50c */

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

void __cdecl FUN_0046d50c(short *param_1)

{
  undefined4 uVar1;
  undefined2 extraout_var;
  byte *pbVar2;
  int iVar3;
  int local_308;
  byte local_304 [768];
  
  FUN_004498a8(&local_308);
  iVar3 = 0;
  pbVar2 = local_304;
  do {
    uVar1 = FUN_004dcd94();
    *pbVar2 = (byte)uVar1;
    uVar1 = FUN_004dcd94();
    pbVar2[1] = (byte)uVar1;
    uVar1 = FUN_004dcd94();
    pbVar2[2] = (byte)uVar1;
    iVar3 = iVar3 + 1;
    pbVar2 = pbVar2 + 3;
  } while (iVar3 < 0x100);
  FUN_0047d8f2(CONCAT22(extraout_var,*param_1),param_1,local_304,*param_1);
  FUN_00449994(&local_308,2);
  return;
}



/* @0046d694 file=? name=FUN_0046d694 */

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

uint __cdecl FUN_0046d694(int param_1)

{
  int *piVar1;
  float fVar2;
  undefined1 uVar3;
  uint uVar4;
  int iVar5;
  float fVar6;
  int *piVar7;
  uint uVar8;
  undefined2 extraout_var;
  undefined2 extraout_var_00;
  undefined4 extraout_ECX;
  undefined2 *puVar9;
  short *psVar10;
  int iVar11;
  undefined8 uVar12;
  
  piVar7 = (int *)FUN_00414b60();
  piVar1 = (int *)(param_1 + 0x7c);
  fVar6 = (float)(*piVar7 - *piVar1) / DAT_0052140c;
  *piVar1 = *piVar7;
  uVar8 = CONCAT22((short)((uint)piVar1 >> 0x10),
                   (ushort)(fVar6 < _DAT_0046d834) << 8 |
                   (ushort)(NAN(fVar6) || NAN(_DAT_0046d834)) << 10 |
                   (ushort)(fVar6 == _DAT_0046d834) << 0xe);
  if (fVar6 >= _DAT_0046d834 && (fVar6 == _DAT_0046d834) == 0) {
    puVar9 = (undefined2 *)(param_1 + 0x80);
    iVar11 = 0;
    do {
      fVar2 = *(float *)(puVar9 + 0x188);
      uVar8 = CONCAT22((short)(uVar8 >> 0x10),
                       (ushort)(fVar2 < _DAT_0046d834) << 8 |
                       (ushort)(NAN(fVar2) || NAN(_DAT_0046d834)) << 10 |
                       (ushort)(fVar2 == _DAT_0046d834) << 0xe);
      if ((fVar2 == _DAT_0046d834) == 0) {
        *(float *)(puVar9 + 0x186) = *(float *)(puVar9 + 0x188) * fVar6 + *(float *)(puVar9 + 0x186)
        ;
        while (_DAT_0046d838 <= *(float *)(puVar9 + 0x186)) {
          *(float *)(puVar9 + 0x186) = *(float *)(puVar9 + 0x186) - _DAT_0046d838;
        }
        uVar8 = FUN_004dcd94();
        uVar4 = *(uint *)(puVar9 + 0x18c);
        if (uVar8 != uVar4) {
          *(uint *)(puVar9 + 0x18c) = uVar8;
          uVar3 = *(undefined1 *)((int)puVar9 + uVar8 + 0x314);
          uVar12 = FUN_0047d962(CONCAT31((int3)((uint)extraout_ECX >> 8),uVar3),uVar4,*puVar9,uVar3)
          ;
          uVar8 = (uint)uVar12;
        }
      }
      iVar11 = iVar11 + 1;
      puVar9 = puVar9 + 0x18e;
    } while (iVar11 < 4);
    psVar10 = (short *)(param_1 + 0x80);
    iVar11 = 0;
    do {
      if ((iVar11 == 1) && (uVar8 = 0, *(int *)(param_1 + 0x70) != 0)) {
        psVar10[2] = 0;
        psVar10[3] = 0;
        iVar5 = *(int *)(param_1 + 0x70);
        if (iVar5 == 1) {
          *(float *)(param_1 + 0x74) =
               *(float *)(param_1 + 0x74) - fVar6 * *(float *)(param_1 + 0x78);
          FUN_0046d50c(psVar10);
          fVar2 = *(float *)(param_1 + 0x74);
          uVar8 = CONCAT22(extraout_var,
                           (ushort)(fVar2 < _DAT_0046d834) << 8 |
                           (ushort)(NAN(fVar2) || NAN(_DAT_0046d834)) << 10 |
                           (ushort)(fVar2 == _DAT_0046d834) << 0xe);
          if (fVar2 < _DAT_0046d834 || (fVar2 == _DAT_0046d834) != 0) {
            *(undefined4 *)(param_1 + 0x74) = 0;
            *(undefined4 *)(param_1 + 0x70) = 2;
          }
        }
        else {
          uVar8 = 0;
          if ((iVar5 != 2) && (uVar8 = iVar5 - 3, uVar8 == 0)) {
            *(float *)(param_1 + 0x74) =
                 fVar6 * *(float *)(param_1 + 0x78) + *(float *)(param_1 + 0x74);
            FUN_0046d50c(psVar10);
            fVar2 = *(float *)(param_1 + 0x74);
            uVar8 = CONCAT22(extraout_var_00,
                             (ushort)(fVar2 < _DAT_0046d83c) << 8 |
                             (ushort)(NAN(fVar2) || NAN(_DAT_0046d83c)) << 10 |
                             (ushort)(fVar2 == _DAT_0046d83c) << 0xe);
            if (fVar2 >= _DAT_0046d83c) {
              *(undefined4 *)(param_1 + 0x74) = 0x3f800000;
              *(undefined4 *)(param_1 + 0x70) = 0;
            }
          }
        }
      }
      else if (*(int *)(psVar10 + 2) != 0) {
        psVar10[2] = 0;
        psVar10[3] = 0;
        uVar12 = FUN_0047d8f2(0,psVar10 + 6,(byte *)(psVar10 + 6),*psVar10);
        uVar8 = (uint)uVar12;
      }
      iVar11 = iVar11 + 1;
      psVar10 = psVar10 + 0x18e;
    } while (iVar11 < 4);
  }
  return uVar8;
}



/* @0046d840 file=? name=FUN_0046d840 */

undefined6 __cdecl FUN_0046d840(undefined4 param_1,int param_2)

{
  undefined6 uVar1;
  
  uVar1 = FUN_0047d76d(param_2);
  return uVar1;
}



/* @0046d850 file=? name=FUN_0046d850 */

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

{
  uint uVar1;
  undefined4 *puVar2;
  int iVar3;
  
  FUN_0044a2d0(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_004f4d0c;
  param_1[0x14a] = param_4;
  param_1[0x14f] = param_6;
  param_1[0x150] = param_7;
  uVar1 = 0x8000;
  param_1[0x14b] = param_5;
  param_1[0x14c] = 0;
  do {
    if ((param_1[0x14b] & uVar1) != 0) {
      param_1[0x14c] = param_1[0x14c] + 1;
    }
    uVar1 = (int)uVar1 >> 1;
  } while (uVar1 != 0);
  param_1[0x14d] = param_1[3] - param_1[1];
  param_1[0x14e] = param_1[4] - param_1[2];
  if (((param_1[0x14a] == 0x5a) || (param_1[0x14a] == 0x10e)) && (param_2 != (undefined4 *)0x0)) {
    param_1[1] = param_2[2];
    param_1[2] = param_2[1];
    param_1[3] = param_2[4];
    param_1[4] = param_2[3];
  }
  iVar3 = 0;
  puVar2 = param_1 + 0x10a;
  do {
    *(undefined1 *)puVar2 = 0;
    iVar3 = iVar3 + 1;
    puVar2 = (undefined4 *)((int)puVar2 + 1);
  } while (iVar3 < 0x100);
  return param_1;
}



/* @0046d91c file=? name=FUN_0046d91c */

void __cdecl FUN_0046d91c(int *param_1,byte param_2)

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



/* @0046d948 file=? name=FUN_0046d948 */

undefined4 FUN_0046d948(void)

{
  return 1;
}



/* @0046d954 file=? name=FUN_0046d954 */

void __cdecl FUN_0046d954(int param_1,char *param_2)

{
  char cVar1;
  int *piVar2;
  uint uVar3;
  uint uVar4;
  char *pcVar5;
  char *pcVar6;
  uint *puVar7;
  char local_54 [80];
  
  FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_L4GraphicsPort__004f4c9f,(char *)0x0);
  uVar3 = 0xffffffff;
  do {
    pcVar5 = param_2;
    if (uVar3 == 0) break;
    uVar3 = uVar3 - 1;
    pcVar5 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar5;
  } while (cVar1 != '\0');
  uVar3 = ~uVar3;
  pcVar5 = pcVar5 + -uVar3;
  pcVar6 = local_54;
  for (uVar4 = uVar3 >> 2; uVar4 != 0; uVar4 = uVar4 - 1) {
    *(undefined4 *)pcVar6 = *(undefined4 *)pcVar5;
    pcVar5 = pcVar5 + 4;
    pcVar6 = pcVar6 + 4;
  }
  for (uVar3 = uVar3 & 3; uVar3 != 0; uVar3 = uVar3 - 1) {
    *pcVar6 = *pcVar5;
    pcVar5 = pcVar5 + 1;
    pcVar6 = pcVar6 + 1;
  }
  FUN_004d49b8(local_54,&DAT_004f4cb0);
  uVar3 = *(uint *)(param_1 + 0x52c);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_bitMask___004f4cb4,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4cc3,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x528);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_baseRotation___004f4cc5,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4cd4,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x534);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_maximumX___004f4cd6,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4ce5,(char *)0x0);
  uVar3 = *(uint *)(param_1 + 0x538);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_maximumY___004f4ce7,(char *)0x0);
  piVar2 = FUN_004db78c(&DAT_00524e20,uVar3);
  FUN_004dbb24(piVar2,&DAT_004f4cf6,(char *)0x0);
  puVar7 = (uint *)(param_1 + 4);
  FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_bounds___004f4cf8,(char *)0x0);
  piVar2 = (int *)FUN_00407d78(&DAT_00524e20,puVar7);
  FUN_004dbb24(piVar2,&DAT_004f4d07,(char *)0x0);
  FUN_004d9c70(&DAT_00524e20);
  FUN_0044a374(param_1,local_54);
  return;
}



/* @0046db5c file=? name=FUN_0046db5c */

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

{
  if (1 < *(int *)(param_1 + 0x540) - 4U) {
    FUN_0046e31c(param_1,param_2,param_3);
  }
  return;
}



/* @0046db84 file=? name=FUN_0046db84 */

void __cdecl FUN_0046db84(int param_1,int param_2)

{
  if (*(int *)(param_1 + 0x14) != 0) {
    if (*(int *)(param_1 + 0x540) == 4) {
      FUN_0046e180(param_1,param_2);
      return;
    }
    if (*(int *)(param_1 + 0x540) == 5) {
      FUN_0046e578(param_1);
      FUN_0046e650(param_1);
      return;
    }
    FUN_0046e1e4(param_1,param_2);
    FUN_0046e650(param_1);
  }
  return;
}



/* @0046dbdc file=? name=FUN_0046dbdc */

void __cdecl FUN_0046dbdc(int param_1)

{
  uint uVar1;
  int *piVar2;
  int local_310 [193];
  undefined2 local_a;
  undefined1 local_8;
  undefined2 local_7;
  undefined1 local_5;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    if (*(int *)(param_1 + 0x540) == 4) {
      piVar2 = local_310;
      uVar1 = FUN_004498a8(piVar2);
      local_7 = 0;
      local_5 = 0;
      local_a = 0xffff;
      local_8 = 0xff;
      FUN_004499e4((int)local_310,0,0xff,(uVar1 & 0xffffff00) << 0x10,
                   CONCAT22((short)CONCAT31((int3)((uint)piVar2 >> 8),0xff),0xffff));
      FUN_0046e180(param_1,(int)local_310);
      FUN_00449994(local_310,2);
    }
    else if (*(int *)(param_1 + 0x540) == 5) {
      FUN_0046e578(param_1);
      FUN_0046e694(param_1);
    }
    else {
      FUN_0046e444(param_1);
      FUN_0046e694(param_1);
    }
  }
  return;
}



/* @0046dca0 file=? name=FUN_0046dca0 */

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

{
  int local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    FUN_0046e114(param_1,&local_8,&local_c,param_4,param_5);
    (**(code **)(**(int **)(param_1 + 0x14) + 0x14))
              (*(int **)(param_1 + 0x14),*(undefined4 *)(param_1 + 0x28 + param_2 * 4),
               *(undefined4 *)(param_1 + 0x52c),param_3,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8));
  }
  return;
}



/* @0046dd00 file=? name=FUN_0046dd00 */

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

{
  int local_14;
  int local_10;
  int local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    FUN_0046e114(param_1,&local_8,&local_c,param_4,param_5);
    FUN_0046e114(param_1,&local_10,&local_14,param_6,param_7);
    (**(code **)(**(int **)(param_1 + 0x14) + 0x18))
              (*(int **)(param_1 + 0x14),*(undefined4 *)(param_1 + 0x28 + param_2 * 4),
               *(undefined4 *)(param_1 + 0x52c),param_3,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8),local_10 + *(int *)(param_1 + 4),
               local_14 + *(int *)(param_1 + 8),param_8);
  }
  return;
}



/* @0046dd8c file=? name=FUN_0046dd8c */

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

{
  int local_14;
  int local_10;
  int local_c;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    FUN_0046e114(param_1,&local_8,&local_c,param_4,param_5);
    FUN_0046e114(param_1,&local_10,&local_14,param_6,param_7);
    (**(code **)(**(int **)(param_1 + 0x14) + 0x1c))
              (*(int **)(param_1 + 0x14),*(undefined4 *)(param_1 + 0x28 + param_2 * 4),
               *(undefined4 *)(param_1 + 0x52c),param_3,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8),local_10 + *(int *)(param_1 + 4),
               local_14 + *(int *)(param_1 + 8));
  }
  return;
}



/* @0046de14 file=? name=FUN_0046de14 */

void FUN_0046de14(void)

{
  return;
}



/* @0046de1c file=? name=FUN_0046de1c */

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

{
  int iVar1;
  int local_c;
  int local_8;
  
  if (((*(int *)(param_1 + 0x14) != 0) && (param_7 != 0)) && (*(int *)(param_7 + 0x18) != 0)) {
    FUN_0046e114(param_1,&local_8,&local_c,param_5,param_6);
    for (iVar1 = param_4 + *(int *)(param_1 + 0x528); iVar1 < 0; iVar1 = iVar1 + 0x168) {
    }
    for (; 0x167 < iVar1; iVar1 = iVar1 + -0x168) {
    }
    (**(code **)(**(int **)(param_1 + 0x14) + 0x24))
              (*(int **)(param_1 + 0x14),*(undefined4 *)(param_1 + 0x28 + param_2 * 4),
               *(undefined4 *)(param_1 + 0x52c),param_3,iVar1,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8),param_7,param_8,param_9,param_10,param_11);
  }
  return;
}



/* @0046ded8 file=? name=FUN_0046ded8 */

void __cdecl
FUN_0046ded8(int param_1,int param_2,int param_3,undefined4 param_4,int param_5,int param_6,
            int param_7,int param_8,undefined4 param_9,undefined4 param_10,undefined4 param_11,
            undefined4 param_12)

{
  int iVar1;
  int local_c;
  int local_8;
  
  if (((*(int *)(param_1 + 0x14) != 0) && (param_8 != 0)) && (*(int *)(param_8 + 0x18) != 0)) {
    FUN_0046e114(param_1,&local_8,&local_c,param_6,param_7);
    for (iVar1 = param_5 + *(int *)(param_1 + 0x528); iVar1 < 0; iVar1 = iVar1 + 0x168) {
    }
    for (; 0x167 < iVar1; iVar1 = iVar1 + -0x168) {
    }
    (**(code **)(**(int **)(param_1 + 0x14) + 0x28))
              (*(int **)(param_1 + 0x14),*(undefined4 *)(param_1 + 0x28 + param_2 * 4),
               *(undefined4 *)(param_1 + 0x28 + param_3 * 4),*(undefined4 *)(param_1 + 0x52c),
               param_4,iVar1,local_8 + *(int *)(param_1 + 4),local_c + *(int *)(param_1 + 8),param_8
               ,param_9,param_10,param_11,param_12);
  }
  return;
}



/* @0046df9c file=? name=FUN_0046df9c */

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

{
  int iVar1;
  int local_c;
  int local_8;
  
  if (((*(int *)(param_1 + 0x14) != 0) && (param_7 != 0)) && (*(int *)(param_7 + 8) != 0)) {
    FUN_0046e114(param_1,&local_8,&local_c,param_5,param_6);
    for (iVar1 = param_4 + *(int *)(param_1 + 0x528); iVar1 < 0; iVar1 = iVar1 + 0x168) {
    }
    for (; 0x167 < iVar1; iVar1 = iVar1 + -0x168) {
    }
    (**(code **)(**(int **)(param_1 + 0x14) + 0x2c))
              (*(int **)(param_1 + 0x14),param_1 + 0x28,*(undefined4 *)(param_1 + 0x52c),param_2,
               param_3,iVar1,local_8 + *(int *)(param_1 + 4),local_c + *(int *)(param_1 + 8),param_7
               ,param_8,param_9,param_10,param_11);
  }
  return;
}



/* @0046e058 file=? name=FUN_0046e058 */

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

{
  int iVar1;
  int local_c;
  int local_8;
  
  if (((*(int *)(param_1 + 0x14) != 0) && (param_7 != 0)) && (*(int *)(param_7 + 8) != 0)) {
    FUN_0046e114(param_1,&local_8,&local_c,param_5,param_6);
    for (iVar1 = param_4 + *(int *)(param_1 + 0x528); iVar1 < 0; iVar1 = iVar1 + 0x168) {
    }
    for (; 0x167 < iVar1; iVar1 = iVar1 + -0x168) {
    }
    (**(code **)(**(int **)(param_1 + 0x14) + 0x30))
              (*(int **)(param_1 + 0x14),*(undefined4 *)(param_1 + 0x28 + param_2 * 4),
               *(undefined4 *)(param_1 + 0x52c),param_3,iVar1,local_8 + *(int *)(param_1 + 4),
               local_c + *(int *)(param_1 + 8),param_7,param_8,param_9,param_10,param_11);
  }
  return;
}



/* @0046e114 file=? name=FUN_0046e114 */

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

{
  int iVar1;
  
  iVar1 = *(int *)(param_1 + 0x528);
  if (iVar1 == 0x5a) {
    *param_2 = param_5;
    *param_3 = *(int *)(param_1 + 0x538) - param_4;
  }
  else if (iVar1 == 0xb4) {
    *param_2 = *(int *)(param_1 + 0x534) - param_4;
    *param_3 = *(int *)(param_1 + 0x538) - param_5;
  }
  else if (iVar1 == 0x10e) {
    *param_2 = *(int *)(param_1 + 0x534) - param_5;
    *param_3 = param_4;
  }
  else {
    *param_2 = param_4;
    *param_3 = param_5;
  }
  return;
}



/* @0046e180 file=? name=FUN_0046e180 */

void __cdecl FUN_0046e180(int param_1,int param_2)

{
  byte *pbVar1;
  byte *pbVar2;
  byte bVar3;
  byte *pbVar4;
  int iVar5;
  uint *puVar6;
  
  pbVar4 = (byte *)(param_2 + 4);
  *(undefined4 *)(param_1 + 0x52c) = 0xffff;
  puVar6 = (uint *)(param_1 + 0x28);
  iVar5 = 0x100;
  do {
    pbVar1 = pbVar4 + 1;
    bVar3 = *pbVar4;
    pbVar2 = pbVar4 + 2;
    pbVar4 = pbVar4 + 3;
    iVar5 = iVar5 + -1;
    *puVar6 = ((int)(uint)bVar3 >> 3) << 0xb | ((int)(uint)*pbVar1 >> 2) << 5 |
              (int)(uint)*pbVar2 >> 3;
    puVar6 = puVar6 + 1;
  } while (0 < iVar5);
  return;
}



/* @0046e1e4 file=? name=FUN_0046e1e4 */

void __cdecl FUN_0046e1e4(int param_1,int param_2)

{
  int iVar1;
  int iVar2;
  int iVar3;
  undefined1 *puVar4;
  uint local_14 [3];
  undefined1 *local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    FUN_0046aa78(local_14,*(uint *)(param_1 + 0x52c) & 0xff,8);
    iVar3 = *(int *)(param_1 + 0x53c) * 0x31c + *(int *)(param_1 + 0x14);
    puVar4 = (undefined1 *)(param_2 + 4);
    iVar1 = 0;
    do {
      *(undefined1 *)(param_1 + 0x428 + local_14[0]) = 0;
      iVar1 = iVar1 + 1;
    } while (iVar1 < 0x100);
    if ((*(byte *)(param_1 + 0x540) & 0x80) != 0) {
      puVar4 = (undefined1 *)(param_2 + 7);
      FUN_0046aab0(local_14);
    }
    do {
      do {
        *(undefined1 *)(param_1 + 0x428 + local_14[0]) = 1;
        iVar2 = local_14[0] * 3 + iVar3 + 0x80;
        iVar1 = *(int *)(param_1 + 0x540);
        if (iVar1 < 0x81) {
          if ((iVar1 == 0x80) || (iVar1 == 0)) {
            *(undefined1 *)(iVar2 + 0xc) = *puVar4;
          }
          else {
            if (iVar1 == 1) goto LAB_0046e2b2;
            if (iVar1 == 2) goto LAB_0046e2ba;
            if (iVar1 == 3) goto LAB_0046e2c2;
          }
        }
        else if (iVar1 == 0x81) {
LAB_0046e2b2:
          *(undefined1 *)(iVar2 + 0xd) = puVar4[1];
        }
        else if (iVar1 == 0x82) {
LAB_0046e2ba:
          *(undefined1 *)(iVar2 + 0xe) = puVar4[2];
        }
        else if (iVar1 == 0x83) {
LAB_0046e2c2:
          *(undefined1 *)(iVar2 + 0xc) = *puVar4;
          *(undefined1 *)(iVar2 + 0xd) = puVar4[1];
          *(undefined1 *)(iVar2 + 0xe) = puVar4[2];
          local_8 = puVar4;
        }
        iVar1 = FUN_0046aae0(local_14);
      } while (iVar1 != 0);
      puVar4 = puVar4 + 3;
      iVar1 = FUN_0046aab0(local_14);
    } while (iVar1 != 0);
    *(undefined4 *)(iVar3 + 0x88) = 1;
    *(undefined4 *)(iVar3 + 0x84) = 1;
  }
  return;
}



/* @0046e31c file=? name=FUN_0046e31c */

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

{
  int iVar1;
  int iVar2;
  int iVar3;
  uint local_10 [3];
  
  if (*(int *)(param_1 + 0x14) == 0) {
    return;
  }
  FUN_0046aa78(local_10,*(uint *)(param_1 + 0x52c) & 0xff,8);
  iVar3 = 0;
  iVar2 = *(int *)(param_1 + 0x53c) * 0x31c + *(int *)(param_1 + 0x14);
  if ((*(byte *)(param_1 + 0x540) & 0x80) != 0) {
    iVar3 = 1;
    FUN_0046aab0(local_10);
  }
  do {
    if (iVar3 == param_3) goto LAB_0046e38f;
    iVar3 = iVar3 + 1;
    iVar1 = FUN_0046aab0(local_10);
  } while (iVar1 != 0);
  goto LAB_0046e42f;
LAB_0046e38f:
  do {
    if (*(char *)(param_1 + 0x428 + local_10[0]) != '\0') {
      iVar3 = *(int *)(param_1 + 0x540);
      iVar1 = local_10[0] * 3 + iVar2;
      if (iVar3 < 0x81) {
        if ((iVar3 == 0x80) || (iVar3 == 0)) {
          *(undefined1 *)(iVar1 + 0x8c) = *param_2;
        }
        else {
          if (iVar3 == 1) goto LAB_0046e3df;
          if (iVar3 == 2) goto LAB_0046e3ea;
          if (iVar3 == 3) goto LAB_0046e3f5;
        }
      }
      else if (iVar3 == 0x81) {
LAB_0046e3df:
        *(undefined1 *)(iVar1 + 0x8d) = param_2[1];
      }
      else if (iVar3 == 0x82) {
LAB_0046e3ea:
        *(undefined1 *)(iVar1 + 0x8e) = param_2[2];
      }
      else if (iVar3 == 0x83) {
LAB_0046e3f5:
        *(undefined1 *)(iVar1 + 0x8c) = *param_2;
        *(undefined1 *)(iVar1 + 0x8d) = param_2[1];
        *(undefined1 *)(iVar1 + 0x8e) = param_2[2];
      }
    }
    iVar3 = FUN_0046aae0(local_10);
  } while (iVar3 != 0);
LAB_0046e42f:
  *(undefined4 *)(iVar2 + 0x88) = 1;
  *(undefined4 *)(iVar2 + 0x84) = 1;
  return;
}



/* @0046e444 file=? name=FUN_0046e444 */

void __cdecl FUN_0046e444(int param_1)

{
  int iVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  uint local_18 [3];
  undefined1 local_9;
  int local_8;
  
  if (*(int *)(param_1 + 0x14) != 0) {
    FUN_0046aa78(local_18,*(int *)(param_1 + 0x52c) >> 8 & 0xff,8);
    iVar4 = *(int *)(param_1 + 0x53c) * 0x31c + *(int *)(param_1 + 0x14);
    iVar1 = FUN_0046ab18((int)local_18);
    iVar2 = (int)(0x1fe0 / (longlong)((1 << ((byte)iVar1 & 0x1f)) + -1));
    iVar1 = 0;
    local_8 = iVar2;
    if ((*(byte *)(param_1 + 0x540) & 0x80) != 0) {
      FUN_0046aab0(local_18);
      iVar1 = iVar2;
    }
    do {
      local_9 = (undefined1)(iVar1 >> 5);
      iVar1 = iVar1 + local_8;
      do {
        iVar3 = local_18[0] * 3 + iVar4 + 0x80;
        iVar2 = *(int *)(param_1 + 0x540);
        if (iVar2 < 0x81) {
          if ((iVar2 == 0x80) || (iVar2 == 0)) {
            *(undefined1 *)(iVar3 + 0xc) = local_9;
          }
          else {
            if (iVar2 == 1) goto LAB_0046e520;
            if (iVar2 == 2) goto LAB_0046e528;
            if (iVar2 == 3) goto LAB_0046e530;
          }
        }
        else if (iVar2 == 0x81) {
LAB_0046e520:
          *(undefined1 *)(iVar3 + 0xd) = local_9;
        }
        else if (iVar2 == 0x82) {
LAB_0046e528:
          *(undefined1 *)(iVar3 + 0xe) = local_9;
        }
        else if (iVar2 == 0x83) {
LAB_0046e530:
          *(undefined1 *)(iVar3 + 0xc) = local_9;
          *(undefined1 *)(iVar3 + 0xd) = local_9;
          *(undefined1 *)(iVar3 + 0xe) = local_9;
        }
        iVar2 = FUN_0046aae0(local_18);
      } while (iVar2 != 0);
      iVar2 = FUN_0046aab0(local_18);
    } while (iVar2 != 0);
    *(undefined4 *)(iVar4 + 0x88) = 1;
    *(undefined4 *)(iVar4 + 0x84) = 1;
  }
  return;
}



/* @0046e578 file=? name=FUN_0046e578 */

void __cdecl FUN_0046e578(int param_1)

{
  int iVar1;
  int iVar2;
  int iVar3;
  uint local_10 [3];
  
  if (*(int *)(param_1 + 0x14) != 0) {
    FUN_0046aa78(local_10,*(int *)(param_1 + 0x52c) >> 8 & 0xff,8);
    iVar3 = *(int *)(param_1 + 0x53c) * 0x31c + *(int *)(param_1 + 0x14);
    do {
      iVar1 = local_10[0] * 3 + iVar3 + 0x80;
      iVar2 = *(int *)(param_1 + 0x540);
      if (iVar2 < 0x81) {
        if ((iVar2 == 0x80) || (iVar2 == 0)) {
          *(undefined1 *)(iVar1 + 0xc) = 0;
        }
        else {
          if (iVar2 == 1) goto LAB_0046e60d;
          if (iVar2 == 2) goto LAB_0046e612;
          if (iVar2 == 3) goto LAB_0046e617;
        }
      }
      else if (iVar2 == 0x81) {
LAB_0046e60d:
        *(undefined1 *)(iVar1 + 0xd) = 0;
      }
      else if (iVar2 == 0x82) {
LAB_0046e612:
        *(undefined1 *)(iVar1 + 0xe) = 0;
      }
      else if (iVar2 == 0x83) {
LAB_0046e617:
        *(undefined1 *)(iVar1 + 0xc) = 0;
        *(undefined1 *)(iVar1 + 0xd) = 0;
        *(undefined1 *)(iVar1 + 0xe) = 0;
      }
      iVar2 = FUN_0046aae0(local_10);
    } while ((iVar2 != 0) || (iVar2 = FUN_0046aab0(local_10), iVar2 != 0));
    *(undefined4 *)(iVar3 + 0x88) = 1;
    *(undefined4 *)(iVar3 + 0x84) = 1;
  }
  return;
}



/* @0046e650 file=? name=FUN_0046e650 */

void __cdecl FUN_0046e650(int param_1)

{
  int iVar1;
  uint *puVar2;
  uint local_10 [3];
  
  FUN_0046aa78(local_10,*(uint *)(param_1 + 0x52c) & 0xff,8);
  puVar2 = (uint *)(param_1 + 0x28);
  do {
    *puVar2 = local_10[0];
    puVar2 = puVar2 + 1;
    iVar1 = FUN_0046aab0(local_10);
  } while (iVar1 != 0);
  return;
}



/* @0046e694 file=? name=FUN_0046e694 */

void __cdecl FUN_0046e694(int param_1)

{
  int iVar1;
  int *piVar2;
  int iVar3;
  uint local_10 [3];
  
  FUN_0046aa78(local_10,*(int *)(param_1 + 0x52c) >> 8 & 0xff,8);
  piVar2 = (int *)(param_1 + 0x28);
  do {
    iVar3 = local_10[0] << 8;
    do {
      *piVar2 = iVar3;
      piVar2 = piVar2 + 1;
      iVar1 = FUN_0046aae0(local_10);
    } while (iVar1 != 0);
    iVar3 = FUN_0046aab0(local_10);
  } while (iVar3 != 0);
  return;
}



/* @0046e6ec file=? name=FUN_0046e6ec */

int __cdecl FUN_0046e6ec(int param_1)

{
  FUN_004498a8((undefined4 *)(param_1 + 8));
  return param_1;
}



/* @0046e702 file=? name=FUN_0046e702 */

void __cdecl FUN_0046e702(int *param_1,byte param_2)

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



/* @0046e72c file=? name=FUN_0046e72c */

undefined4 * __cdecl
FUN_0046e72c(undefined4 *param_1,char *param_2,undefined4 param_3,undefined4 param_4)

{
  char cVar1;
  uint uVar2;
  uint uVar3;
  char *pcVar4;
  char *pcVar5;
  
  *(undefined1 *)(param_1 + 2) = 0;
  uVar2 = 0xffffffff;
  do {
    pcVar4 = param_2;
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    pcVar4 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar4;
  } while (cVar1 != '\0');
  uVar2 = ~uVar2;
  pcVar4 = pcVar4 + -uVar2;
  pcVar5 = (char *)(param_1 + 2);
  for (uVar3 = uVar2 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {
    *(undefined4 *)pcVar5 = *(undefined4 *)pcVar4;
    pcVar4 = pcVar4 + 4;
    pcVar5 = pcVar5 + 4;
  }
  for (uVar2 = uVar2 & 3; uVar2 != 0; uVar2 = uVar2 - 1) {
    *pcVar5 = *pcVar4;
    pcVar4 = pcVar4 + 1;
    pcVar5 = pcVar5 + 1;
  }
  *(undefined1 *)((int)param_1 + 0x47) = 0;
  *param_1 = param_3;
  param_1[1] = param_4;
  param_1[0x12] = DAT_00522cc8;
  DAT_00522cc8 = param_1;
  return param_1;
}



/* @0046e788 file=? name=FUN_0046e788 */

undefined4 __cdecl FUN_0046e788(char *param_1)

{
  char *pcVar1;
  bool bVar2;
  int *piVar3;
  char *pcVar4;
  uint uVar5;
  undefined4 *puVar6;
  char *pcVar7;
  char *pcVar8;
  int iVar9;
  undefined4 uVar10;
  bool bVar11;
  char local_120 [256];
  int local_20;
  uint local_1c;
  int *local_18;
  int *local_14;
  int *local_10;
  int *local_c;
  int *local_8;
  
  uVar10 = 0;
  piVar3 = (int *)FUN_00402298(0x20);
  if (piVar3 == (int *)0x0) {
    local_8 = (int *)0x0;
  }
  else {
    local_8 = FUN_00403e84(piVar3,param_1,1);
  }
  local_c = FUN_00404720((int)local_8,s_colors_004f4da5,(char *)0x0);
  if (local_c == (int *)0x0) {
    FUN_004dbb24(&DAT_00524e20,param_1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_has_no__colors__page__004f4dac,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  local_10 = FUN_00404720((int)local_8,s_attributes_004f4dc3,(char *)0x0);
  if (local_10 == (int *)0x0) {
    FUN_004dbb24(&DAT_00524e20,param_1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_has_no__attributes__page__004f4dce,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  local_14 = FUN_00404720((int)local_8,s_groups_004f4de9,(char *)0x0);
  if (local_14 == (int *)0x0) {
    FUN_004dbb24(&DAT_00524e20,param_1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_has_no__groups__page__004f4df0,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  if (((local_10 != (int *)0x0) && (local_c != (int *)0x0)) && (local_14 != (int *)0x0)) {
    DAT_00522cc8 = 0;
    local_18 = (int *)local_14[1];
    while (local_18 != (int *)0x0) {
      pcVar8 = (char *)local_18[1];
      local_1c = 0;
      local_20 = 0;
      if (pcVar8 == (char *)0x0) {
        FUN_004dbb24(&DAT_00524e20,(char *)0x0,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_is_an_empty__GAT_group__004f4e07,(char *)0x0);
        FUN_004d9c38(&DAT_00524e20);
      }
      else {
        while (*pcVar8 != '\0') {
          while (((&DAT_005207dd)[*pcVar8] & 1) != 0) {
            pcVar8 = pcVar8 + 1;
          }
          iVar9 = 0;
          pcVar4 = local_120;
          do {
            if (((&DAT_005207dd)[*pcVar8] & 0xe) == 0) break;
            *pcVar4 = *pcVar8;
            iVar9 = iVar9 + 1;
            pcVar4 = pcVar4 + 1;
            pcVar8 = pcVar8 + 1;
          } while (iVar9 < 0xff);
          *pcVar4 = '\0';
          bVar2 = false;
          for (puVar6 = (undefined4 *)local_c[1]; puVar6 != (undefined4 *)0x0;
              puVar6 = (undefined4 *)*puVar6) {
            pcVar4 = (char *)(puVar6 + 2);
            pcVar7 = local_120;
            do {
              if (*pcVar4 != *pcVar7) goto LAB_0046e9ab;
              bVar11 = true;
              if (*pcVar4 == '\0') break;
              pcVar1 = pcVar4 + 1;
              if (*pcVar1 != pcVar7[1]) goto LAB_0046e9ab;
              pcVar4 = pcVar4 + 2;
              pcVar7 = pcVar7 + 2;
              bVar11 = *pcVar1 == '\0';
            } while (!bVar11);
            if (bVar11) {
              local_20 = FUN_004dd1e0((char *)puVar6[1]);
              bVar2 = true;
              break;
            }
LAB_0046e9ab:
          }
          if (!bVar2) {
            bVar2 = false;
            for (puVar6 = (undefined4 *)local_10[1]; puVar6 != (undefined4 *)0x0;
                puVar6 = (undefined4 *)*puVar6) {
              pcVar4 = (char *)(puVar6 + 2);
              pcVar7 = local_120;
              do {
                if (*pcVar4 != *pcVar7) goto LAB_0046ea00;
                bVar11 = true;
                if (*pcVar4 == '\0') break;
                pcVar1 = pcVar4 + 1;
                if (*pcVar1 != pcVar7[1]) goto LAB_0046ea00;
                pcVar4 = pcVar4 + 2;
                pcVar7 = pcVar7 + 2;
                bVar11 = *pcVar1 == '\0';
              } while (!bVar11);
              if (bVar11) {
                uVar5 = FUN_004dd1e0((char *)puVar6[1]);
                local_1c = local_1c | uVar5;
                bVar2 = true;
                break;
              }
LAB_0046ea00:
            }
            if (!bVar2) {
              FUN_004dbb24(&DAT_00524e20,s_Attribute___004f4e20,(char *)0x0);
              FUN_004dbb24(&DAT_00524e20,local_120,(char *)0x0);
              FUN_004dbb24(&DAT_00524e20,s___not_found__004f4e2c,(char *)0x0);
              FUN_004d9c38(&DAT_00524e20);
            }
          }
        }
      }
      puVar6 = (undefined4 *)FUN_00402298(0x4c);
      if (puVar6 != (undefined4 *)0x0) {
        FUN_0046e72c(puVar6,(char *)(local_18 + 2),local_20,local_1c);
      }
      local_18 = (int *)*local_18;
    }
    if (local_c != (int *)0x0) {
      (**(code **)*local_c)(local_c,3);
    }
    if (local_10 != (int *)0x0) {
      (**(code **)*local_10)(local_10,3);
    }
    if (local_14 != (int *)0x0) {
      (**(code **)*local_14)(local_14,3);
    }
    uVar10 = 1;
  }
  FUN_00403ecc(local_8,3);
  return uVar10;
}



/* @0046eaf0 file=? name=FUN_0046eaf0 */

void FUN_0046eaf0(void)

{
  int *piVar1;
  int *piVar2;
  
  piVar1 = DAT_00522cc8;
  while (piVar2 = piVar1, piVar2 != (int *)0x0) {
    piVar1 = (int *)piVar2[0x12];
    if (piVar2 != (int *)0x0) {
      FUN_004022d0(piVar2);
    }
  }
  DAT_00522cc8 = (int *)0x0;
  return;
}



/* @0046eb18 file=? name=FUN_0046eb18 */

undefined4 __cdecl FUN_0046eb18(char *param_1,undefined4 *param_2,undefined4 *param_3)

{
  undefined4 *puVar1;
  int iVar2;
  
  puVar1 = DAT_00522cc8;
  while( true ) {
    if (puVar1 == (undefined4 *)0x0) {
      return 0;
    }
    iVar2 = FUN_004d4ae0(param_1,(char *)(puVar1 + 2),0x40);
    if (iVar2 == 0) break;
    puVar1 = (undefined4 *)puVar1[0x12];
  }
  *param_2 = *puVar1;
  *param_3 = puVar1[1];
  return 1;
}



/* @0046eb64 file=? name=FUN_0046eb64 */

undefined4 FUN_0046eb64(void)

{
  return 0;
}



/* @0046eb6c file=? name=FUN_0046eb6c */

int * __cdecl FUN_0046eb6c(int param_1)

{
  int iVar1;
  int iVar2;
  int *piVar3;
  int local_14 [4];
  
  piVar3 = (int *)0x0;
  iVar2 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),param_1,0x12);
  if (iVar2 != 0) {
    iVar1 = *(int *)(iVar2 + 4);
    *(int *)(iVar2 + 4) = *(int *)(iVar2 + 4) + 1;
    if (iVar1 == 0) {
      FUN_00406cd0(iVar2);
    }
    FUN_004030dc(local_14,*(undefined4 *)(iVar2 + 0x3c),*(undefined4 *)(iVar2 + 0x40),0);
    if (*(int *)(iVar2 + 0x3c) != 0) {
      piVar3 = (int *)FUN_00402298(0x14);
      if (piVar3 == (int *)0x0) {
        piVar3 = (int *)0x0;
      }
      else {
        piVar3 = FUN_0046ebf0(piVar3,local_14);
      }
    }
    *(int *)(iVar2 + 4) = *(int *)(iVar2 + 4) + -1;
  }
  return piVar3;
}



/* @0046ebf0 file=? name=FUN_0046ebf0 */

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

{
  int extraout_EAX;
  int *piVar1;
  int iVar2;
  int *piVar3;
  
  (**(code **)(*param_2 + 0x1c))(param_2,param_1,4);
  piVar3 = FUN_004de998((int *)0x0,0xc,*param_1,1,&LAB_0046f974);
  param_1[2] = extraout_EAX;
  for (iVar2 = 0; iVar2 < *param_1; iVar2 = iVar2 + 1) {
    (**(code **)(*piVar3 + 0x1c))(piVar3,iVar2 * 0xc + param_1[2],0xc);
  }
  (**(code **)(*piVar3 + 0x1c))(piVar3,param_1 + 1,4);
  iVar2 = FUN_004022b0(param_1[1] << 2);
  param_1[3] = iVar2;
  for (iVar2 = 0; iVar2 < param_1[1]; iVar2 = iVar2 + 1) {
    (**(code **)(*piVar3 + 0x1c))(piVar3,iVar2 * 4 + param_1[3],4);
  }
  iVar2 = FUN_004022b0(param_1[1] << 2);
  param_1[4] = iVar2;
  for (iVar2 = 0; iVar2 < param_1[1]; iVar2 = iVar2 + 1) {
    piVar1 = (int *)FUN_00402298(8);
    if (piVar1 == (int *)0x0) {
      piVar1 = (int *)0x0;
    }
    else {
      piVar1 = FUN_0046f190(piVar1,piVar3);
    }
    *(int **)(param_1[4] + iVar2 * 4) = piVar1;
  }
  return param_1;
}



/* @0046ecdc file=? name=FUN_0046ecdc */

void __cdecl FUN_0046ecdc(int *param_1,byte param_2)

{
  int iVar1;
  
  if (param_1 != (int *)0x0) {
    FUN_004022e8((int *)param_1[2]);
    FUN_004022e8((int *)param_1[3]);
    for (iVar1 = 0; iVar1 < param_1[1]; iVar1 = iVar1 + 1) {
      FUN_0046f1f0(*(int **)(param_1[4] + iVar1 * 4),3);
    }
    FUN_004022e8((int *)param_1[4]);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0046ed34 file=? name=FUN_0046ed34 */

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

{
  int iVar1;
  int *piVar2;
  int *piVar3;
  int *piVar4;
  undefined4 *puVar5;
  int *piVar6;
  char *local_10;
  char *local_c;
  undefined4 local_8;
  
  local_8 = 0xffffffff;
  iVar1 = FUN_00404088(param_3,s_gauge_004f4e39,s_image_004f4e3f,&local_c);
  if (iVar1 != 0) {
    piVar2 = (int *)FUN_004064fc(*(char **)(param_4 + 0x14),local_c);
    piVar3 = (int *)FUN_00402298(0x20);
    if (piVar3 == (int *)0x0) {
      piVar3 = (int *)0x0;
    }
    else {
      piVar3 = FUN_00403e84(piVar3,(char *)piVar2,1);
    }
    iVar1 = FUN_00404088((int)piVar3,s_object_004f4e45,s_gatfile_004f4e4c,&local_10);
    if (iVar1 == 0) {
      FUN_004dbb24(&DAT_00524e20,s_Missing__gat_specification__004f4e54,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
    }
    else {
      piVar4 = (int *)FUN_004064fc(*(char **)(param_4 + 0x14),local_10);
      iVar1 = FUN_0046e788((char *)piVar4);
      if (iVar1 != 0) {
        puVar5 = (undefined4 *)FUN_00402298(0x18);
        if (puVar5 == (undefined4 *)0x0) {
          piVar6 = (int *)0x0;
        }
        else {
          piVar6 = FUN_0040328c(puVar5,0);
        }
        iVar1 = FUN_0046ee84(piVar6,(int)piVar3);
        if (iVar1 == 1) {
          puVar5 = (undefined4 *)FUN_00406f3c(param_1,param_2,0x12,1,0,piVar6,-1);
          local_8 = *puVar5;
        }
        FUN_0046eaf0();
        FUN_00403310(piVar6,3);
      }
      FUN_004022d0(piVar4);
    }
    FUN_00403ecc(piVar3,3);
    FUN_004022d0(piVar2);
  }
  return local_8;
}



/* @0046ee84 file=? name=FUN_0046ee84 */

int __cdecl FUN_0046ee84(int *param_1,int param_2)

{
  undefined4 *puVar1;
  int iVar2;
  int iVar3;
  float10 fVar4;
  float local_28 [3];
  int local_1c;
  float local_18;
  int local_14;
  int *local_10;
  int local_c;
  int *local_8;
  
  iVar3 = 1;
  local_8 = FUN_00404720(param_2,s_vertices_004f4e70,(char *)0x0);
  if (local_8 == (int *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_No__vertices__page_in_the__GIM_f_004f4e79,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    iVar3 = 0;
  }
  else {
    local_c = FUN_00403b60((int)local_8);
    if (local_c < 1) {
      FUN_004dbb24(&DAT_00524e20,s_The__vertices__page_in_the__GIM_f_004f4e9e,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      iVar3 = 0;
    }
    else {
      (**(code **)(*param_1 + 0x20))(param_1,&local_c,4);
      puVar1 = (undefined4 *)local_8[1];
      iVar2 = 0;
      if (0 < local_c) {
        do {
          FUN_00408944((char *)puVar1[1],local_28);
          (**(code **)(*param_1 + 0x20))(param_1,local_28,0xc);
          puVar1 = (undefined4 *)*puVar1;
          iVar2 = iVar2 + 1;
        } while (iVar2 < local_c);
      }
    }
    if (local_8 != (int *)0x0) {
      (**(code **)*local_8)(local_8,3);
    }
  }
  if (iVar3 == 1) {
    local_10 = FUN_00404720(param_2,&DAT_004f4ed3,(char *)0x0);
    if (local_10 == (int *)0x0) {
      FUN_004dbb24(&DAT_00524e20,s_No__lods__page_in_the__GIM_file__004f4ed8,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      iVar3 = 0;
    }
    else {
      local_14 = FUN_00403b60((int)local_10);
      if (local_14 < 1) {
        FUN_004dbb24(&DAT_00524e20,s_The__lod__page_in_the__GIM_file_h_004f4ef9,(char *)0x0);
        FUN_004d9c38(&DAT_00524e20);
        iVar3 = 0;
      }
      else {
        (**(code **)(*param_1 + 0x20))(param_1,&local_14,4);
        iVar2 = 0;
        puVar1 = (undefined4 *)local_10[1];
        if (0 < local_14) {
          do {
            local_1c = puVar1[1];
            if (local_1c == 0) {
              FUN_004dbb24(&DAT_00524e20,s_Missing_scale_value__004f4f29,(char *)0x0);
              FUN_004d9c38(&DAT_00524e20);
              iVar3 = 0;
              break;
            }
            fVar4 = (float10)FUN_004dd1cc(local_1c);
            local_18 = (float)fVar4;
            (**(code **)(*param_1 + 0x20))(param_1,&local_18,4);
            puVar1 = (undefined4 *)*puVar1;
            iVar2 = iVar2 + 1;
          } while (iVar2 < local_14);
        }
        iVar2 = 0;
        puVar1 = (undefined4 *)local_10[1];
        if (0 < local_14) {
          do {
            iVar3 = FUN_0046f234(param_1,param_2,(char *)(puVar1 + 2));
            if (iVar3 == 0) break;
            puVar1 = (undefined4 *)*puVar1;
            iVar2 = iVar2 + 1;
          } while (iVar2 < local_14);
        }
      }
    }
    if (local_10 != (int *)0x0) {
      (**(code **)*local_10)(local_10,3);
    }
  }
  return iVar3;
}



/* @0046f0c0 file=? name=FUN_0046f0c0 */

void __cdecl
FUN_0046f0c0(int *param_1,float param_2,float param_3,int *param_4,int param_5,float *param_6,
            int param_7)

{
  int iVar1;
  undefined4 *puVar2;
  float *pfVar3;
  int iVar4;
  float local_34 [12];
  
  if (DAT_004f4da4 == '\0') {
    FUN_004de998((int *)&DAT_00522ccc,0xc,100,1,&LAB_0046f974);
    DAT_004f4da4 = DAT_004f4da4 + '\x01';
  }
  FUN_0040aadc(local_34);
  iVar1 = FUN_0040af88(param_6,local_34);
  if (iVar1 == 0) {
    iVar1 = 0;
    for (pfVar3 = (float *)param_1[3]; (iVar1 < param_1[1] && (*pfVar3 < param_2));
        pfVar3 = pfVar3 + 1) {
      iVar1 = iVar1 + 1;
    }
    if (iVar1 < param_1[1]) {
      puVar2 = &DAT_0052317c;
      for (iVar4 = 0; iVar4 < *param_1; iVar4 = iVar4 + 1) {
        *puVar2 = 0;
        puVar2 = puVar2 + 1;
      }
      FUN_0046f374(*(int **)(param_1[4] + iVar1 * 4),param_4,param_5,param_6,param_1[2],0x522ccc,
                   0x52317c,param_3,param_7);
    }
  }
  return;
}



/* @0046f184 file=? name=FUN_0046f184 */

undefined4 FUN_0046f184(void)

{
  return 1;
}



/* @0046f190 file=? name=FUN_0046f190 */

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

{
  int iVar1;
  int iVar2;
  
  (**(code **)(*param_2 + 0x1c))(param_2,param_1,4);
  iVar1 = FUN_004022b0(*param_1 << 2);
  param_1[1] = iVar1;
  for (iVar1 = 0; iVar1 < *param_1; iVar1 = iVar1 + 1) {
    iVar2 = FUN_00402298(0x14);
    if (iVar2 == 0) {
      iVar2 = 0;
    }
    else {
      iVar2 = FUN_0046f468(iVar2,param_2);
    }
    *(int *)(param_1[1] + iVar1 * 4) = iVar2;
  }
  return param_1;
}



/* @0046f1f0 file=? name=FUN_0046f1f0 */

void __cdecl FUN_0046f1f0(int *param_1,byte param_2)

{
  int iVar1;
  
  if (param_1 != (int *)0x0) {
    for (iVar1 = 0; iVar1 < *param_1; iVar1 = iVar1 + 1) {
      FUN_0046f500(*(int **)(param_1[1] + iVar1 * 4),3);
    }
    FUN_004022e8((int *)param_1[1]);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0046f234 file=? name=FUN_0046f234 */

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

{
  undefined4 *puVar1;
  int iVar2;
  int iVar3;
  int local_c;
  int *local_8;
  
  iVar2 = 1;
  local_8 = FUN_00404720(param_2,param_3,(char *)0x0);
  if (local_8 == (int *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_Can_t_find_the___004f4f3e,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___page_in_the__GIM_file__004f4f4f,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    iVar2 = 0;
  }
  else {
    local_c = FUN_00403b60((int)local_8);
    if (local_c < 1) {
      FUN_004dbb24(&DAT_00524e20,s_The___004f4f68,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s___page_in_the__GIM_file_has_no_e_004f4f6e,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      iVar2 = 0;
    }
    else {
      (**(code **)(*param_1 + 0x20))(param_1,&local_c,4);
      iVar3 = 0;
      puVar1 = (undefined4 *)local_8[1];
      if (0 < local_c) {
        do {
          iVar2 = FUN_0046f530(param_1,(char *)(puVar1 + 2),(char *)puVar1[1]);
          if (iVar2 == 0) break;
          puVar1 = (undefined4 *)*puVar1;
          iVar3 = iVar3 + 1;
        } while (iVar3 < local_c);
      }
    }
    if (local_8 != (int *)0x0) {
      (**(code **)*local_8)(local_8,3);
    }
  }
  return iVar2;
}



/* @0046f368 file=? name=FUN_0046f368 */

undefined4 FUN_0046f368(void)

{
  return 1;
}



/* @0046f374 file=? name=FUN_0046f374 */

void __cdecl
FUN_0046f374(int *param_1,int *param_2,int param_3,float *param_4,int param_5,int param_6,
            int param_7,float param_8,int param_9)

{
  byte *pbVar1;
  int iVar2;
  int local_18;
  int local_14;
  int local_10;
  int local_c;
  undefined4 *local_8;
  
  local_8 = (undefined4 *)param_1[1];
  if (param_9 == 0) {
    for (iVar2 = 0; iVar2 < *param_1; iVar2 = iVar2 + 1) {
      pbVar1 = (byte *)*local_8;
      local_8 = local_8 + 1;
      FUN_0046f774(pbVar1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,(int *)0x0);
    }
  }
  else {
    FUN_00407bd0(&local_18,9999,9999,0xffffd8f1,0xffffd8f1);
    for (iVar2 = 0; iVar2 < *param_1; iVar2 = iVar2 + 1) {
      pbVar1 = (byte *)*local_8;
      local_8 = local_8 + 1;
      FUN_0046f774(pbVar1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,&local_18);
    }
    (**(code **)(*param_2 + 0x18))(param_2,param_9);
    (**(code **)(*param_2 + 0x24))(param_2,local_18 + -4,local_14 + -4);
    (**(code **)(*param_2 + 0x40))(param_2,local_10 + 4,local_c + 4);
  }
  return;
}



/* @0046f468 file=? name=FUN_0046f468 */

int __cdecl FUN_0046f468(int param_1,int *param_2)

{
  undefined4 uVar1;
  int iVar2;
  int local_8;
  
  (**(code **)(*param_2 + 0x1c))(param_2,&local_8,4);
  *(int *)(param_1 + 8) = local_8;
  if (local_8 == 0) {
    (**(code **)(*param_2 + 0x1c))(param_2,param_1 + 4,4);
    (**(code **)(*param_2 + 0x1c))(param_2,param_1,4);
    (**(code **)(*param_2 + 0x1c))(param_2,param_1 + 0xc,4);
    uVar1 = FUN_004022b0(*(int *)(param_1 + 0xc) << 2);
    *(undefined4 *)(param_1 + 0x10) = uVar1;
    for (iVar2 = 0; iVar2 < *(int *)(param_1 + 0xc); iVar2 = iVar2 + 1) {
      (**(code **)(*param_2 + 0x1c))(param_2,iVar2 * 4 + *(int *)(param_1 + 0x10),4);
    }
  }
  return param_1;
}



/* @0046f500 file=? name=FUN_0046f500 */

void __cdecl FUN_0046f500(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    if (param_1[2] == 0) {
      FUN_004022e8((int *)param_1[4]);
    }
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0046f530 file=? name=FUN_0046f530 */

/* WARNING: Type propagation algorithm not settling */

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

{
  char cVar1;
  int iVar2;
  char *pcVar3;
  char local_158 [64];
  int local_118 [64];
  undefined4 local_18;
  int local_14 [4];
  
  local_14[2] = 0;
  local_14[1] = 0;
  local_14[0] = 0;
  local_18 = 1;
  iVar2 = FUN_004d4b58(param_2,s_linelist_004f4f96);
  if (iVar2 == 0) {
    local_14[3] = 0;
    (**(code **)(*param_1 + 0x20))(param_1,local_14 + 3,4);
    while (*param_3 != '\0') {
      while (((&DAT_005207dd)[*param_3] & 1) != 0) {
        param_3 = param_3 + 1;
      }
      if (*param_3 == 'v') {
        iVar2 = 0;
        while( true ) {
          param_3 = param_3 + 1;
          if (((&DAT_005207dd)[*param_3] & 2) == 0) break;
          iVar2 = (int)*param_3 + iVar2 * 10 + -0x30;
        }
        if (local_14[0] < 0x40) {
          local_118[local_14[0]] = iVar2;
          local_14[0] = local_14[0] + 1;
        }
      }
      else if (*param_3 == 'a') {
        iVar2 = 0;
        pcVar3 = local_158;
        do {
          cVar1 = *param_3;
          if ((((&DAT_005207dd)[cVar1] & 1) != 0) || (cVar1 == '\0')) break;
          *pcVar3 = cVar1;
          iVar2 = iVar2 + 1;
          param_3 = param_3 + 1;
          pcVar3 = pcVar3 + 1;
        } while (iVar2 < 0x3f);
        *pcVar3 = '\0';
        iVar2 = FUN_0046eb18(local_158,local_14 + 1,local_14 + 2);
        if (iVar2 == 0) {
          FUN_004dbb24(&DAT_00524e20,s_Couldn_t_find_attribute_group___004f4f9f,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,local_158,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,&DAT_004f4fbf,(char *)0x0);
          FUN_004d9c38(&DAT_00524e20);
        }
      }
    }
    (**(code **)(*param_1 + 0x20))(param_1,local_14 + 1,4);
    (**(code **)(*param_1 + 0x20))(param_1,local_14 + 2,4);
    if (local_14[0] == 0) {
      FUN_004dbb24(&DAT_00524e20,s_No_vertex_indices_in_primitive__004f4fc2,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      local_18 = 0;
    }
    else {
      (**(code **)(*param_1 + 0x20))(param_1,local_14,4);
      iVar2 = 0;
      if (0 < local_14[0]) {
        do {
          (**(code **)(*param_1 + 0x20))(param_1,local_118 + iVar2,4);
          iVar2 = iVar2 + 1;
        } while (iVar2 < local_14[0]);
      }
    }
  }
  else {
    FUN_004dbb24(&DAT_00524e20,s_Unsupported_primitive___004f4fe2,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___in__GIM_file__004f4ffa,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    local_18 = 0;
  }
  return local_18;
}



/* @0046f768 file=? name=FUN_0046f768 */

undefined4 FUN_0046f768(void)

{
  return 1;
}



/* @0046f774 file=? name=FUN_0046f774 */

int __cdecl
FUN_0046f774(byte *param_1,int *param_2,int param_3,float *param_4,int param_5,int param_6,
            int param_7,float param_8,int *param_9)

{
  int iVar1;
  int iVar2;
  undefined4 uVar3;
  undefined4 uVar4;
  int *piVar5;
  
  iVar2 = *(int *)(param_1 + 8) + -1;
  if ((*(int *)(param_1 + 8) == 0) && (1 < *(int *)(param_1 + 0xc))) {
    if (*(int *)(param_1 + 4) != 0) {
      param_3 = *(int *)(param_1 + 4);
    }
    (**(code **)(*param_2 + 0x18))(param_2,param_3);
    piVar5 = *(int **)(param_1 + 0x10);
    iVar2 = *piVar5;
    FUN_0046f888(param_1,param_4,(float *)(iVar2 * 0xc + param_5),(float *)(iVar2 * 0xc + param_6),
                 (int *)(iVar2 * 4 + param_7),param_8,param_9);
    uVar3 = FUN_004dcd94();
    uVar4 = FUN_004dcd94();
    (**(code **)(*param_2 + 0x24))(param_2,uVar4,uVar3);
    iVar2 = *(int *)(param_1 + 0xc);
    while (iVar2 = iVar2 + -1, 0 < iVar2) {
      piVar5 = piVar5 + 1;
      iVar1 = *piVar5;
      FUN_0046f888(param_1,param_4,(float *)(iVar1 * 0xc + param_5),(float *)(iVar1 * 0xc + param_6)
                   ,(int *)(iVar1 * 4 + param_7),param_8,param_9);
      uVar3 = FUN_004dcd94();
      uVar4 = FUN_004dcd94();
      (**(code **)(*param_2 + 0x30))(param_2,uVar4,uVar3);
    }
  }
  return iVar2;
}



/* @0046f888 file=? name=FUN_0046f888 */

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

void __cdecl
FUN_0046f888(byte *param_1,float *param_2,float *param_3,float *param_4,int *param_5,float param_6,
            int *param_7)

{
  int iVar1;
  float local_14 [3];
  float local_8;
  
  if (*param_5 == 0) {
    if ((*param_1 & 1) == 0) {
      FUN_00408b98(param_4,param_3,param_2);
    }
    else {
      FUN_00408440(local_14,param_3);
      local_8 = param_6;
      FUN_004086ac(local_14,local_14,param_6);
      FUN_00408b98(param_4,local_14,param_2);
    }
    *param_4 = *param_4 + _DAT_0046f970;
    param_4[2] = -param_4[2] + _DAT_0046f970;
    *param_5 = 1;
  }
  if (param_7 != (int *)0x0) {
    if (*param_4 < (float)*param_7) {
      iVar1 = FUN_004dcd94();
      *param_7 = iVar1;
    }
    if ((float)param_7[2] < *param_4) {
      iVar1 = FUN_004dcd94();
      param_7[2] = iVar1;
    }
    if (param_4[2] < (float)param_7[1]) {
      iVar1 = FUN_004dcd94();
      param_7[1] = iVar1;
    }
    if ((float)param_7[3] < param_4[2]) {
      iVar1 = FUN_004dcd94();
      param_7[3] = iVar1;
    }
  }
  return;
}



/* @0046f97c file=? name=FUN_0046f97c */

undefined4 * __cdecl FUN_0046f97c(undefined4 *param_1)

{
  bool bVar1;
  bool bVar2;
  bool bVar3;
  bool bVar4;
  bool bVar5;
  bool bVar6;
  bool bVar7;
  bool bVar8;
  char *pcVar9;
  char *pcVar10;
  int iVar11;
  undefined4 *puVar12;
  undefined3 extraout_var;
  undefined3 extraout_var_00;
  undefined3 extraout_var_01;
  undefined3 extraout_var_02;
  undefined3 extraout_var_03;
  undefined3 extraout_var_04;
  undefined3 extraout_var_05;
  undefined3 extraout_var_06;
  int *piVar13;
  int local_44 [8];
  int local_24;
  int local_20;
  int local_1c;
  int local_18;
  int local_14;
  int local_10;
  int local_c;
  uint local_8;
  
  FUN_00447890(param_1);
  *param_1 = &PTR_FUN_004f56a4;
  param_1[0x714b] = 0;
  param_1[0x714c] = 0;
  param_1[0x714a] = 1;
  param_1[0x714d] = 0;
  pcVar9 = (char *)FUN_004dee74(s_L4GAUGE_004f5631);
  if (pcVar9 != (char *)0x0) {
    pcVar10 = (char *)FUN_004dee74(s_L4PLASMA_004f5639);
    if (pcVar10 != (char *)0x0) {
      iVar11 = FUN_004d4bec(pcVar10,&DAT_004f5642,4);
      if (iVar11 == 0) {
        puVar12 = (undefined4 *)FUN_00402298(100);
        if (puVar12 == (undefined4 *)0x0) {
          puVar12 = (undefined4 *)0x0;
        }
        else {
          puVar12 = FUN_004750b4(puVar12,0x2f8,0xb);
        }
        param_1[0x714c] = puVar12;
      }
      else {
        puVar12 = (undefined4 *)FUN_00402298(100);
        if (puVar12 == (undefined4 *)0x0) {
          puVar12 = (undefined4 *)0x0;
        }
        else {
          puVar12 = FUN_004750b4(puVar12,0x3f8,0xc);
        }
        param_1[0x714c] = puVar12;
      }
    }
    FUN_00403e84(local_44,s_GAUGE_L4GAUGE_INI_004f5647,1);
    iVar11 = FUN_00403f84((int)local_44,pcVar9);
    if (iVar11 != 0) {
      local_8 = 0;
      local_c = 0x280;
      local_10 = 0x1e0;
      local_14 = 0x40;
      local_18 = 0x40;
      local_1c = 0x500;
      local_20 = 0;
      local_24 = 0;
      bVar1 = FUN_004040d8((int)local_44,pcVar9,&DAT_004f5659,(int *)&local_8);
      bVar2 = FUN_004040d8((int)local_44,pcVar9,s_width_004f565e,&local_c);
      bVar3 = FUN_004040d8((int)local_44,pcVar9,s_height_004f5664,&local_10);
      bVar4 = FUN_004040d8((int)local_44,pcVar9,s_sizeInKB_004f566b,&local_14);
      bVar5 = FUN_004040d8((int)local_44,pcVar9,s_granularityInKB_004f5674,&local_18);
      bVar6 = FUN_004040d8((int)local_44,pcVar9,s_bytesPerLine_004f5684,&local_1c);
      bVar7 = FUN_004040d8((int)local_44,pcVar9,s_pageFcnPtr_004f5691,&local_20);
      bVar8 = FUN_004040d8((int)local_44,pcVar9,s_special_004f569c,&local_24);
      if (CONCAT31(extraout_var,bVar1) + CONCAT31(extraout_var_00,bVar2) +
          CONCAT31(extraout_var_01,bVar3) + CONCAT31(extraout_var_02,bVar4) +
          CONCAT31(extraout_var_03,bVar5) + CONCAT31(extraout_var_04,bVar6) +
          CONCAT31(extraout_var_05,bVar7) + CONCAT31(extraout_var_06,bVar8) == 8) {
        piVar13 = (int *)FUN_00402298(0xcf0);
        if (piVar13 == (int *)0x0) {
          piVar13 = (int *)0x0;
        }
        else {
          piVar13 = FUN_0046ced4(piVar13,local_8,local_c,local_10,local_14,local_18,local_1c,
                                 local_20,local_24);
        }
        param_1[0x714b] = piVar13;
      }
    }
    FUN_00403ecc(local_44,2);
  }
  return param_1;
}



/* @0046fbcc file=? name=FUN_0046fbcc */

void __cdecl FUN_0046fbcc(int *param_1,byte param_2)

{
  undefined4 *puVar1;
  int *piVar2;
  int iVar3;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004f56a4;
    FUN_00447fc0((int)param_1,0);
    iVar3 = 0;
    piVar2 = param_1 + 0x15;
    do {
      puVar1 = (undefined4 *)*piVar2;
      if ((puVar1 != (undefined4 *)0x0) && (puVar1 != (undefined4 *)0x0)) {
        (**(code **)*puVar1)(puVar1,3);
      }
      iVar3 = iVar3 + 1;
      piVar2 = piVar2 + 1;
    } while (iVar3 < 0x10);
    puVar1 = (undefined4 *)param_1[0x714b];
    if ((puVar1 != (undefined4 *)0x0) && (puVar1 != (undefined4 *)0x0)) {
      (**(code **)*puVar1)(puVar1,3);
    }
    puVar1 = (undefined4 *)param_1[0x714c];
    if ((puVar1 != (undefined4 *)0x0) && (puVar1 != (undefined4 *)0x0)) {
      (**(code **)*puVar1)(puVar1,3);
    }
    FUN_00447a14(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0046fc5c file=? name=FUN_0046fc5c */

void __cdecl FUN_0046fc5c(int param_1)

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



/* @0046fc88 file=? name=FUN_0046fc88 */

void __cdecl FUN_0046fc88(int param_1)

{
  FUN_00447b60(param_1);
  return;
}



/* @0046fc98 file=? name=FUN_0046fc98 */

void FUN_0046fc98(void)

{
  FUN_00447e64();
  return;
}



