/* @00401000 file=? name=entry */

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

void entry(void)

{
  int *piVar1;
  int iVar2;
  undefined4 *puVar3;
  undefined2 in_FS;
  undefined **ppuVar4;
  
  _DAT_004e005d = DAT_004e0059 << 2;
  puVar3 = &DAT_00521404;
  for (iVar2 = 0x3f30; iVar2 != 0; iVar2 = iVar2 + -1) {
    *(undefined1 *)puVar3 = 0;
    puVar3 = (undefined4 *)((int)puVar3 + 1);
  }
  piVar1 = (int *)segment(in_FS,4);
  iVar2 = *piVar1;
  _DAT_004e0061 = *(undefined4 *)(iVar2 + -8);
  _DAT_004e0065 = *(undefined4 *)(iVar2 + -4);
  DAT_00524c68 = iVar2 + -4;
  FUN_004d67cf(0);
  ppuVar4 = &PTR_DAT_004e002c;
  _DAT_004e006a = GetModuleHandleA((LPCSTR)0x0);
  FUN_004df558((int)ppuVar4);
  return;
}



/* @0040106e file=? name=__GetExceptDLLinfo */

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

void __cdecl __GetExceptDLLinfo(undefined4 *param_1)

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



/* @0040109c file=? name=FUN_0040109c */

undefined4 __cdecl FUN_0040109c(int param_1,undefined4 param_2)

{
  int iVar1;
  char *pcVar2;
  undefined4 *puVar3;
  int *piVar4;
  undefined4 *puVar5;
  undefined4 extraout_ECX;
  int extraout_EDX;
  int iVar6;
  int iVar7;
  undefined8 uVar8;
  undefined4 uVar9;
  int local_8c [33];
  undefined4 *local_8;
  
  FUN_004dbb24(&DAT_00524e20,s_BattleTech_v4_10_004e037c,(char *)0x0);
  FUN_004d9c38(&DAT_00524e20);
  iVar1 = FUN_0047b2ec(param_1,param_2,&LAB_0047af8c);
  if (iVar1 == 0) {
    uVar9 = 1;
  }
  else {
    FUN_00407218(local_8c,s_btl4_res_004e038d,&DAT_004e0070,3);
    iVar1 = DAT_004fd550;
    if (DAT_004fd550 < 1) {
      puVar3 = (undefined4 *)FUN_00402298(0x28);
      if (puVar3 == (undefined4 *)0x0) {
        puVar3 = (undefined4 *)0x0;
      }
      else {
        puVar3 = FUN_0044f29c(puVar3,DAT_0052140c);
      }
      puVar5 = (undefined4 *)FUN_00402298(0xd4);
      if (puVar5 == (undefined4 *)0x0) {
        piVar4 = (int *)0x0;
      }
      else {
        piVar4 = FUN_004d34c4(puVar5,local_8c,0x3eb,&DAT_0051e8d8);
      }
      FUN_0044f318((int)puVar3,piVar4);
    }
    else {
      iVar7 = 0x800000;
      pcVar2 = (char *)FUN_004dee74(s_SPOOLSIZE_004e0396);
      if (pcVar2 != (char *)0x0) {
        FUN_004dbb24(&DAT_00524e20,s_Spool_size___004e03a0,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,pcVar2,(char *)0x0);
        FUN_004d9c38(&DAT_00524e20);
        iVar7 = FUN_004dd1e0(pcVar2);
        if (iVar7 == 0) {
          iVar7 = 0x800000;
        }
      }
      uVar9 = 0x38;
      uVar8 = FUN_00402298(0x38);
      iVar6 = (int)((ulonglong)uVar8 >> 0x20);
      if ((undefined4 *)uVar8 == (undefined4 *)0x0) {
        puVar3 = (undefined4 *)0x0;
      }
      else {
        uVar9 = 1;
        if (iVar1 != 2) {
          uVar9 = 2;
        }
        puVar3 = FUN_0044f8b8((undefined4 *)uVar8,DAT_0052140c,uVar9,iVar7);
        uVar9 = extraout_ECX;
        iVar6 = extraout_EDX;
      }
      uVar8 = FUN_0044fa14(uVar9,iVar6,(int)puVar3);
      if ((int)uVar8 != 0) {
        local_8 = (undefined4 *)FUN_00402298(0xd8);
        if (local_8 == (undefined4 *)0x0) {
          piVar4 = (int *)0x0;
        }
        else {
          piVar4 = FUN_004d3be4(local_8,local_8c,(int)uVar8);
        }
        FUN_0044f318((int)puVar3,piVar4);
      }
      if (iVar1 == 1) {
        puVar5 = (undefined4 *)FUN_00402298(0xd8);
        if (puVar5 == (undefined4 *)0x0) {
          piVar4 = (int *)0x0;
        }
        else {
          piVar4 = FUN_0047c3fc(puVar5,local_8c,1);
        }
        FUN_0044f318((int)puVar3,piVar4);
      }
    }
    FUN_0044f344((int)puVar3);
    if (puVar3 != (undefined4 *)0x0) {
      (**(code **)*puVar3)(puVar3,3);
    }
    FUN_00407354(local_8c,2);
    uVar9 = DAT_004efc98;
  }
  return uVar9;
}



/* @004012a8 file=? name=FUN_004012a8 */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e0628;
  return param_1;
}



/* @004012c7 file=? name=FUN_004012c7 */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e0628;
  return param_1;
}



/* @004012e6 file=? name=FUN_004012e6 */

void __cdecl FUN_004012e6(int *param_1,byte param_2)

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



/* @00401312 file=? name=FUN_00401312 */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e05cc;
  return param_1;
}



/* @00401331 file=? name=FUN_00401331 */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e05cc;
  return param_1;
}



/* @00401350 file=? name=FUN_00401350 */

void __cdecl FUN_00401350(int *param_1,byte param_2)

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



/* @0040137c file=? name=FUN_0040137c */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e0570;
  return param_1;
}



/* @0040139b file=? name=FUN_0040139b */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e0570;
  return param_1;
}



/* @004013ba file=? name=FUN_004013ba */

void __cdecl FUN_004013ba(int *param_1,byte param_2)

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



/* @004013e6 file=? name=FUN_004013e6 */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e0514;
  return param_1;
}



/* @00401405 file=? name=FUN_00401405 */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e0514;
  return param_1;
}



/* @00401424 file=? name=FUN_00401424 */

void __cdecl FUN_00401424(int *param_1,byte param_2)

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



/* @00401450 file=? name=FUN_00401450 */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e04b8;
  return param_1;
}



/* @0040146f file=? name=FUN_0040146f */

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

{
  FUN_004194d8(param_1,param_2);
  *param_1 = &PTR_FUN_004e04b8;
  return param_1;
}



/* @0040148e file=? name=FUN_0040148e */

void __cdecl FUN_0040148e(int *param_1,byte param_2)

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



/* @004014ba file=? name=FUN_004014ba */

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

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



/* @004014d9 file=? name=FUN_004014d9 */

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

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



/* @004014f8 file=? name=FUN_004014f8 */

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

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



/* @00401517 file=? name=FUN_00401517 */

void __cdecl FUN_00401517(int *param_1,byte param_2)

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



/* @00401543 file=? name=FUN_00401543 */

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

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



/* @00401562 file=? name=FUN_00401562 */

void __cdecl FUN_00401562(int *param_1,byte param_2)

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



/* @0040158e file=? name=FUN_0040158e */

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

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



/* @004015ad file=? name=FUN_004015ad */

void __cdecl FUN_004015ad(int *param_1,byte param_2)

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



/* @004015d9 file=? name=FUN_004015d9 */

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

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



/* @004015f8 file=? name=FUN_004015f8 */

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

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



/* @00401617 file=? name=FUN_00401617 */

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

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



/* @00401636 file=? name=FUN_00401636 */

void __cdecl FUN_00401636(int *param_1,byte param_2)

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



/* @00401662 file=? name=FUN_00401662 */

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

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



/* @00401681 file=? name=FUN_00401681 */

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

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



/* @004016a0 file=? name=FUN_004016a0 */

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

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



/* @004016bf file=? name=FUN_004016bf */

void __cdecl FUN_004016bf(int *param_1,byte param_2)

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



/* @004016eb file=? name=FUN_004016eb */

void __cdecl FUN_004016eb(int *param_1)

{
  (**(code **)(*param_1 + 0x38))(param_1);
  return;
}



/* @004016fa file=? name=FUN_004016fa */

void __cdecl FUN_004016fa(int *param_1)

{
  (**(code **)(*param_1 + 0x3c))(param_1);
  return;
}



/* @00401709 file=? name=FUN_00401709 */

void __cdecl FUN_00401709(int *param_1)

{
  (**(code **)(*param_1 + 0x40))(param_1);
  return;
}



/* @00401718 file=? name=FUN_00401718 */

void __cdecl FUN_00401718(int *param_1)

{
  (**(code **)(*param_1 + 0x44))(param_1);
  return;
}



/* @00401727 file=? name=FUN_00401727 */

int * __cdecl FUN_00401727(int *param_1)

{
  (**(code **)(*param_1 + 4))(param_1);
  return param_1;
}



/* @0040173a file=? name=FUN_0040173a */

int * __cdecl FUN_0040173a(int *param_1)

{
  (**(code **)(*param_1 + 8))(param_1);
  return param_1;
}



/* @0040174d file=? name=FUN_0040174d */

int * __cdecl FUN_0040174d(int *param_1)

{
  (**(code **)(*param_1 + 0xc))(param_1);
  return param_1;
}



/* @00401760 file=? name=FUN_00401760 */

int * __cdecl FUN_00401760(int *param_1)

{
  (**(code **)(*param_1 + 0x10))(param_1);
  return param_1;
}



/* @00401774 file=? name=FUN_00401774 */

uint __cdecl FUN_00401774(LPCSTR param_1,int param_2)

{
  char cVar1;
  int iVar2;
  uint uVar3;
  uint uVar4;
  char *pcVar5;
  uint unaff_EDI;
  short *psVar6;
  
  iVar2 = DAT_004f0760;
  if ((DAT_004f0760 == 0) || (param_2 != 0)) {
    if (param_2 == 0) {
      uVar3 = thunk_FUN_004d93ac(param_1,0x8301,0x80);
    }
    else {
      uVar3 = thunk_FUN_004d93ac(param_1,0x8000,unaff_EDI);
    }
  }
  else {
    *(undefined2 *)(DAT_004f0760 + 6) = 0xc;
    *(undefined2 *)(iVar2 + 10) = 0x54;
    uVar3 = 0xffffffff;
    do {
      pcVar5 = param_1;
      if (uVar3 == 0) break;
      uVar3 = uVar3 - 1;
      pcVar5 = param_1 + 1;
      cVar1 = *param_1;
      param_1 = pcVar5;
    } while (cVar1 != '\0');
    uVar3 = ~uVar3;
    pcVar5 = pcVar5 + -uVar3;
    psVar6 = (short *)(iVar2 + 0xc);
    for (uVar4 = uVar3 >> 2; uVar4 != 0; uVar4 = uVar4 - 1) {
      *(undefined4 *)psVar6 = *(undefined4 *)pcVar5;
      pcVar5 = pcVar5 + 4;
      psVar6 = psVar6 + 2;
    }
    for (uVar4 = uVar3 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
      *(char *)psVar6 = *pcVar5;
      pcVar5 = pcVar5 + 1;
      psVar6 = (short *)((int)psVar6 + 1);
    }
    *(undefined2 *)(iVar2 + 0x5c) = 0x8302;
    *(undefined2 *)(iVar2 + 0x5e) = 0x80;
    FUN_00452100(0,uVar3);
    uVar3 = (int)*(short *)(iVar2 + 0xc) | 0x10000;
  }
  return uVar3;
}



/* @00401810 file=? name=FUN_00401810 */

undefined8 __cdecl FUN_00401810(uint param_1)

{
  int iVar1;
  undefined4 uVar2;
  undefined2 *puVar3;
  undefined4 extraout_EDX;
  undefined8 uVar4;
  
  iVar1 = DAT_004f0760;
  if ((param_1 & 0x10000) != 0) {
    puVar3 = (undefined2 *)(DAT_004f0760 + 0xc);
    *(undefined2 *)(DAT_004f0760 + 6) = 0xe;
    *(undefined2 *)(iVar1 + 10) = 2;
    *puVar3 = (short)param_1;
    uVar4 = FUN_00452100(puVar3,iVar1);
    return uVar4;
  }
  uVar2 = thunk_FUN_004d92c4(param_1);
  return CONCAT44(extraout_EDX,uVar2);
}



/* @0040184c file=? name=FUN_0040184c */

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

{
  undefined2 *puVar1;
  DWORD DVar2;
  DWORD *pDVar3;
  int iVar4;
  int iVar5;
  
  iVar5 = DAT_004f0760;
  if ((param_1 & 0x10000) == 0) {
    iVar5 = 2;
    if (param_3 == 0) {
      iVar5 = 0;
    }
    DVar2 = thunk_FUN_004d9334(param_1,param_2,iVar5);
  }
  else {
    pDVar3 = (DWORD *)(DAT_004f0760 + 0xc);
    puVar1 = (undefined2 *)(DAT_004f0760 + 0xc);
    *(undefined2 *)(DAT_004f0760 + 6) = 0x13;
    *(undefined2 *)(iVar5 + 10) = 8;
    iVar4 = CONCAT22((short)((uint)iVar5 >> 0x10),2);
    *puVar1 = (short)param_1;
    if (param_3 == 0) {
      iVar4 = iVar4 + -2;
    }
    *(short *)(iVar5 + 0xe) = (short)iVar4;
    *(LONG *)(iVar5 + 0x10) = param_2;
    FUN_00452100(pDVar3,iVar4);
    DVar2 = *pDVar3;
  }
  return DVar2;
}



/* @004018cc file=? name=FUN_004018cc */

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

{
  int iVar1;
  int iVar2;
  char *pcVar3;
  undefined4 extraout_ECX;
  undefined4 extraout_EDX;
  char *pcVar4;
  undefined2 *puVar5;
  undefined2 local_8;
  
  iVar2 = DAT_004f0760;
  if ((param_1 & 0x10000) == 0) {
    param_3 = thunk_FUN_004d8b14(param_1,param_2,param_3);
  }
  else {
    puVar5 = (undefined2 *)(DAT_004f0760 + 0xc);
    iVar1 = DAT_004f0760;
    for (pcVar4 = param_3; DAT_004f0760 = iVar1, pcVar4 != (char *)0x0;
        pcVar4 = pcVar4 + -(int)pcVar3) {
      pcVar3 = pcVar4;
      if ((char *)0xff00 < pcVar4) {
        pcVar3 = (char *)0xff00;
      }
      *(undefined2 *)(iVar1 + 6) = 0xd;
      *(short *)(iVar1 + 10) = (short)pcVar3 + 4;
      local_8 = (undefined2)param_1;
      *puVar5 = local_8;
      *(short *)(iVar2 + 0xe) = (short)pcVar3;
      FUN_004d4918((undefined4 *)(iVar2 + 0x10),(undefined4 *)param_2,(uint)pcVar3);
      FUN_00452100(extraout_ECX,extraout_EDX);
      param_2 = param_2 + (int)pcVar3;
      iVar1 = DAT_004f0760;
    }
  }
  return param_3;
}



/* @00401970 file=? name=FUN_00401970 */

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

{
  int iVar1;
  int iVar2;
  undefined4 *puVar3;
  char *pcVar4;
  char *pcVar5;
  
  iVar2 = DAT_004f0760;
  if ((param_1 & 0x10000) == 0) {
    param_3 = thunk_FUN_004d892c(param_1,param_2,param_3);
  }
  else {
    puVar3 = (undefined4 *)(DAT_004f0760 + 0xc);
    iVar1 = DAT_004f0760;
    for (pcVar5 = param_3; DAT_004f0760 = iVar1, pcVar5 != (char *)0x0;
        pcVar5 = pcVar5 + -(int)pcVar4) {
      pcVar4 = pcVar5;
      if ((char *)0xff00 < pcVar5) {
        pcVar4 = (char *)0xff00;
      }
      *(undefined2 *)(iVar1 + 6) = 0x12;
      *(undefined2 *)(iVar1 + 10) = 4;
      *(short *)puVar3 = (short)param_1;
      *(short *)(iVar2 + 0xe) = (short)pcVar4;
      FUN_00452100(puVar3,param_1);
      FUN_004d4918((undefined4 *)param_2,puVar3,(uint)pcVar4);
      param_2 = param_2 + (int)pcVar4;
      iVar1 = DAT_004f0760;
    }
  }
  return param_3;
}



/* @00401a1c file=? name=FUN_00401a1c */

int FUN_00401a1c(void)

{
  int iVar1;
  
  if (DAT_004e0688 == 0xffff) {
    iVar1 = FUN_004d418d();
    if (iVar1 < DAT_004e068c) {
      DAT_004e0684 = DAT_004e0684 + -0x1800b0;
    }
    DAT_004e068c = iVar1;
    return iVar1 - DAT_004e0684;
  }
  return DAT_004e0684;
}



/* @00401a5c file=? name=FUN_00401a5c */

undefined4 * __cdecl FUN_00401a5c(undefined4 *param_1)

{
  char *pcVar1;
  char *pcVar2;
  char *pcVar3;
  bool bVar4;
  
  *param_1 = 0;
  param_1[1] = 0;
  DAT_004e0684 = 0;
  pcVar2 = (char *)FUN_004dee74(s_L4TIMER_004e0690);
  if (pcVar2 != (char *)0x0) {
    pcVar3 = &DAT_004e0698;
    do {
      if (*pcVar2 != *pcVar3) goto LAB_00401ada;
      bVar4 = true;
      if (*pcVar2 == '\0') break;
      pcVar1 = pcVar2 + 1;
      if (*pcVar1 != pcVar3[1]) goto LAB_00401ada;
      pcVar2 = pcVar2 + 2;
      pcVar3 = pcVar3 + 2;
      bVar4 = *pcVar1 == '\0';
    } while (!bVar4);
    if (bVar4) {
      FUN_00481872(0xff00,0);
      FUN_00481953(0x1c,&LAB_00401a14,&DAT_004e0688);
      DAT_0052140c = 0x41e00000;
      return param_1;
    }
  }
LAB_00401ada:
  DAT_0052140c = 0x4191a6e0;
  DAT_004e0684 = FUN_004d418d();
  return param_1;
}



/* @00401afc file=? name=FUN_00401afc */

void FUN_00401afc(void)

{
  if (DAT_004e0688 != 0xffff) {
    FUN_00481c82(DAT_004e0688);
    FUN_00481934();
  }
  return;
}



/* @00401b1c file=? name=FUN_00401b1c */

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

float10 FUN_00401b1c(void)

{
  byte bVar1;
  byte bVar2;
  byte bVar3;
  int iVar4;
  float10 fVar5;
  
  FUN_004d46cf(0x43,0xc2);
  bVar1 = FUN_004d45d3(0x40);
  bVar2 = FUN_004d45d3(0x40);
  bVar3 = FUN_004d45d3(0x40);
  iVar4 = ((int)(uint)bVar2 >> 1) + (uint)bVar3 * 0x80;
  if (DAT_004e0688 == 0xffff) {
    fVar5 = (float10)(int)(0xffff - (iVar4 + (bVar1 & 0x80) * 0x100)) * (float10)_DAT_00401bcc;
  }
  else {
    if ((bVar1 & 0x80) != 0) {
      iVar4 = (DAT_004fee74 >> 1) + iVar4;
    }
    fVar5 = (float10)((DAT_004fee74 - 1) - iVar4) / (float10)DAT_004fee74;
  }
  return fVar5;
}



/* @00401be8 file=? name=FUN_00401be8 */

bool __cdecl FUN_00401be8(uint *param_1)

{
  uint *puVar1;
  
  puVar1 = (uint *)param_1[1];
  if ((puVar1 != (uint *)0x0) && (param_1 != (uint *)((int)puVar1 + (*puVar1 & 0xfffffffe)))) {
    return false;
  }
  return param_1 == *(uint **)((int)param_1 + (*param_1 & 0xfffffffe) + 4);
}



/* @00401c18 file=? name=FUN_00401c18 */

int * __cdecl FUN_00401c18(int *param_1,int param_2,uint param_3)

{
  int iVar1;
  
  param_1[1] = param_2;
  param_1[4] = param_3 + 3 & 0xfffffffc;
  iVar1 = FUN_004022b0(param_3);
  *param_1 = iVar1;
  if (DAT_004e06c4 == -0x54eca86b) {
    DAT_004e06c4 = -0x12edcf;
    param_1[8] = 1;
  }
  else {
    param_1[8] = 0;
  }
  FUN_00401f30(param_1);
  return param_1;
}



/* @00401c70 file=? name=FUN_00401c70 */

void __cdecl FUN_00401c70(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    param_1[2] = 0;
    param_1[3] = 0;
    param_1[4] = 0;
    if (param_1[8] != 0) {
      DAT_004e06c4 = 0xab135795;
    }
    FUN_004022d0((int *)*param_1);
    *param_1 = 0;
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00401cb8 file=? name=FUN_00401cb8 */

int __cdecl FUN_00401cb8(int param_1)

{
  int *piVar1;
  int iVar2;
  
  iVar2 = 0;
  piVar1 = *(int **)(param_1 + 0xc);
  do {
    piVar1 = (int *)piVar1[3];
    iVar2 = iVar2 + *piVar1 + -8;
  } while (piVar1 != *(int **)(param_1 + 0xc));
  return iVar2;
}



/* @00401cdc file=? name=FUN_00401cdc */

int __cdecl FUN_00401cdc(int param_1)

{
  return **(int **)(*(int *)(param_1 + 0xc) + 8) + -8;
}



/* @00401cf0 file=munga/heap.cpp name=FUN_00401cf0 */

uint * __cdecl FUN_00401cf0(int param_1,uint param_2)

{
  char *pcVar1;
  uint uVar2;
  uint uVar3;
  uint uVar4;
  int *piVar5;
  uint *puVar6;
  uint uVar7;
  uint *local_8;
  
  if (DAT_004e06c4 == -0x12edcf) {
    uVar7 = param_2 + 0xb & 0xfffffffc;
    if (uVar7 < 0x10) {
      uVar7 = 0x10;
    }
    local_8 = *(uint **)(param_1 + 0xc);
    while (uVar2 = *local_8 - uVar7, (int)uVar2 < 0) {
      local_8 = (uint *)local_8[3];
      if (local_8 == *(uint **)(param_1 + 0xc)) {
        uVar2 = *(uint *)(param_1 + 0x10);
        uVar3 = FUN_00401cb8(param_1);
        uVar4 = FUN_00401cdc(param_1);
        pcVar1 = *(char **)(param_1 + 4);
        FUN_004dbb24(&DAT_00524e20,s_Requested_004e06d3,(char *)0x0);
        piVar5 = FUN_004db880(&DAT_00524e20,param_2);
        FUN_004dbb24(piVar5,s_bytes_from_004e06de,(char *)0x0);
        FUN_004dbb24(piVar5,pcVar1,(char *)0x0);
        FUN_004dbb24(piVar5,s_Largest_block_remaining_is_004e06eb,(char *)0x0);
        piVar5 = FUN_004db880(piVar5,uVar4);
        FUN_004dbb24(piVar5,s_bytes_Total_remaining_memory_is_004e0708,(char *)0x0);
        piVar5 = FUN_004db880(piVar5,uVar3);
        FUN_004dbb24(piVar5,s_bytes_Heap_size_was_set_to_004e072a,(char *)0x0);
        piVar5 = FUN_004db880(piVar5,uVar2);
        FUN_004dbb24(piVar5,s_bytes_004e0747,(char *)0x0);
        FUN_0040385c(s_No_remaining_block_large_enough__004e074f,
                     s_d__tesla_bt_munga_HEAP_CPP_004e0771,0x156);
      }
    }
    if (uVar2 < 0x11) {
      *local_8 = *local_8 | 1;
      if (local_8 == (uint *)local_8[3]) {
        *(undefined4 *)(param_1 + 0xc) = 0;
      }
      else {
        if (local_8 == *(uint **)(param_1 + 0xc)) {
          *(uint **)(param_1 + 0xc) = (uint *)local_8[3];
        }
        uVar7 = local_8[3];
        uVar2 = local_8[2];
        *(uint *)(uVar7 + 8) = uVar2;
        *(uint *)(uVar2 + 0xc) = uVar7;
      }
    }
    else {
      piVar5 = (int *)((int)local_8 + *local_8 + 4);
      *piVar5 = *piVar5 + uVar2;
      *local_8 = uVar2;
      puVar6 = (uint *)(uVar2 + (int)local_8);
      *puVar6 = uVar7 | 1;
      puVar6[1] = (uint)local_8;
      FUN_00402164(param_1,local_8);
      local_8 = puVar6;
    }
    local_8 = local_8 + 2;
  }
  else {
    local_8 = (uint *)FUN_004de55c(param_2);
  }
  return local_8;
}



/* @00401ec8 file=? name=FUN_00401ec8 */

void __cdecl FUN_00401ec8(int param_1,int *param_2)

{
  uint *puVar1;
  uint *puVar2;
  
  if (DAT_004e06c4 == -0x12edcf) {
    puVar1 = (uint *)(param_2 + -2);
    FUN_00402230(param_1,puVar1);
    puVar2 = (uint *)param_2[-1];
    if ((puVar2 == (uint *)0x0) || ((*puVar2 & 1) != 0)) {
      *puVar1 = *puVar1 & 0xfffffffe;
      FUN_004020e8(param_1,puVar1);
    }
    else {
      *puVar2 = *puVar2 + (*puVar1 & 0xfffffffe);
      *(uint **)((int)puVar2 + *puVar2 + 4) = puVar2;
      FUN_00402164(param_1,puVar2);
    }
  }
  else {
    FUN_004de420(param_2);
  }
  return;
}



/* @00401f30 file=? name=FUN_00401f30 */

void __cdecl FUN_00401f30(int *param_1)

{
  int *piVar1;
  undefined4 *puVar2;
  int iVar3;
  
  piVar1 = (int *)*param_1;
  puVar2 = (undefined4 *)((int)piVar1 + param_1[4] + -0x10 & 0xfffffffc);
  param_1[2] = (int)puVar2;
  *puVar2 = 1;
  puVar2[3] = 0;
  puVar2[2] = 0;
  puVar2[1] = piVar1;
  param_1[2] = (int)piVar1;
  *piVar1 = (int)puVar2 - (int)piVar1;
  piVar1[1] = 0;
  param_1[3] = 0;
  FUN_004020e8((int)param_1,(uint *)param_1[2]);
  iVar3 = FUN_00401cb8((int)param_1);
  param_1[5] = iVar3;
  param_1[4] = iVar3;
  return;
}



/* @00401f90 file=? name=FUN_00401f90 */

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

{
  bool bVar1;
  undefined4 uVar2;
  undefined3 extraout_var;
  uint uVar3;
  char *pcVar4;
  uint *puVar5;
  undefined8 uVar6;
  uint *puVar7;
  
  puVar5 = *(uint **)(param_1 + 8);
  if ((puVar5 == (uint *)0x0) || (DAT_004e06c4 != -0x12edcf)) {
    uVar2 = 0;
  }
  else {
    for (; *puVar5 != 1; puVar5 = (uint *)((*puVar5 & 0xfffffffe) + (int)puVar5)) {
      bVar1 = FUN_00401be8(puVar5);
      if (CONCAT31(extraout_var,bVar1) == 0) {
        return 0;
      }
      if ((*puVar5 & 1) == 0) {
        if ((puVar5 != *(uint **)(puVar5[2] + 0xc)) || (puVar5 != *(uint **)(puVar5[3] + 8))) {
          return 0;
        }
        if (((puVar5 != *(uint **)(param_1 + 0xc)) && (*puVar5 < *(uint *)puVar5[2])) ||
           ((*(uint **)(param_1 + 0xc) != (uint *)puVar5[3] && (*(uint *)puVar5[3] < *puVar5)))) {
          return 0;
        }
      }
      uVar3 = *puVar5 & 1;
      if (((param_2 != 0) && ((uVar3 == 0 || (param_3 == 0)))) && ((uVar3 != 0 || (param_4 == 0))))
      {
        if (uVar3 == 0) {
          pcVar4 = &DAT_004e0796;
        }
        else {
          pcVar4 = s_Allocated_004e078c;
        }
        FUN_004dbb24(&DAT_00524e20,pcVar4,(char *)0x0);
        uVar3 = *puVar5;
        puVar7 = puVar5;
        FUN_004dbb24(&DAT_00524e20,s_block_at_004e079b,(char *)0x0);
        uVar6 = FUN_004dbd4c(&DAT_00524e20,(uint)puVar7);
        FUN_004dbb24((int *)uVar6,s___size___004e07a6,(char *)0x0);
        FUN_004db880((int *)uVar6,uVar3 & 0xfffffffe);
        FUN_004d9c38(&DAT_00524e20);
      }
    }
    if (param_2 != 0) {
      FUN_004d9c38(&DAT_00524e20);
    }
    uVar2 = 1;
  }
  return uVar2;
}



/* @004020e8 file=? name=FUN_004020e8 */

void __cdecl FUN_004020e8(int param_1,uint *param_2)

{
  uint uVar1;
  uint uVar2;
  uint *puVar3;
  
  if (*(int *)(param_1 + 0xc) == 0) {
    *(uint **)(param_1 + 0xc) = param_2;
    param_2[3] = (uint)param_2;
    param_2[2] = (uint)param_2;
    return;
  }
  puVar3 = *(uint **)(param_1 + 0xc);
  if (*param_2 < *puVar3) {
    *(uint **)(param_1 + 0xc) = param_2;
  }
  else {
    do {
      puVar3 = (uint *)puVar3[3];
      if (puVar3 == *(uint **)(param_1 + 0xc)) break;
    } while (*puVar3 < *param_2);
  }
  uVar1 = puVar3[2];
  uVar2 = *(uint *)(uVar1 + 0xc);
  param_2[3] = uVar2;
  param_2[2] = uVar1;
  *(uint **)(uVar1 + 0xc) = param_2;
  *(uint **)(uVar2 + 8) = param_2;
  return;
}



/* @00402134 file=? name=FUN_00402134 */

void __cdecl FUN_00402134(int param_1,int param_2)

{
  int iVar1;
  int iVar2;
  
  if (param_2 == *(int *)(param_2 + 0xc)) {
    *(undefined4 *)(param_1 + 0xc) = 0;
    return;
  }
  if (param_2 == *(int *)(param_1 + 0xc)) {
    *(int *)(param_2 + 0xc) = *(int *)(param_1 + 0xc);
  }
  iVar1 = *(int *)(param_2 + 0xc);
  iVar2 = *(int *)(param_2 + 8);
  *(int *)(iVar1 + 8) = iVar2;
  *(int *)(iVar2 + 0xc) = iVar1;
  return;
}



/* @00402164 file=? name=FUN_00402164 */

void __cdecl FUN_00402164(int param_1,uint *param_2)

{
  uint uVar1;
  uint uVar2;
  uint uVar3;
  uint *puVar4;
  uint *puVar5;
  uint *puVar6;
  
  uVar1 = *param_2;
  puVar4 = (uint *)param_2[3];
  if (puVar4 == (uint *)param_2[2]) {
    if (param_2 != puVar4) {
      if (uVar1 <= *puVar4) {
        puVar4 = param_2;
      }
      *(uint **)(param_1 + 0xc) = puVar4;
    }
  }
  else if (((*puVar4 < uVar1) && (puVar4 != *(uint **)(param_1 + 0xc))) ||
          ((puVar4 = (uint *)param_2[2], uVar1 < *puVar4 && (param_2 != *(uint **)(param_1 + 0xc))))
          ) {
    if (param_2 == *(uint **)(param_1 + 0xc)) {
      *(uint *)(param_1 + 0xc) = param_2[3];
    }
    uVar2 = param_2[3];
    uVar3 = param_2[2];
    *(uint *)(uVar2 + 8) = uVar3;
    *(uint *)(uVar3 + 0xc) = uVar2;
    if (puVar4 == (uint *)param_2[2]) {
      do {
        puVar5 = puVar4;
        puVar6 = (uint *)puVar5[2];
        if (puVar5 == *(uint **)(param_1 + 0xc)) break;
        puVar4 = puVar6;
      } while (uVar1 < *puVar6);
    }
    else {
      do {
        puVar6 = puVar4;
        puVar5 = (uint *)puVar6[3];
        if (puVar5 == *(uint **)(param_1 + 0xc)) break;
        puVar4 = puVar5;
      } while (*puVar5 < uVar1);
    }
    param_2[2] = (uint)puVar6;
    param_2[3] = (uint)puVar5;
    puVar6[3] = (uint)param_2;
    puVar5[2] = (uint)param_2;
    if (uVar1 < **(uint **)(param_1 + 0xc)) {
      *(uint **)(param_1 + 0xc) = param_2;
    }
  }
  return;
}



/* @00402230 file=? name=FUN_00402230 */

void __cdecl FUN_00402230(int param_1,uint *param_2)

{
  uint *puVar1;
  uint uVar2;
  
  puVar1 = (uint *)((*param_2 & 0xfffffffe) + (int)param_2);
  if ((*puVar1 & 1) == 0) {
    uVar2 = (*param_2 & 0xfffffffe) + *puVar1;
    *param_2 = uVar2 | 1;
    *(uint **)((int)param_2 + uVar2 + 4) = param_2;
    if (puVar1 == (uint *)puVar1[3]) {
      *(undefined4 *)(param_1 + 0xc) = 0;
    }
    else {
      if (puVar1 == *(uint **)(param_1 + 0xc)) {
        *(uint *)(param_1 + 0xc) = puVar1[3];
      }
      uVar2 = puVar1[3];
      *(uint *)(uVar2 + 8) = puVar1[2];
      *(uint *)(puVar1[2] + 0xc) = uVar2;
    }
  }
  return;
}



/* @0040228c file=? name=FUN_0040228c */

undefined4 FUN_0040228c(void)

{
  return 1;
}



/* @00402298 file=? name=FUN_00402298 */

void __cdecl FUN_00402298(uint param_1)

{
  FUN_00401cf0(0x4e06a0,param_1);
  return;
}



/* @004022b0 file=? name=FUN_004022b0 */

void __cdecl FUN_004022b0(uint param_1)

{
  FUN_00401cf0(0x4e06a0,param_1);
  return;
}



/* @004022c8 file=? name=FUN_004022c8 */

undefined4 __cdecl FUN_004022c8(undefined4 param_1,undefined4 param_2)

{
  return param_2;
}



/* @004022d0 file=? name=FUN_004022d0 */

void __cdecl FUN_004022d0(int *param_1)

{
  FUN_00401ec8(0x4e06a0,param_1);
  return;
}



/* @004022e8 file=? name=FUN_004022e8 */

void __cdecl FUN_004022e8(int *param_1)

{
  FUN_00401ec8(0x4e06a0,param_1);
  return;
}



/* @00402300 file=? name=FUN_00402300 */

char * __cdecl FUN_00402300(char *param_1)

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



/* @00402370 file=? name=FUN_00402370 */

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

{
  int iVar1;
  
  iVar1 = FUN_004d4a78(param_1);
  param_1[iVar1] = param_2;
  param_1[iVar1 + 1] = '\0';
  return param_1;
}



/* @00402390 file=? name=FUN_00402390 */

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

{
  char *local_8;
  
  local_8 = param_2;
  (**(code **)(*param_1 + 0x1c))(param_1,param_2,1);
  for (; *local_8 != '\0'; local_8 = local_8 + 1) {
    (**(code **)(*param_1 + 0x1c))(param_1,local_8,1);
  }
  return param_1;
}



/* @004023d4 file=? name=FUN_004023d4 */

void __cdecl FUN_004023d4(int *param_1,char *param_2)

{
  int iVar1;
  
  iVar1 = FUN_004d4a78(param_2);
  (**(code **)(*param_1 + 0x20))(param_1,param_2,iVar1 + 1);
  return;
}



/* @004023f4 file=? name=FUN_004023f4 */

void __cdecl FUN_004023f4(undefined4 *param_1)

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



/* @00402410 file=? name=FUN_00402410 */

uint * __cdecl FUN_00402410(uint *param_1,uint *param_2)

{
  undefined4 *puVar1;
  
  param_1[1] = param_2[1];
  *param_1 = *param_2;
  if (param_2[2] == 0) {
    param_1[2] = 0;
  }
  else {
    puVar1 = (undefined4 *)FUN_004022b0(*param_1);
    param_1[2] = (uint)puVar1;
    FUN_004d4918(puVar1,(undefined4 *)param_2[2],param_1[1] + 1);
  }
  param_1[3] = 0;
  return param_1;
}



/* @00402460 file=? name=FUN_00402460 */

uint * __cdecl FUN_00402460(uint *param_1,char *param_2)

{
  uint uVar1;
  undefined4 *puVar2;
  
  if ((param_2 == (char *)0x0) || (*param_2 == '\0')) {
    param_1[1] = 0;
    *param_1 = 0;
    param_1[2] = 0;
  }
  else {
    uVar1 = FUN_004d4a78(param_2);
    param_1[1] = uVar1;
    *param_1 = ((DAT_004e07b0 + param_1[1]) / DAT_004e07b0) * DAT_004e07b0;
    puVar2 = (undefined4 *)FUN_004022b0(*param_1);
    param_1[2] = (uint)puVar2;
    FUN_004d4918(puVar2,(undefined4 *)param_2,param_1[1] + 1);
  }
  param_1[3] = 0;
  return param_1;
}



/* @004024d8 file=? name=FUN_004024d8 */

void __cdecl FUN_004024d8(int *param_1,byte param_2)

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



/* @00402504 file=? name=FUN_00402504 */

undefined4 FUN_00402504(void)

{
  return 1;
}



/* @00402518 file=? name=FUN_00402518 */

uint * __cdecl FUN_00402518(uint *param_1,uint *param_2,uint *param_3)

{
  uint uVar1;
  
  if (param_3 == param_2) {
    FUN_00402410(param_1,param_2);
  }
  else {
    if ((int *)param_2[2] != (int *)0x0) {
      FUN_004022e8((int *)param_2[2]);
    }
    param_2[1] = param_3[1];
    uVar1 = *param_3;
    *param_2 = uVar1;
    if (uVar1 == 0) {
      param_2[2] = 0;
    }
    else {
      uVar1 = FUN_004022b0(*param_2);
      param_2[2] = uVar1;
      FUN_004d4918((undefined4 *)param_2[2],(undefined4 *)param_3[2],param_2[1] + 1);
    }
    FUN_00402410(param_1,param_2);
  }
  return param_1;
}



/* @00402590 file=? name=FUN_00402590 */

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

{
  uint uVar1;
  
  if ((int *)param_2[2] != (int *)0x0) {
    FUN_004022e8((int *)param_2[2]);
  }
  if ((param_3 == (char *)0x0) || (*param_3 == '\0')) {
    param_2[1] = 0;
    *param_2 = 0;
    param_2[2] = 0;
  }
  else {
    uVar1 = FUN_004d4a78(param_3);
    param_2[1] = uVar1;
    *param_2 = ((param_2[1] + DAT_004e07b0) / DAT_004e07b0) * DAT_004e07b0;
    uVar1 = FUN_004022b0(*param_2);
    param_2[2] = uVar1;
    FUN_004d4918((undefined4 *)param_2[2],(undefined4 *)param_3,param_2[1] + 1);
  }
  FUN_00402410(param_1,param_2);
  return param_1;
}



/* @00402624 file=? name=FUN_00402624 */

uint * __cdecl FUN_00402624(uint *param_1,int param_2,int param_3)

{
  uint local_1c;
  int local_18;
  undefined4 *local_14;
  uint local_c;
  int local_8;
  
  FUN_004023f4(&local_1c);
  local_8 = *(int *)(param_2 + 4) + *(int *)(param_3 + 4);
  if (local_8 == 0) {
    FUN_00402410(param_1,&local_1c);
    FUN_004024d8((int *)&local_1c,2);
  }
  else {
    local_18 = 0;
    local_1c = ((local_8 + DAT_004e07b0) / DAT_004e07b0) * DAT_004e07b0;
    local_c = local_1c;
    local_14 = (undefined4 *)FUN_004022b0(local_1c);
    *(undefined1 *)local_14 = 0;
    if (*(undefined4 **)(param_2 + 8) != (undefined4 *)0x0) {
      FUN_004d4918(local_14,*(undefined4 **)(param_2 + 8),*(uint *)(param_2 + 4));
      local_18 = *(int *)(param_2 + 4);
    }
    if (*(undefined4 **)(param_3 + 8) != (undefined4 *)0x0) {
      FUN_004d4918((undefined4 *)((int)local_14 + local_18),*(undefined4 **)(param_3 + 8),
                   *(int *)(param_3 + 4) + 1);
      local_18 = local_18 + *(int *)(param_3 + 4);
    }
    FUN_00402410(param_1,&local_1c);
    FUN_004024d8((int *)&local_1c,2);
  }
  return param_1;
}



/* @00402718 file=? name=FUN_00402718 */

uint * __cdecl FUN_00402718(uint *param_1,uint *param_2,undefined1 param_3)

{
  uint local_14;
  uint local_10;
  undefined4 *local_c;
  
  FUN_004023f4(&local_14);
  if (param_2[2] == 0) {
    local_10 = 1;
    local_14 = DAT_004e07b0;
    local_c = (undefined4 *)FUN_004022b0(DAT_004e07b0);
    *(undefined1 *)local_c = param_3;
    *(undefined1 *)((int)local_c + 1) = 0;
  }
  else {
    local_10 = param_2[1] + 1;
    local_14 = *param_2;
    if (local_10 == local_14) {
      local_14 = local_14 + DAT_004e07b0;
    }
    local_c = (undefined4 *)FUN_004022b0(local_14);
    FUN_004d4918(local_c,(undefined4 *)param_2[2],param_2[1]);
    *(undefined1 *)((int)local_c + param_2[1]) = param_3;
    *(undefined1 *)((int)local_c + local_10) = 0;
  }
  FUN_00402410(param_1,&local_14);
  FUN_004024d8((int *)&local_14,2);
  return param_1;
}



/* @004027d8 file=? name=FUN_004027d8 */

undefined4 __cdecl FUN_004027d8(int param_1,int param_2)

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



/* @00402838 file=? name=FUN_00402838 */

uint * __cdecl FUN_00402838(uint *param_1,uint *param_2,uint param_3,char *param_4)

{
  char *pcVar1;
  uint uVar2;
  char *pcVar3;
  uint local_34 [4];
  uint local_24 [4];
  uint local_14 [2];
  char *local_c;
  
  pcVar3 = &DAT_004e07b4;
  if (param_4 != (char *)0x0) {
    pcVar3 = param_4;
  }
  FUN_00402410(local_14,param_2);
  if (local_c == (char *)0x0) {
    FUN_00402410(param_1,local_14);
    FUN_004024d8((int *)local_14,2);
  }
  else {
    pcVar1 = FUN_004d4d1c(local_c,pcVar3);
    uVar2 = 0;
    if (param_3 != 0) {
      do {
        pcVar1 = FUN_004d4d1c((char *)0x0,pcVar3);
        if (pcVar1 == (char *)0x0) break;
        uVar2 = uVar2 + 1;
      } while (uVar2 < param_3);
    }
    if (pcVar1 == (char *)0x0) {
      FUN_004023f4(local_24);
      FUN_00402410(param_1,local_24);
      FUN_004024d8((int *)local_24,2);
      FUN_004024d8((int *)local_14,2);
    }
    else {
      FUN_00402460(local_34,pcVar1);
      FUN_00402410(param_1,local_34);
      FUN_004024d8((int *)local_34,2);
      FUN_004024d8((int *)local_14,2);
    }
  }
  return param_1;
}



/* @00402948 file=? name=FUN_00402948 */

int * __cdecl FUN_00402948(int *param_1,uint *param_2)

{
  int *piVar1;
  uint local_18 [4];
  int local_8;
  
  (**(code **)(*param_1 + 0x1c))(param_1,&local_8,4);
  piVar1 = (int *)FUN_004022b0(local_8 + 1);
  (**(code **)(*param_1 + 0x1c))(param_1,piVar1,local_8 + 1);
  FUN_00402590(local_18,param_2,(char *)piVar1);
  FUN_004024d8((int *)local_18,2);
  FUN_004022e8(piVar1);
  return param_1;
}



/* @004029b0 file=? name=FUN_004029b0 */

void __cdecl FUN_004029b0(int *param_1,int param_2)

{
  (**(code **)(*param_1 + 0x20))(param_1,param_2 + 4,4);
  (**(code **)(*param_1 + 0x20))(param_1,*(undefined4 *)(param_2 + 8),*(int *)(param_2 + 4) + 1);
  return;
}



/* @004029e4 file=munga/cstr.cpp name=FUN_004029e4 */

void __cdecl FUN_004029e4(char *param_1,uint *param_2)

{
  uint local_14 [4];
  
  if (param_1 == (char *)0x0) {
    FUN_0040385c(s_Convert_From_Ascii___str____NULL_004e07b8,s_d__tesla_bt_munga_CSTR_CPP_004e07d9,
                 0x22b);
  }
  if (param_2 == (uint *)0x0) {
    FUN_0040385c(s_Convert_From_Ascii___value____NU_004e07f4,s_d__tesla_bt_munga_CSTR_CPP_004e0817,
                 0x22f);
  }
  FUN_00402590(local_14,param_2,param_1);
  FUN_004024d8((int *)local_14,2);
  return;
}



/* @00402a4c file=? name=FUN_00402a4c */

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

{
  int *piVar1;
  int iVar2;
  int *piVar3;
  
  if (param_3 == param_2) {
    iVar2 = *param_2;
    *param_1 = iVar2;
    piVar1 = (int *)(iVar2 + 0xc);
    *piVar1 = *piVar1 + 1;
  }
  else {
    piVar3 = (int *)*param_2;
    piVar1 = piVar3 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar3,3);
    }
    iVar2 = *param_3;
    *param_2 = iVar2;
    piVar1 = (int *)(iVar2 + 0xc);
    *piVar1 = *piVar1 + 1;
    iVar2 = *param_2;
    *param_1 = iVar2;
    piVar1 = (int *)(iVar2 + 0xc);
    *piVar1 = *piVar1 + 1;
  }
  return param_1;
}



/* @00402a98 file=? name=FUN_00402a98 */

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

{
  int *piVar1;
  int *piVar2;
  int iVar3;
  uint *puVar4;
  
  piVar2 = (int *)*param_2;
  piVar1 = piVar2 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(piVar2,3);
  }
  puVar4 = (uint *)FUN_00402298(0x10);
  if (puVar4 == (uint *)0x0) {
    puVar4 = (uint *)0x0;
  }
  else {
    puVar4 = FUN_00402460(puVar4,param_3);
  }
  *param_2 = (int)puVar4;
  *(int *)(*param_2 + 0xc) = *(int *)(*param_2 + 0xc) + 1;
  iVar3 = *param_2;
  *param_1 = iVar3;
  piVar1 = (int *)(iVar3 + 0xc);
  *piVar1 = *piVar1 + 1;
  return param_1;
}



/* @00402aec file=? name=FUN_00402aec */

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

{
  int *piVar1;
  int *piVar2;
  undefined4 *puVar3;
  int iVar4;
  
  piVar2 = (int *)*param_2;
  piVar1 = piVar2 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(piVar2,3);
  }
  puVar3 = (undefined4 *)FUN_00402298(0x10);
  if (puVar3 == (undefined4 *)0x0) {
    iVar4 = 0;
  }
  else {
    iVar4 = FUN_004023f4(puVar3);
  }
  *param_2 = iVar4;
  *(int *)(iVar4 + 0xc) = *(int *)(iVar4 + 0xc) + 1;
  FUN_00402948(param_1,(uint *)*param_2);
  return;
}



/* @00402b3c file=? name=FUN_00402b3c */

void __cdecl FUN_00402b3c(char *param_1,int *param_2)

{
  int *piVar1;
  int *piVar2;
  undefined4 *puVar3;
  int iVar4;
  
  piVar2 = (int *)*param_2;
  piVar1 = piVar2 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(piVar2,3);
  }
  puVar3 = (undefined4 *)FUN_00402298(0x10);
  if (puVar3 == (undefined4 *)0x0) {
    iVar4 = 0;
  }
  else {
    iVar4 = FUN_004023f4(puVar3);
  }
  *param_2 = iVar4;
  *(int *)(iVar4 + 0xc) = *(int *)(iVar4 + 0xc) + 1;
  FUN_004029e4(param_1,(uint *)*param_2);
  return;
}



/* @00402b98 file=? name=FUN_00402b98 */

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

{
  int iVar1;
  undefined4 *puVar2;
  
  param_1[3] = param_2;
  param_1[2] = param_3 * param_2;
  param_1[4] = param_4 * param_1[3];
  *param_1 = param_5;
  puVar2 = (undefined4 *)FUN_004022b0(param_1[2] + 8);
  param_1[1] = puVar2;
  *puVar2 = 0;
  puVar2[1] = param_1[2];
  param_1[5] = puVar2 + 2;
  param_1[6] = puVar2 + 2;
  param_1[7] = 0;
  if (DAT_004e0834 == (undefined4 *)0x0) {
    param_1[9] = param_1;
    param_1[8] = param_1;
    DAT_004e0834 = param_1;
  }
  else {
    iVar1 = DAT_004e0834[9];
    param_1[8] = DAT_004e0834;
    param_1[9] = iVar1;
    *(undefined4 **)(iVar1 + 0x20) = param_1;
    DAT_004e0834[9] = param_1;
  }
  return param_1;
}



/* @00402c28 file=? name=FUN_00402c28 */

void __cdecl FUN_00402c28(int *param_1,byte param_2)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  int *piVar4;
  
  if (param_1 != (int *)0x0) {
    piVar4 = (int *)param_1[1];
    while (piVar4 != (int *)0x0) {
      piVar1 = (int *)*piVar4;
      FUN_004022d0(piVar4);
      piVar4 = piVar1;
    }
    if ((param_1 == DAT_004e0834) && (DAT_004e0834 = (int *)param_1[8], param_1 == DAT_004e0834)) {
      DAT_004e0834 = (int *)0x0;
    }
    else {
      iVar2 = param_1[8];
      iVar3 = param_1[9];
      *(int *)(iVar2 + 0x24) = iVar3;
      *(int *)(iVar3 + 0x20) = iVar2;
    }
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00402c88 file=? name=FUN_00402c88 */

int __cdecl FUN_00402c88(int param_1)

{
  undefined4 *puVar1;
  int iVar2;
  
  iVar2 = *(int *)(param_1 + 0x18);
  if ((uint)(*(int *)(param_1 + 8) - *(int *)(param_1 + 0xc)) <
      (uint)(iVar2 - *(int *)(param_1 + 0x14))) {
    *(undefined4 *)(param_1 + 8) = *(undefined4 *)(param_1 + 0x10);
    *(int *)(param_1 + 0x14) = *(int *)(param_1 + 0x14) + -8;
    puVar1 = (undefined4 *)FUN_004022b0(*(int *)(param_1 + 8) + 8);
    **(undefined4 **)(param_1 + 0x14) = puVar1;
    *(undefined4 **)(param_1 + 0x14) = puVar1;
    *puVar1 = 0;
    puVar1[1] = *(undefined4 *)(param_1 + 0x10);
    *(int *)(param_1 + 0x14) = *(int *)(param_1 + 0x14) + 8;
    *(int *)(param_1 + 0x18) = *(int *)(param_1 + 0x14) + *(int *)(param_1 + 0xc);
    iVar2 = *(int *)(param_1 + 0x14);
  }
  else {
    *(int *)(param_1 + 0x18) = *(int *)(param_1 + 0x18) + *(int *)(param_1 + 0xc);
  }
  return iVar2;
}



/* @00402cec file=? name=FUN_00402cec */

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

void FUN_00402cec(void)

{
  undefined4 *puVar1;
  char *pcVar2;
  uint uVar3;
  uint uVar4;
  int *piVar5;
  int iVar6;
  uint uVar7;
  undefined4 *puVar8;
  uint uVar9;
  byte bVar10;
  uint local_74;
  code *local_64;
  undefined4 uStack_60;
  uint local_5c;
  code *local_58;
  undefined4 uStack_54;
  uint local_50;
  code *local_4c;
  undefined4 uStack_48;
  uint local_44;
  code *local_40;
  undefined4 uStack_3c;
  uint local_38;
  code *local_34;
  undefined4 local_30;
  int *piStack_2c;
  int *piStack_28;
  int *piStack_24;
  int local_20;
  undefined4 uStack_1c;
  int local_18;
  undefined4 uStack_14;
  
  FUN_004dbb24(&DAT_00524e20,s__Bytes__Rcds__Dels__Free_Use__Na_004e0838,(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s__________________________________004e085c,(char *)0x0);
  puVar8 = DAT_004e0834;
  do {
    puVar1 = (undefined4 *)puVar8[1];
    local_74 = 0;
    local_18 = 0;
    uVar7 = 0;
    uVar3 = (uint)(puVar8[2] - (puVar8[6] - puVar8[5])) / (uint)puVar8[3];
    for (; puVar1 != (undefined4 *)0x0; puVar1 = (undefined4 *)*puVar1) {
      local_74 = local_74 + puVar1[1] + 8;
      local_18 = local_18 + (uint)puVar1[1] / (uint)puVar8[3];
    }
    for (puVar1 = (undefined4 *)puVar8[7]; puVar1 != (undefined4 *)0x0;
        puVar1 = (undefined4 *)*puVar1) {
      uVar7 = uVar7 + 1;
    }
    local_20 = uVar3 + uVar7;
    uStack_1c = 0;
    uStack_14 = 0;
    uVar9 = local_18 - local_20;
    bVar10 = 0x25;
    uVar4 = FUN_004dcd94();
    FUN_004dafd8(&local_64,4);
    local_5c = uVar3;
    FUN_004dafd8(&local_58,6);
    local_50 = uVar7;
    FUN_004dafd8(&local_4c,6);
    local_44 = uVar9;
    FUN_004dafd8(&local_40,6);
    local_38 = local_74;
    FUN_004dafd8(&local_34,6);
    (*local_34)(DAT_00524e20,local_30);
    piVar5 = FUN_004db880(&DAT_00524e20,local_38);
    if (piVar5 == (int *)0x0) {
      iVar6 = 0;
    }
    else {
      iVar6 = *piVar5;
    }
    (*local_40)(iVar6,uStack_3c);
    piStack_2c = FUN_004db880(piVar5,local_44);
    if (piStack_2c == (int *)0x0) {
      iVar6 = 0;
    }
    else {
      iVar6 = *piStack_2c;
    }
    (*local_4c)(iVar6,uStack_48);
    piStack_28 = FUN_004db880(piStack_2c,local_50);
    if (piStack_28 == (int *)0x0) {
      iVar6 = 0;
    }
    else {
      iVar6 = *piStack_28;
    }
    (*local_58)(iVar6,uStack_54);
    piStack_24 = FUN_004db880(piStack_28,local_5c);
    if (piStack_24 == (int *)0x0) {
      iVar6 = 0;
    }
    else {
      iVar6 = *piStack_24;
    }
    (*local_64)(iVar6,uStack_60);
    piVar5 = FUN_004db78c(piStack_24,uVar4);
    FUN_004db92c(piVar5,bVar10);
    pcVar2 = (char *)*puVar8;
    if (pcVar2 != (char *)0x0) {
      piVar5 = FUN_004db92c(&DAT_00524e20,0x20);
      FUN_004dbb24(piVar5,pcVar2,(char *)0x0);
    }
    FUN_004d9c38(&DAT_00524e20);
    puVar8 = (undefined4 *)puVar8[8];
  } while (puVar8 != DAT_004e0834);
  FUN_004d9c38(&DAT_00524e20);
  return;
}



/* @00402f74 file=? name=FUN_00402f74 */

undefined4 * __cdecl FUN_00402f74(int param_1)

{
  undefined4 *puVar1;
  
  puVar1 = *(undefined4 **)(param_1 + 0x1c);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)FUN_00402c88(param_1);
  }
  else {
    *(undefined4 *)(param_1 + 0x1c) = *puVar1;
  }
  return puVar1;
}



/* @00402f98 file=? name=FUN_00402f98 */

void __cdecl FUN_00402f98(int param_1,undefined4 *param_2)

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



/* @00402fac file=? name=FUN_00402fac */

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

{
  undefined4 *puVar1;
  longlong lVar2;
  int iVar3;
  
  puVar1 = *(undefined4 **)(param_3 + 4);
  do {
    if (puVar1 == (undefined4 *)0x0) {
      iVar3 = 0;
LAB_00402fe2:
      return CONCAT44(param_2,iVar3);
    }
    param_2 = (uint)puVar1[1] / *(uint *)(param_3 + 0xc);
    if (param_4 < param_2) {
      lVar2 = (longlong)*(int *)(param_3 + 0xc) * (longlong)(int)param_4;
      param_2 = (uint)((ulonglong)lVar2 >> 0x20);
      iVar3 = (int)puVar1 + (int)lVar2 + 8;
      goto LAB_00402fe2;
    }
    param_4 = param_4 - param_2;
    puVar1 = (undefined4 *)*puVar1;
  } while( true );
}



/* @00402fe8 file=? name=FUN_00402fe8 */

undefined4 __cdecl FUN_00402fe8(int param_1,undefined4 *param_2)

{
  int iVar1;
  undefined4 *puVar2;
  uint uVar3;
  
  iVar1 = *(int *)(param_1 + 0x14);
  *(undefined4 *)(param_1 + 0x28) = *(undefined4 *)(param_1 + 0x18);
  uVar3 = *(uint *)(param_1 + 0xc);
  puVar2 = (undefined4 *)FUN_00402c88(param_1);
  FUN_004d4918(puVar2,param_2,uVar3);
  if (iVar1 != *(int *)(param_1 + 0x14)) {
    *(int *)(param_1 + 0x28) = *(int *)(param_1 + 0x14);
  }
  return *(undefined4 *)(param_1 + 0x28);
}



/* @00403024 file=? name=FUN_00403024 */

undefined4 __cdecl FUN_00403024(int param_1)

{
  int iVar1;
  
  iVar1 = *(int *)(param_1 + 0x14);
  *(undefined4 *)(param_1 + 0x28) = *(undefined4 *)(param_1 + 0x18);
  FUN_00402c88(param_1);
  if (iVar1 != *(int *)(param_1 + 0x14)) {
    *(int *)(param_1 + 0x28) = *(int *)(param_1 + 0x14);
  }
  return *(undefined4 *)(param_1 + 0x28);
}



/* @00403050 file=? name=FUN_00403050 */

void __cdecl FUN_00403050(int param_1)

{
  int iVar1;
  int *piVar2;
  int *piVar3;
  
  if (*(int *)(param_1 + 0x28) != 0) {
    iVar1 = *(int *)(param_1 + 0x14);
    if (*(int *)(param_1 + 0x28) == iVar1) {
      if (**(int **)(param_1 + 4) == 0) {
        *(undefined4 *)(param_1 + 0x28) = 0;
      }
      else {
        piVar2 = *(int **)(param_1 + 4);
        do {
          piVar3 = piVar2;
          piVar2 = (int *)*piVar3;
        } while ((int *)(*(int *)(param_1 + 0x14) + -8) != (int *)*piVar3);
        *(int *)(param_1 + 0x28) = (int)piVar3 + ((piVar3[1] + 8) - *(int *)(param_1 + 0xc));
      }
    }
    else {
      if (iVar1 == *(int *)(param_1 + 0x18)) {
        piVar2 = *(int **)(param_1 + 4);
        do {
          piVar3 = piVar2;
          piVar2 = (int *)*piVar3;
        } while ((int *)(iVar1 + -8) != (int *)*piVar3);
        FUN_004022d0((int *)(iVar1 + -8));
        *piVar3 = 0;
        *(int **)(param_1 + 0x14) = piVar3 + 2;
        *(int *)(param_1 + 8) = piVar3[1];
      }
      *(undefined4 *)(param_1 + 0x18) = *(undefined4 *)(param_1 + 0x28);
      *(int *)(param_1 + 0x28) = *(int *)(param_1 + 0x28) - *(int *)(param_1 + 0xc);
    }
  }
  return;
}



/* @004030dc file=? name=FUN_004030dc */

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

{
  *param_1 = &PTR_FUN_004e0908;
  param_1[1] = param_2;
  param_1[3] = param_3;
  param_1[2] = param_1[1] + param_4;
  return;
}



/* @00403104 file=? name=FUN_00403104 */

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

{
  undefined4 *puVar1;
  uint uVar2;
  
  uVar2 = param_3;
  puVar1 = (undefined4 *)(**(code **)*param_1)(param_1);
  FUN_004d4918(param_2,puVar1,uVar2);
  (**(code **)(*param_1 + 0x14))(param_1,param_3);
  return param_1;
}



/* @00403134 file=? name=FUN_00403134 */

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

{
  undefined4 *puVar1;
  uint uVar2;
  
  uVar2 = param_3;
  puVar1 = (undefined4 *)(**(code **)*param_1)(param_1);
  FUN_004d4918(puVar1,param_2,uVar2);
  (**(code **)(*param_1 + 0x14))(param_1,param_3);
  return param_1;
}



/* @00403164 file=munga/memstrm.cpp name=FUN_00403164 */

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

{
  int iVar1;
  int iVar2;
  undefined1 *puVar3;
  int *piVar4;
  undefined1 local_5;
  
  FUN_004dc680(*param_2,0);
  if ((*(byte *)(*param_2 + 0x18) & 0x80) == 0) {
    FUN_004dc680(*param_2,0);
    FUN_004daf40(param_2,0);
    while( true ) {
      piVar4 = FUN_004dadcc(param_2,&local_5);
      iVar1 = *piVar4;
      if ((*(byte *)(iVar1 + 0xc) & 0x86) != 0) {
        iVar1 = 0;
      }
      if (iVar1 == 0) break;
      (**(code **)(*param_1 + 0x20))(param_1,&local_5,1);
    }
  }
  else {
    FUN_004daf00(param_2,0,2);
    iVar1 = FUN_004daf7c(param_2);
    FUN_004dc680(*param_2,0);
    FUN_004daf40(param_2,0);
    iVar2 = (**(code **)(*param_1 + 0x10))(param_1,iVar1);
    if (iVar2 == 0) {
      FUN_0040385c(s_Not_enough_memory_remaining_in_s_004e089c,
                   s_d__tesla_bt_munga_MEMSTRM_CPP_004e08c3,0x69);
    }
    iVar2 = iVar1;
    puVar3 = (undefined1 *)(**(code **)*param_1)(param_1);
    FUN_004dae60(param_2,puVar3,iVar2);
    (**(code **)(*param_1 + 0x14))(param_1,iVar1);
  }
  return param_1;
}



/* @00403248 file=? name=FUN_00403248 */

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

{
  undefined4 uVar1;
  
  uVar1 = (**(code **)(*param_2 + 4))(param_2);
  uVar1 = (**(code **)*param_2)(param_2,uVar1);
  (**(code **)(*param_1 + 0x20))(param_1,uVar1);
  return;
}



/* @00403270 file=? name=FUN_00403270 */

bool __cdecl FUN_00403270(int param_1)

{
  return (uint)(*(int *)(param_1 + 8) - *(int *)(param_1 + 4)) <= *(uint *)(param_1 + 0xc);
}



/* @0040328c file=? name=FUN_0040328c */

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

{
  undefined4 uVar1;
  uint uVar2;
  
  FUN_004030dc(param_1,0,param_2,0);
  uVar2 = param_2 + 0x80U & 0xffffff80;
  *param_1 = &PTR_FUN_004e08e4;
  param_1[3] = uVar2;
  uVar1 = FUN_004022b0(uVar2);
  param_1[1] = uVar1;
  param_1[2] = uVar1;
  param_1[4] = 0;
  param_1[5] = 1;
  return param_1;
}



/* @004032dc file=? name=FUN_004032dc */

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

{
  FUN_004030dc(param_1,param_2,param_3,param_4);
  *param_1 = &PTR_FUN_004e08e4;
  param_1[5] = 0;
  param_1[4] = param_3;
  return param_1;
}



/* @00403310 file=? name=FUN_00403310 */

void __cdecl FUN_00403310(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004e08e4;
    if (param_1[5] != 0) {
      FUN_004022e8((int *)param_1[1]);
    }
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00403344 file=? name=FUN_00403344 */

undefined4 __cdecl FUN_00403344(int param_1,uint param_2)

{
  undefined4 *puVar1;
  int iVar2;
  uint uVar3;
  
  if ((*(int *)(param_1 + 0x14) != 0) &&
     ((uint)(*(int *)(param_1 + 0xc) - (*(int *)(param_1 + 8) - *(int *)(param_1 + 4))) < param_2))
  {
    iVar2 = *(int *)(param_1 + 8) - *(int *)(param_1 + 4);
    uVar3 = param_2 + iVar2 + 0x81 & 0xffffff80;
    puVar1 = (undefined4 *)FUN_004022b0(uVar3);
    FUN_004d4918(puVar1,*(undefined4 **)(param_1 + 4),*(uint *)(param_1 + 0xc));
    FUN_004022e8(*(int **)(param_1 + 4));
    *(undefined4 **)(param_1 + 4) = puVar1;
    *(uint *)(param_1 + 0xc) = uVar3;
    *(int *)(param_1 + 8) = *(int *)(param_1 + 4) + iVar2;
  }
  return 1;
}



/* @004033d0 file=? name=FUN_004033d0 */

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

{
  undefined4 *puVar1;
  int iVar2;
  uint uVar3;
  
  (**(code **)(*param_1 + 0x10))(param_1,param_3);
  uVar3 = param_3;
  puVar1 = (undefined4 *)(**(code **)*param_1)(param_1);
  FUN_004d4918(puVar1,param_2,uVar3);
  (**(code **)(*param_1 + 0x14))(param_1,param_3);
  if ((uint)(param_1[2] - param_1[1]) < (uint)param_1[4]) {
    iVar2 = param_1[4];
  }
  else {
    iVar2 = param_1[2] - param_1[1];
  }
  param_1[4] = iVar2;
  return param_1;
}



/* @00403428 file=? name=FUN_00403428 */

undefined4 __cdecl FUN_00403428(int param_1)

{
  return *(undefined4 *)(param_1 + 8);
}



/* @00403433 file=? name=FUN_00403433 */

int __cdecl FUN_00403433(int param_1)

{
  return *(int *)(param_1 + 0x10) - (*(int *)(param_1 + 8) - *(int *)(param_1 + 4));
}



/* @00403446 file=? name=FUN_00403446 */

void __cdecl FUN_00403446(int param_1,undefined4 param_2)

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



/* @00403454 file=? name=FUN_00403454 */

void __cdecl FUN_00403454(int param_1,int param_2)

{
  *(int *)(param_1 + 8) = *(int *)(param_1 + 4) + param_2;
  return;
}



/* @00403465 file=? name=FUN_00403465 */

void __cdecl FUN_00403465(int param_1,int param_2)

{
  *(int *)(param_1 + 8) = *(int *)(param_1 + 8) + param_2;
  return;
}



/* @00403473 file=? name=FUN_00403473 */

void __cdecl FUN_00403473(int param_1,int param_2)

{
  *(int *)(param_1 + 8) = *(int *)(param_1 + 8) - param_2;
  return;
}



/* @00403481 file=? name=FUN_00403481 */

int __cdecl FUN_00403481(int param_1)

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



/* @00403494 file=? name=FUN_00403494 */

bool __cdecl FUN_00403494(int *param_1,uint param_2)

{
  uint uVar1;
  
  uVar1 = (**(code **)(*param_1 + 4))(param_1);
  return uVar1 <= param_2;
}



/* @004034b0 file=? name=FUN_004034b0 */

undefined4 * __cdecl FUN_004034b0(undefined4 *param_1,LPCSTR param_2,int param_3)

{
  FUN_004030dc(param_1,0,0,0);
  *param_1 = &PTR_FUN_004e09e0;
  FUN_004034e4((int)param_1,param_2,param_3);
  return param_1;
}



/* @004034e4 file=? name=FUN_004034e4 */

void __cdecl FUN_004034e4(int param_1,LPCSTR param_2,int param_3)

{
  uint uVar1;
  DWORD DVar2;
  
  *(uint *)(param_1 + 0x14) = (uint)(param_3 == 0);
  *(undefined4 *)(param_1 + 0x10) = 0xffffffff;
  *(undefined4 *)(param_1 + 4) = 0;
  *(undefined4 *)(param_1 + 8) = 0;
  *(undefined4 *)(param_1 + 0xc) = 0;
  if (param_2 != (LPCSTR)0x0) {
    uVar1 = FUN_00401774(param_2,*(int *)(param_1 + 0x14));
    *(uint *)(param_1 + 0x10) = uVar1;
  }
  if (*(int *)(param_1 + 0x10) != -1) {
    if (*(int *)(param_1 + 0x14) == 0) {
      *(undefined4 *)(param_1 + 0xc) = 0xffffffff;
    }
    else {
      DVar2 = FUN_0040184c(*(uint *)(param_1 + 0x10),0,1);
      *(DWORD *)(param_1 + 0xc) = DVar2;
      FUN_0040184c(*(uint *)(param_1 + 0x10),0,0);
    }
  }
  return;
}



/* @00403564 file=? name=FUN_00403564 */

void __cdecl FUN_00403564(int param_1)

{
  if (*(int *)(param_1 + 0x10) != -1) {
    FUN_00401810(*(uint *)(param_1 + 0x10));
  }
  *(undefined4 *)(param_1 + 0x10) = 0xffffffff;
  return;
}



/* @00403588 file=? name=FUN_00403588 */

void __cdecl FUN_00403588(int param_1,LONG param_2)

{
  DWORD DVar1;
  
  DVar1 = FUN_0040184c(*(uint *)(param_1 + 0x10),param_2,0);
  *(DWORD *)(param_1 + 8) = DVar1;
  return;
}



/* @004035a8 file=? name=FUN_004035a8 */

int __cdecl FUN_004035a8(int param_1,int param_2)

{
  DWORD DVar1;
  
  DVar1 = FUN_0040184c(*(uint *)(param_1 + 0x10),*(int *)(param_1 + 8) + param_2,0);
  *(DWORD *)(param_1 + 8) = DVar1;
  return param_1;
}



/* @004035cc file=? name=FUN_004035cc */

int __cdecl FUN_004035cc(int param_1,int param_2)

{
  DWORD DVar1;
  
  DVar1 = FUN_0040184c(*(uint *)(param_1 + 0x10),*(int *)(param_1 + 8) + param_2,0);
  *(DWORD *)(param_1 + 8) = DVar1;
  return param_1;
}



/* @004035f0 file=? name=FUN_004035f0 */

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

{
  char *pcVar1;
  
  pcVar1 = FUN_00401970(*(uint *)(param_1 + 0x10),param_2,param_3);
  *(int *)(param_1 + 8) = (int)(pcVar1 + *(int *)(param_1 + 8));
  return param_1;
}



/* @00403614 file=? name=FUN_00403614 */

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

{
  char *pcVar1;
  
  pcVar1 = FUN_004018cc(*(uint *)(param_1 + 0x10),param_2,param_3);
  *(int *)(param_1 + 8) = (int)(pcVar1 + *(int *)(param_1 + 8));
  return param_1;
}



/* @00403638 file=? name=FUN_00403638 */

undefined4 FUN_00403638(void)

{
  return 1;
}



/* @00403642 file=munga/filestrm.hpp name=FUN_00403642 */

undefined4 FUN_00403642(void)

{
  FUN_0040385c(s_No_implementation_possible_for_F_004e092c,s_d__tesla_bt_munga_filestrm_hpp_004e0964
               ,0x2d);
  return 0;
}



/* @0040365d file=munga/filestrm.hpp name=FUN_0040365d */

void FUN_0040365d(void)

{
  FUN_0040385c(s_No_implementation_possible_for_F_004e0983,s_d__tesla_bt_munga_filestrm_hpp_004e09c0
               ,0x33);
  return;
}



/* @00403678 file=? name=FUN_00403678 */

undefined4 FUN_00403678(void)

{
  FUN_004dcd7c();
  return 1;
}



/* @004036a0 file=? name=FUN_004036a0 */

void __cdecl FUN_004036a0(UINT param_1)

{
  FUN_004dee24(param_1);
  return;
}



/* @00403798 file=? name=FUN_00403798 */

void __cdecl FUN_00403798(char *param_1,char *param_2,uint param_3)

{
  int *piVar1;
  
  if (DAT_004e0a04 == 0) {
    DAT_004e0a04 = 1;
    FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004e0adb,(char *)0x0);
    piVar1 = FUN_004db78c(&DAT_00524e20,param_3);
    FUN_004dbb24(piVar1,s____Failed_004e0add,(char *)0x0);
    FUN_004dbb24(piVar1,param_1,(char *)0x0);
    FUN_004dbb24(piVar1,&DAT_004e0ae8,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_Failing_to_debugger_004e0aea,(char *)0x0);
    FUN_004d9c70(&DAT_00524e20);
    FUN_00401afc();
    FUN_0044c720();
    FUN_00447b38();
  }
  return;
}



/* @0040385c file=? name=FUN_0040385c */

void __cdecl FUN_0040385c(char *param_1,char *param_2,uint param_3)

{
  int *piVar1;
  
  if (DAT_004e0a04 == 0) {
    DAT_004e0a04 = 1;
    FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004e0aff,(char *)0x0);
    piVar1 = FUN_004db78c(&DAT_00524e20,param_3);
    FUN_004dbb24(piVar1,&DAT_004e0b01,(char *)0x0);
    FUN_004dbb24(piVar1,param_1,(char *)0x0);
    FUN_004dbb24(piVar1,&DAT_004e0b05,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_Failing_to_debugger_004e0b07,(char *)0x0);
    FUN_004d9c70(&DAT_00524e20);
    FUN_00401afc();
    FUN_0044c720();
    FUN_00447b38();
  }
  return;
}



/* @00403920 file=? name=FUN_00403920 */

void __cdecl FUN_00403920(float *param_1,float *param_2)

{
  *param_1 = -*param_2;
  param_1[1] = -param_2[1];
  return;
}



/* @00403939 file=? name=FUN_00403939 */

void __cdecl FUN_00403939(float *param_1,float *param_2,float *param_3)

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



/* @00403956 file=? name=FUN_00403956 */

void __cdecl FUN_00403956(float *param_1,float *param_2,float *param_3)

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



/* @00403973 file=? name=FUN_00403973 */

void __cdecl FUN_00403973(float *param_1,float *param_2,float param_3)

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



/* @0040398e file=? name=FUN_0040398e */

void __cdecl FUN_0040398e(float *param_1,float *param_2,float *param_3)

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



/* @004039ab file=? name=FUN_004039ab */

void __cdecl FUN_004039ab(float *param_1,float *param_2,float param_3)

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



/* @004039c6 file=? name=FUN_004039c6 */

void __cdecl FUN_004039c6(float *param_1,float *param_2,float *param_3)

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



/* @004039e3 file=? name=FUN_004039e3 */

float * __cdecl FUN_004039e3(float *param_1,float *param_2)

{
  float10 fVar1;
  
  fVar1 = FUN_004dd138((double)(param_2[1] * param_2[1] + *param_2 * *param_2));
  *param_1 = *param_2 / (float)fVar1;
  param_1[1] = param_2[1] / (float)fVar1;
  return param_1;
}



/* @00403a23 file=? name=FUN_00403a23 */

undefined4 FUN_00403a23(void)

{
  return 1;
}



/* @00403a30 file=? name=FUN_00403a30 */

void __cdecl FUN_00403a30(undefined4 *param_1)

{
  *param_1 = &PTR_FUN_004e0b2c;
  param_1[2] = 0;
  param_1[1] = 0;
  return;
}



/* @00403a48 file=? name=FUN_00403a48 */

void __cdecl FUN_00403a48(int *param_1,byte param_2)

{
  int iVar1;
  int *piVar2;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004e0b2c;
    while (piVar2 = (int *)param_1[1], piVar2 != (int *)0x0) {
      iVar1 = *piVar2;
      FUN_004022d0(piVar2);
      param_1[1] = iVar1;
    }
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00403a80 file=? name=FUN_00403a80 */

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

{
  int iVar1;
  undefined4 *puVar2;
  
  iVar1 = FUN_004d4a78(param_2);
  puVar2 = (undefined4 *)FUN_004022b0(iVar1 + 9);
  puVar2[1] = param_3;
  *puVar2 = 0;
  if (*(int *)(param_1 + 4) == 0) {
    *(undefined4 **)(param_1 + 4) = puVar2;
  }
  else {
    **(undefined4 **)(param_1 + 8) = puVar2;
  }
  *(undefined4 **)(param_1 + 8) = puVar2;
  FUN_00403be8((int)puVar2,param_2);
  return puVar2 + 2;
}



/* @00403ad0 file=? name=FUN_00403ad0 */

undefined4 __cdecl FUN_00403ad0(int param_1,char *param_2)

{
  char *pcVar1;
  undefined4 *puVar2;
  char *pcVar3;
  undefined4 uVar4;
  char *pcVar5;
  bool bVar6;
  
  for (puVar2 = *(undefined4 **)(param_1 + 4); puVar2 != (undefined4 *)0x0;
      puVar2 = (undefined4 *)*puVar2) {
    pcVar3 = (char *)(puVar2 + 2);
    pcVar5 = param_2;
    do {
      if (*pcVar3 != *pcVar5) goto LAB_00403b05;
      bVar6 = true;
      if (*pcVar3 == '\0') break;
      pcVar1 = pcVar3 + 1;
      if (*pcVar1 != pcVar5[1]) goto LAB_00403b05;
      pcVar3 = pcVar3 + 2;
      pcVar5 = pcVar5 + 2;
      bVar6 = *pcVar1 == '\0';
    } while (!bVar6);
    if (bVar6) break;
LAB_00403b05:
  }
  if (puVar2 == (undefined4 *)0x0) {
    uVar4 = 0;
  }
  else {
    uVar4 = puVar2[1];
  }
  return uVar4;
}



/* @00403b1c file=? name=FUN_00403b1c */

void __cdecl FUN_00403b1c(int param_1,int param_2)

{
  int *piVar1;
  int *piVar2;
  int *piVar3;
  int *piVar4;
  
  piVar4 = (int *)(param_2 + -8);
  piVar1 = *(int **)(param_1 + 4);
  piVar3 = (int *)0x0;
  while ((piVar2 = piVar1, piVar2 != (int *)0x0 && (piVar4 != piVar2))) {
    piVar3 = piVar2;
    piVar1 = (int *)*piVar2;
  }
  if (piVar3 == (int *)0x0) {
    *(int *)(param_1 + 4) = *piVar4;
  }
  else {
    *piVar3 = *piVar4;
  }
  if (piVar4 == *(int **)(param_1 + 8)) {
    *(int **)(param_1 + 8) = piVar3;
  }
  FUN_004022d0(piVar4);
  return;
}



/* @00403b60 file=? name=FUN_00403b60 */

int __cdecl FUN_00403b60(int param_1)

{
  undefined4 *puVar1;
  int iVar2;
  
  iVar2 = 0;
  for (puVar1 = *(undefined4 **)(param_1 + 4); puVar1 != (undefined4 *)0x0;
      puVar1 = (undefined4 *)*puVar1) {
    iVar2 = iVar2 + 1;
  }
  return iVar2;
}



/* @00403b7c file=? name=FUN_00403b7c */

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

{
  undefined4 *puVar1;
  int iVar2;
  int iVar3;
  int local_c;
  
  iVar2 = FUN_004d4a78(param_3);
  puVar1 = *(undefined4 **)(param_2 + 4);
  local_c = 0;
  for (; puVar1 != (undefined4 *)0x0; puVar1 = (undefined4 *)*puVar1) {
    iVar3 = FUN_004d4ae0((char *)(puVar1 + 2),param_3,iVar2);
    if (iVar3 == 0) {
      local_c = local_c + 1;
      (**(code **)(*param_1 + 4))(param_1,puVar1 + 2,puVar1[1]);
    }
  }
  return local_c;
}



/* @00403bdc file=? name=FUN_00403bdc */

undefined4 FUN_00403bdc(void)

{
  return 1;
}



/* @00403be8 file=? name=FUN_00403be8 */

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

{
  char cVar1;
  uint uVar2;
  uint uVar3;
  char *pcVar4;
  char *pcVar5;
  
  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 + 8);
  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;
  }
  return (char *)(param_1 + 8);
}



/* @00403c20 file=? name=FUN_00403c20 */

bool __cdecl FUN_00403c20(int param_1,char *param_2)

{
  char cVar1;
  char *pcVar2;
  bool bVar3;
  
  if (param_2 == (char *)0x0) {
    bVar3 = param_1 == -8;
  }
  else {
    pcVar2 = (char *)(param_1 + 8);
    do {
      cVar1 = *pcVar2;
      if (cVar1 != *param_2) {
        return cVar1 == *param_2;
      }
      if (cVar1 == '\0') {
        return true;
      }
      cVar1 = pcVar2[1];
      if (cVar1 != param_2[1]) {
        return cVar1 == param_2[1];
      }
      pcVar2 = pcVar2 + 2;
      param_2 = param_2 + 2;
      bVar3 = cVar1 == '\0';
    } while (!bVar3);
  }
  return bVar3;
}



/* @00403c68 file=? name=FUN_00403c68 */

undefined4 FUN_00403c68(void)

{
  return 1;
}



/* @00403c74 file=? name=FUN_00403c74 */

undefined4 * __cdecl FUN_00403c74(undefined4 *param_1)

{
  FUN_00403a30(param_1);
  *param_1 = &PTR_FUN_004e0b24;
  return param_1;
}



/* @00403c90 file=? name=FUN_00403c90 */

void __cdecl FUN_00403c90(int *param_1,byte param_2)

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



/* @00403cbc file=? name=FUN_00403cbc */

undefined4 * __cdecl FUN_00403cbc(int param_1,int param_2)

{
  undefined4 *puVar1;
  
  for (puVar1 = *(undefined4 **)(param_1 + 4);
      (puVar1 != (undefined4 *)0x0 && (param_2 != puVar1[1])); puVar1 = (undefined4 *)*puVar1) {
  }
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = puVar1 + 2;
  }
  return puVar1;
}



/* @00403ce4 file=? name=FUN_00403ce4 */

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

{
  char *pcVar1;
  undefined4 *puVar2;
  char *pcVar3;
  char *pcVar4;
  bool bVar5;
  
  puVar2 = *(undefined4 **)(param_1 + 4);
  do {
    if (puVar2 == (undefined4 *)0x0) {
      return (undefined4 *)0x0;
    }
    pcVar3 = (char *)(puVar2 + 2);
    pcVar4 = param_2;
    do {
      if (*pcVar3 != *pcVar4) goto LAB_00403d19;
      bVar5 = true;
      if (*pcVar3 == '\0') break;
      pcVar1 = pcVar3 + 1;
      if (*pcVar1 != pcVar4[1]) goto LAB_00403d19;
      pcVar3 = pcVar3 + 2;
      pcVar4 = pcVar4 + 2;
      bVar5 = *pcVar1 == '\0';
    } while (!bVar5);
    if (bVar5) {
      return puVar2;
    }
LAB_00403d19:
    puVar2 = (undefined4 *)*puVar2;
  } while( true );
}



/* @00403d28 file=? name=FUN_00403d28 */

void __cdecl FUN_00403d28(int param_1,int param_2)

{
  undefined4 *puVar1;
  
  for (puVar1 = *(undefined4 **)(param_1 + 4);
      (puVar1 != (undefined4 *)0x0 && (param_2 != puVar1[1])); puVar1 = (undefined4 *)*puVar1) {
  }
  return;
}



/* @00403d48 file=? name=FUN_00403d48 */

void __cdecl FUN_00403d48(int param_1,char *param_2)

{
  char *pcVar1;
  int *piVar2;
  int *piVar3;
  int *piVar4;
  char *pcVar5;
  bool bVar6;
  
  piVar2 = (int *)0x0;
  for (piVar3 = *(int **)(param_1 + 4); piVar3 != (int *)0x0; piVar3 = (int *)*piVar3) {
    piVar4 = piVar3 + 2;
    pcVar5 = param_2;
    do {
      if ((char)*piVar4 != *pcVar5) goto LAB_00403d7e;
      bVar6 = true;
      if ((char)*piVar4 == '\0') break;
      pcVar1 = (char *)((int)piVar4 + 1);
      if (*pcVar1 != pcVar5[1]) goto LAB_00403d7e;
      piVar4 = (int *)((int)piVar4 + 2);
      pcVar5 = pcVar5 + 2;
      bVar6 = *pcVar1 == '\0';
    } while (!bVar6);
    if (bVar6) break;
LAB_00403d7e:
    piVar2 = piVar3;
  }
  if (piVar3 != (int *)0x0) {
    if (piVar2 == (int *)0x0) {
      *(int *)(param_1 + 4) = *piVar3;
    }
    else {
      *piVar2 = *piVar3;
    }
    if (piVar3 == *(int **)(param_1 + 8)) {
      *(int **)(param_1 + 8) = piVar2;
    }
    FUN_004022d0(piVar3);
  }
  return;
}



/* @00403db0 file=? name=FUN_00403db0 */

undefined4 * __cdecl FUN_00403db0(undefined4 *param_1)

{
  FUN_00403c74(param_1);
  *param_1 = &PTR_FUN_004e0b1c;
  return param_1;
}



/* @00403dcc file=? name=FUN_00403dcc */

void __cdecl FUN_00403dcc(int *param_1,byte param_2)

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



/* @00403df8 file=? name=FUN_00403df8 */

undefined4 * __cdecl FUN_00403df8(int param_1,byte *param_2,undefined4 param_3)

{
  byte bVar1;
  undefined4 *puVar2;
  undefined4 *puVar3;
  int iVar4;
  undefined4 *puVar5;
  byte *pbVar6;
  byte *pbVar7;
  bool bVar8;
  
  iVar4 = FUN_004d4a78((char *)param_2);
  puVar5 = (undefined4 *)FUN_004022b0(iVar4 + 9);
  puVar3 = (undefined4 *)0x0;
  for (puVar2 = *(undefined4 **)(param_1 + 4); puVar2 != (undefined4 *)0x0;
      puVar2 = (undefined4 *)*puVar2) {
    pbVar7 = (byte *)(puVar2 + 2);
    pbVar6 = param_2;
    do {
      bVar1 = *pbVar6;
      bVar8 = bVar1 < *pbVar7;
      if ((bVar1 != *pbVar7) || (bVar8 = false, bVar1 == 0)) break;
      bVar1 = pbVar6[1];
      bVar8 = bVar1 < pbVar7[1];
      if (bVar1 != pbVar7[1]) break;
      pbVar6 = pbVar6 + 2;
      pbVar7 = pbVar7 + 2;
      bVar8 = false;
    } while (bVar1 != 0);
    if (bVar8) break;
    puVar3 = puVar2;
  }
  if (puVar2 == (undefined4 *)0x0) {
    *(undefined4 **)(param_1 + 8) = puVar5;
  }
  if (puVar3 == (undefined4 *)0x0) {
    *(undefined4 **)(param_1 + 4) = puVar5;
  }
  else {
    *puVar3 = puVar5;
  }
  puVar5[1] = param_3;
  *puVar5 = puVar2;
  FUN_00403be8((int)puVar5,(char *)param_2);
  return puVar5 + 2;
}



/* @00403e84 file=? name=FUN_00403e84 */

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

{
  *param_1 = 0;
  param_1[2] = 0;
  param_1[1] = 0;
  param_1[4] = 0;
  param_1[3] = 0;
  param_1[5] = 0;
  param_1[6] = 0;
  param_1[7] = param_3;
  if ((param_2 != (char *)0x0) && (*param_2 != '\0')) {
    FUN_00404bfc(param_1,param_2);
  }
  return param_1;
}



/* @00403ecc file=? name=FUN_00403ecc */

void __cdecl FUN_00403ecc(int *param_1,byte param_2)

{
  int *piVar1;
  char *pcVar2;
  int iVar3;
  
  if (param_1 != (int *)0x0) {
    piVar1 = (int *)param_1[1];
    if ((((param_1[5] != 0) && ((char *)*param_1 != (char *)0x0)) && (*(char *)*param_1 != '\0')) &&
       (iVar3 = FUN_00404d6c(param_1,(char *)0x0), iVar3 == 0)) {
      pcVar2 = (char *)*param_1;
      FUN_004dbb24((int *)&DAT_00524e68,s_NotationFile__Error_writing_file_004e0b38,(char *)0x0);
      FUN_004dbb24((int *)&DAT_00524e68,pcVar2,(char *)0x0);
      FUN_004dbb24((int *)&DAT_00524e68,s_____changes_lost__004e0b5c,(char *)0x0);
      FUN_004d9c38((int *)&DAT_00524e68);
    }
    while (piVar1 != (int *)0x0) {
      param_1[1] = piVar1[1];
      FUN_004056ac(piVar1,3);
      piVar1 = (int *)param_1[1];
    }
    if ((int *)*param_1 != (int *)0x0) {
      FUN_004022d0((int *)*param_1);
    }
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00403f84 file=? name=FUN_00403f84 */

void __cdecl FUN_00403f84(int param_1,char *param_2)

{
  int local_8;
  
  FUN_004050ac(param_1,param_2,&local_8);
  return;
}



/* @00403fa0 file=? name=FUN_00403fa0 */

undefined4 __cdecl FUN_00403fa0(int param_1,char *param_2)

{
  int iVar1;
  undefined4 uVar2;
  int local_8;
  
  iVar1 = FUN_004050ac(param_1,param_2,&local_8);
  if (iVar1 == 0) {
    uVar2 = 0;
  }
  else if ((*(byte *)(param_1 + 0x1c) & 4) == 0) {
    uVar2 = *(undefined4 *)(local_8 + 0x10);
  }
  else {
    uVar2 = *(undefined4 *)(local_8 + 0x14);
  }
  return uVar2;
}



/* @00403fdc file=? name=FUN_00403fdc */

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

{
  int iVar1;
  int local_8;
  
  *(undefined4 *)(param_1 + 0x14) = 1;
  iVar1 = FUN_004050ac(param_1,param_2,&local_8);
  if (iVar1 == 0) {
    local_8 = FUN_0040402c(param_1,param_2,param_3);
  }
  else {
    FUN_004057c8(local_8,param_3);
  }
  return local_8;
}



/* @0040402c file=? name=FUN_0040402c */

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

{
  undefined4 *puVar1;
  int iVar2;
  
  *(undefined4 *)(param_1 + 0x14) = 1;
  puVar1 = (undefined4 *)FUN_00402298(0x24);
  if (puVar1 == (undefined4 *)0x0) {
    iVar2 = 0;
  }
  else {
    iVar2 = FUN_0040567c(puVar1,param_1);
  }
  FUN_00405704(iVar2,param_2,(int *)(param_1 + 0x10));
  FUN_004057c8(iVar2,param_3);
  FUN_00405074(param_1,iVar2);
  return iVar2;
}



/* @00404088 file=? name=FUN_00404088 */

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

{
  int iVar1;
  int local_c;
  int *local_8;
  
  iVar1 = FUN_004050ac(param_1,param_2,(int *)&local_8);
  if ((iVar1 != 0) && (iVar1 = FUN_00405868(local_8,param_3,&local_c), iVar1 != 0)) {
    *param_4 = *(undefined4 *)(local_c + 8);
    return 1;
  }
  return 0;
}



/* @004040d8 file=? name=FUN_004040d8 */

bool __cdecl FUN_004040d8(int param_1,char *param_2,char *param_3,int *param_4)

{
  int iVar1;
  int iVar2;
  char *local_8;
  
  iVar1 = FUN_00404088(param_1,param_2,param_3,&local_8);
  if (iVar1 != 0) {
    iVar2 = FUN_004dd1e0(local_8);
    *param_4 = iVar2;
  }
  return iVar1 != 0;
}



/* @00404118 file=? name=FUN_00404118 */

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

{
  int iVar1;
  float10 fVar2;
  undefined4 local_8;
  
  iVar1 = FUN_00404088(param_1,param_2,param_3,&local_8);
  if (iVar1 != 0) {
    fVar2 = (float10)FUN_004dd1cc(local_8);
    *param_4 = (float)fVar2;
    return 1;
  }
  return 0;
}



/* @00404154 file=? name=FUN_00404154 */

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

{
  int iVar1;
  float10 fVar2;
  undefined4 local_8;
  
  iVar1 = FUN_00404088(param_1,param_2,param_3,&local_8);
  if (iVar1 != 0) {
    fVar2 = (float10)FUN_004dd1cc(local_8);
    *param_4 = (double)fVar2;
    return 1;
  }
  return 0;
}



/* @00404190 file=? name=FUN_00404190 */

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

{
  int iVar1;
  undefined4 uVar2;
  char *local_8;
  
  iVar1 = FUN_00404088(param_1,param_2,param_3,&local_8);
  if (iVar1 != 0) {
    iVar1 = FUN_004d4b58(local_8,&DAT_004e0b6e);
    if (((iVar1 == 0) || (iVar1 = FUN_004d4b58(local_8,&DAT_004e0b73), iVar1 == 0)) ||
       (iVar1 = FUN_004dd1e0(local_8), iVar1 != 0)) {
      uVar2 = 1;
    }
    else {
      uVar2 = 0;
    }
    *param_4 = uVar2;
    return 1;
  }
  return 0;
}



/* @00404204 file=? name=FUN_00404204 */

void __cdecl FUN_00404204(int param_1,char *param_2,char *param_3,char *param_4)

{
  int iVar1;
  int *piVar2;
  int *local_8;
  
  *(undefined4 *)(param_1 + 0x14) = 1;
  iVar1 = FUN_004050ac(param_1,param_2,(int *)&local_8);
  if (iVar1 == 0) {
    local_8 = (int *)FUN_0040402c(param_1,param_2,(char *)0x0);
  }
  piVar2 = (int *)FUN_00402298(0x10);
  if (piVar2 != (int *)0x0) {
    *piVar2 = 0;
    piVar2[2] = 0;
    piVar2[1] = 0;
    piVar2[3] = 0;
  }
  FUN_0040548c((int)piVar2,param_3,local_8 + 5);
  FUN_00405548((int)piVar2,param_4);
  FUN_00405920(local_8,piVar2);
  return;
}



/* @00404298 file=? name=FUN_00404298 */

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

{
  int *piVar1;
  int local_8c [15];
  int local_4e [18];
  
  FUN_004db158(local_8c,0,&DAT_00521410,0xc,2);
  piVar1 = FUN_004db78c(local_4e,param_4);
  FUN_004d9c58(piVar1);
  FUN_00404204(param_1,param_2,param_3,&DAT_00521410);
  FUN_004db428(local_8c,2);
  return;
}



/* @00404304 file=? name=FUN_00404304 */

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

{
  int *piVar1;
  int local_90 [15];
  int local_52 [18];
  float local_8;
  
  FUN_004db158(local_90,0,&DAT_0052141c,0x20,2);
  local_8 = param_4;
  piVar1 = FUN_004db634(local_52,(float10)param_4);
  FUN_004d9c58(piVar1);
  FUN_00404204(param_1,param_2,param_3,&DAT_0052141c);
  FUN_004db428(local_90,2);
  return;
}



/* @0040437c file=? name=FUN_0040437c */

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

{
  int *piVar1;
  int local_94 [15];
  int local_56 [18];
  undefined4 local_c;
  undefined4 uStack_8;
  
  FUN_004db158(local_94,0,&DAT_0052143c,0x40,2);
  local_c = param_4;
  uStack_8 = param_5;
  piVar1 = FUN_004db634(local_56,(float10)(double)CONCAT44(param_5,param_4));
  FUN_004d9c58(piVar1);
  FUN_00404204(param_1,param_2,param_3,&DAT_0052143c);
  FUN_004db428(local_94,2);
  return;
}



/* @004043f8 file=? name=FUN_004043f8 */

void __cdecl FUN_004043f8(int param_1,char *param_2,char *param_3,int param_4)

{
  int local_8c [15];
  int local_4e [18];
  
  FUN_004db158(local_8c,0,&DAT_0052147c,6,2);
  if (param_4 == 0) {
    FUN_004dbb24(local_4e,s_False_004e0b7c,(char *)0x0);
    FUN_004d9c58(local_4e);
  }
  else {
    FUN_004dbb24(local_4e,&DAT_004e0b77,(char *)0x0);
    FUN_004d9c58(local_4e);
  }
  FUN_00404204(param_1,param_2,param_3,&DAT_0052147c);
  FUN_004db428(local_8c,2);
  return;
}



/* @00404490 file=? name=FUN_00404490 */

void __cdecl FUN_00404490(int param_1,char *param_2,char *param_3,char *param_4)

{
  int iVar1;
  undefined4 *puVar2;
  int local_8;
  
  *(undefined4 *)(param_1 + 0x14) = 1;
  iVar1 = FUN_004050ac(param_1,param_2,&local_8);
  if (iVar1 == 0) {
    local_8 = FUN_0040402c(param_1,param_2,(char *)0x0);
  }
  puVar2 = (undefined4 *)FUN_00402298(0x10);
  if (puVar2 != (undefined4 *)0x0) {
    *puVar2 = 0;
    puVar2[2] = 0;
    puVar2[1] = 0;
    puVar2[3] = 0;
  }
  FUN_0040548c((int)puVar2,param_3,(int *)(local_8 + 0x14));
  FUN_00405548((int)puVar2,param_4);
  FUN_00405834(local_8,puVar2);
  return;
}



/* @00404528 file=? name=FUN_00404528 */

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

{
  int *piVar1;
  int local_8c [15];
  int local_4e [18];
  
  FUN_004db158(local_8c,0,&DAT_00521482,0xc,2);
  piVar1 = FUN_004db78c(local_4e,param_4);
  FUN_004d9c58(piVar1);
  FUN_00404490(param_1,param_2,param_3,&DAT_00521482);
  FUN_004db428(local_8c,2);
  return;
}



/* @00404594 file=? name=FUN_00404594 */

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

{
  int *piVar1;
  int local_90 [15];
  int local_52 [18];
  float local_8;
  
  FUN_004db158(local_90,0,&DAT_0052148e,0x20,2);
  local_8 = param_4;
  piVar1 = FUN_004db634(local_52,(float10)param_4);
  FUN_004d9c58(piVar1);
  FUN_00404490(param_1,param_2,param_3,&DAT_0052148e);
  FUN_004db428(local_90,2);
  return;
}



/* @0040460c file=? name=FUN_0040460c */

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

{
  int *piVar1;
  int local_94 [15];
  int local_56 [18];
  undefined4 local_c;
  undefined4 uStack_8;
  
  FUN_004db158(local_94,0,&DAT_005214ae,0x40,2);
  local_c = param_4;
  uStack_8 = param_5;
  piVar1 = FUN_004db634(local_56,(float10)(double)CONCAT44(param_5,param_4));
  FUN_004d9c58(piVar1);
  FUN_00404490(param_1,param_2,param_3,&DAT_005214ae);
  FUN_004db428(local_94,2);
  return;
}



/* @00404688 file=? name=FUN_00404688 */

void __cdecl FUN_00404688(int param_1,char *param_2,char *param_3,int param_4)

{
  int local_8c [15];
  int local_4e [18];
  
  FUN_004db158(local_8c,0,&DAT_005214ee,6,2);
  if (param_4 == 0) {
    FUN_004dbb24(local_4e,s_False_004e0b87,(char *)0x0);
    FUN_004d9c58(local_4e);
  }
  else {
    FUN_004dbb24(local_4e,&DAT_004e0b82,(char *)0x0);
    FUN_004d9c58(local_4e);
  }
  FUN_00404490(param_1,param_2,param_3,&DAT_005214ee);
  FUN_004db428(local_8c,2);
  return;
}



/* @00404720 file=? name=FUN_00404720 */

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

{
  int iVar1;
  int *piVar2;
  int local_8;
  
  iVar1 = FUN_004050ac(param_1,param_2,&local_8);
  if (iVar1 == 0) {
    piVar2 = (int *)0x0;
  }
  else {
    piVar2 = FUN_00404758(param_1,local_8,param_3);
  }
  return piVar2;
}



/* @00404758 file=? name=FUN_00404758 */

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

{
  char *pcVar1;
  int iVar2;
  undefined4 *puVar3;
  int *piVar4;
  int iVar5;
  char *pcVar6;
  bool bVar7;
  
  pcVar6 = param_3;
  if (param_3 == (char *)0x0) {
    pcVar6 = &DAT_004e0b8d;
  }
  iVar2 = FUN_004d4a78(pcVar6);
  puVar3 = (undefined4 *)FUN_00402298(0xc);
  if (puVar3 == (undefined4 *)0x0) {
    piVar4 = (int *)0x0;
  }
  else {
    piVar4 = FUN_00403c74(puVar3);
  }
  for (puVar3 = *(undefined4 **)(param_2 + 8); puVar3 != (undefined4 *)0x0;
      puVar3 = (undefined4 *)*puVar3) {
    pcVar1 = (char *)puVar3[1];
    if (pcVar1 == (char *)0x0) {
      bVar7 = param_3 == (char *)0x0;
    }
    else if ((*(byte *)(param_1 + 0x1c) & 0x10) == 0) {
      iVar5 = FUN_004d4ae0(pcVar1,pcVar6,iVar2);
      bVar7 = iVar5 == 0;
    }
    else {
      iVar5 = FUN_004d4bec(pcVar1,pcVar6,iVar2);
      bVar7 = iVar5 == 0;
    }
    if ((*(byte *)(param_1 + 0x1c) & 4) == 0) {
      if (pcVar1 == (char *)0x0) {
        if ((*(byte *)(param_1 + 0x1c) & 1) == 0) {
          bVar7 = false;
        }
        else {
          bVar7 = false;
        }
      }
    }
    else if ((puVar3[3] == 0) || (!bVar7)) {
      bVar7 = false;
    }
    else {
      bVar7 = true;
    }
    if (bVar7) {
      (**(code **)(*piVar4 + 4))(piVar4,pcVar1,puVar3[2]);
    }
  }
  return piVar4;
}



/* @0040485c file=? name=FUN_0040485c */

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

{
  int iVar1;
  char *pcVar2;
  int iVar3;
  undefined4 *puVar4;
  int *piVar5;
  int iVar6;
  char *pcVar7;
  bool bVar8;
  
  pcVar7 = param_2;
  if (param_2 == (char *)0x0) {
    pcVar7 = &DAT_004e0b8f;
  }
  iVar3 = FUN_004d4a78(pcVar7);
  puVar4 = (undefined4 *)FUN_00402298(0xc);
  if (puVar4 == (undefined4 *)0x0) {
    piVar5 = (int *)0x0;
  }
  else {
    piVar5 = FUN_00403c74(puVar4);
  }
  for (iVar1 = *(int *)(param_1 + 4); iVar1 != 0; iVar1 = *(int *)(iVar1 + 4)) {
    pcVar2 = *(char **)(iVar1 + 0x18);
    if (pcVar2 == (char *)0x0) {
      bVar8 = param_2 == (char *)0x0;
    }
    else if ((*(byte *)(param_1 + 0x1c) & 8) == 0) {
      iVar6 = FUN_004d4ae0(pcVar2,pcVar7,iVar3);
      bVar8 = iVar6 == 0;
    }
    else {
      iVar6 = FUN_004d4bec(pcVar2,pcVar7,iVar3);
      bVar8 = iVar6 == 0;
    }
    if ((*(byte *)(param_1 + 0x1c) & 2) == 0) {
      if (pcVar2 == (char *)0x0) {
        if ((*(byte *)(param_1 + 0x1c) & 1) == 0) {
          bVar8 = false;
        }
        else {
          bVar8 = false;
        }
      }
    }
    else if ((*(int *)(iVar1 + 0x20) == 0) || (!bVar8)) {
      bVar8 = false;
    }
    else {
      bVar8 = true;
    }
    if (bVar8) {
      (**(code **)(*piVar5 + 4))(piVar5,pcVar2,iVar1);
    }
  }
  return piVar5;
}



/* @00404954 file=? name=FUN_00404954 */

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

{
  int iVar1;
  int *piVar2;
  int local_8;
  
  iVar1 = FUN_004050ac(param_1,param_2,&local_8);
  if (iVar1 == 0) {
    piVar2 = (int *)0x0;
  }
  else {
    piVar2 = FUN_0040498c(param_1,local_8,param_3);
  }
  return piVar2;
}



/* @0040498c file=? name=FUN_0040498c */

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

{
  char *pcVar1;
  int iVar2;
  undefined4 *puVar3;
  int *piVar4;
  int iVar5;
  char *pcVar6;
  bool bVar7;
  
  pcVar6 = param_3;
  if (param_3 == (char *)0x0) {
    pcVar6 = &DAT_004e0b91;
  }
  iVar2 = FUN_004d4a78(pcVar6);
  puVar3 = (undefined4 *)FUN_00402298(0xc);
  if (puVar3 == (undefined4 *)0x0) {
    piVar4 = (int *)0x0;
  }
  else {
    piVar4 = FUN_00403db0(puVar3);
  }
  for (puVar3 = *(undefined4 **)(param_2 + 8); puVar3 != (undefined4 *)0x0;
      puVar3 = (undefined4 *)*puVar3) {
    pcVar1 = (char *)puVar3[1];
    if (pcVar1 == (char *)0x0) {
      bVar7 = param_3 == (char *)0x0;
    }
    else if ((*(byte *)(param_1 + 0x1c) & 0x10) == 0) {
      iVar5 = FUN_004d4ae0(pcVar1,pcVar6,iVar2);
      bVar7 = iVar5 == 0;
    }
    else {
      iVar5 = FUN_004d4bec(pcVar1,pcVar6,iVar2);
      bVar7 = iVar5 == 0;
    }
    if ((*(byte *)(param_1 + 0x1c) & 4) == 0) {
      if (pcVar1 == (char *)0x0) {
        if ((*(byte *)(param_1 + 0x1c) & 1) == 0) {
          bVar7 = false;
        }
        else {
          bVar7 = false;
        }
      }
    }
    else if ((puVar3[3] == 0) || (!bVar7)) {
      bVar7 = false;
    }
    else {
      bVar7 = true;
    }
    if (bVar7) {
      (**(code **)(*piVar4 + 4))(piVar4,pcVar1,puVar3[2]);
    }
  }
  return piVar4;
}



/* @00404a90 file=? name=FUN_00404a90 */

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

{
  int iVar1;
  char *pcVar2;
  int iVar3;
  undefined4 *puVar4;
  int *piVar5;
  int iVar6;
  char *pcVar7;
  bool bVar8;
  
  pcVar7 = param_2;
  if (param_2 == (char *)0x0) {
    pcVar7 = &DAT_004e0b93;
  }
  iVar3 = FUN_004d4a78(pcVar7);
  puVar4 = (undefined4 *)FUN_00402298(0xc);
  if (puVar4 == (undefined4 *)0x0) {
    piVar5 = (int *)0x0;
  }
  else {
    piVar5 = FUN_00403db0(puVar4);
  }
  for (iVar1 = *(int *)(param_1 + 4); iVar1 != 0; iVar1 = *(int *)(iVar1 + 4)) {
    pcVar2 = *(char **)(iVar1 + 0x18);
    if (pcVar2 == (char *)0x0) {
      bVar8 = param_2 == (char *)0x0;
    }
    else if ((*(byte *)(param_1 + 0x1c) & 8) == 0) {
      iVar6 = FUN_004d4ae0(pcVar2,pcVar7,iVar3);
      bVar8 = iVar6 == 0;
    }
    else {
      iVar6 = FUN_004d4bec(pcVar2,pcVar7,iVar3);
      bVar8 = iVar6 == 0;
    }
    if ((*(byte *)(param_1 + 0x1c) & 2) == 0) {
      if (pcVar2 == (char *)0x0) {
        if ((*(byte *)(param_1 + 0x1c) & 1) == 0) {
          bVar8 = false;
        }
        else {
          bVar8 = false;
        }
      }
    }
    else if ((*(int *)(iVar1 + 0x20) == 0) || (!bVar8)) {
      bVar8 = false;
    }
    else {
      bVar8 = true;
    }
    if (bVar8) {
      (**(code **)(*piVar5 + 4))(piVar5,pcVar2,iVar1);
    }
  }
  return piVar5;
}



/* @00404b88 file=? name=FUN_00404b88 */

void __cdecl FUN_00404b88(int param_1,char *param_2,char *param_3)

{
  int iVar1;
  int *local_8;
  
  iVar1 = FUN_004050ac(param_1,param_2,(int *)&local_8);
  if (iVar1 != 0) {
    *(undefined4 *)(param_1 + 0x14) = 1;
    FUN_00405988(local_8,param_3);
  }
  return;
}



/* @00404bc0 file=? name=FUN_00404bc0 */

void __cdecl FUN_00404bc0(int param_1,char *param_2)

{
  int iVar1;
  int local_c;
  int *local_8;
  
  iVar1 = FUN_00405190(param_1,param_2,(int *)&local_8,&local_c);
  if (iVar1 != 0) {
    FUN_00405224(param_1,local_8,local_c);
  }
  return;
}



/* @00404bfc file=? name=FUN_00404bfc */

void __cdecl FUN_00404bfc(int *param_1,char *param_2)

{
  char cVar1;
  int iVar2;
  int iVar3;
  int *piVar4;
  uint uVar5;
  uint uVar6;
  char *pcVar7;
  char *pcVar8;
  char local_294 [512];
  int local_94 [17];
  int local_50 [19];
  
  FUN_004da66c(local_94,0,param_2,1,DAT_00520540);
  iVar2 = param_1[3];
  if (*param_1 == 0) {
    iVar3 = FUN_004d4a78(param_2);
    iVar3 = FUN_004022b0(iVar3 + 1);
    *param_1 = iVar3;
    uVar5 = 0xffffffff;
    do {
      pcVar7 = param_2;
      if (uVar5 == 0) break;
      uVar5 = uVar5 - 1;
      pcVar7 = param_2 + 1;
      cVar1 = *param_2;
      param_2 = pcVar7;
    } while (cVar1 != '\0');
    uVar5 = ~uVar5;
    pcVar7 = pcVar7 + -uVar5;
    pcVar8 = (char *)*param_1;
    for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
      *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
      pcVar7 = pcVar7 + 4;
      pcVar8 = pcVar8 + 4;
    }
    for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
      *pcVar8 = *pcVar7;
      pcVar7 = pcVar7 + 1;
      pcVar8 = pcVar8 + 1;
    }
  }
  if ((*(byte *)(local_94[0] + 0xc) & 0x86) != 0) {
    local_94[0] = 0;
  }
  if (local_94[0] != 0) {
    while( true ) {
      piVar4 = FUN_004dad10(local_50,local_294,0x200,10);
      iVar3 = *piVar4;
      if ((*(byte *)(iVar3 + 0xc) & 0x86) != 0) {
        iVar3 = 0;
      }
      if (iVar3 == 0) break;
      FUN_0040527c((int)param_1,local_294);
    }
    FUN_004da44c(local_94);
    FUN_0040527c((int)param_1,(char *)0x0);
  }
  if (iVar2 == 0) {
    param_1[5] = 0;
  }
  FUN_004da754(local_94,2);
  return;
}



/* @00404d00 file=? name=FUN_00404d00 */

void __cdecl FUN_00404d00(int param_1,char *param_2,int param_3)

{
  int iVar1;
  char *pcVar2;
  char *pcVar3;
  
  iVar1 = *(int *)(param_1 + 0xc);
  pcVar3 = param_2 + param_3;
  while (param_2 < pcVar3) {
    pcVar2 = FUN_004d49f4(param_2,'\0');
    FUN_0040527c(param_1,param_2);
    param_2 = pcVar2 + 1;
  }
  FUN_0040527c(param_1,(char *)0x0);
  if (iVar1 == 0) {
    *(undefined4 *)(param_1 + 0x14) = 0;
  }
  return;
}



/* @00404d6c file=? name=FUN_00404d6c */

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

{
  char cVar1;
  LPCSTR pCVar2;
  int iVar3;
  char *pcVar4;
  uint uVar5;
  uint uVar6;
  char *pcVar7;
  undefined4 uVar8;
  int local_90 [17];
  int local_4c [18];
  
  FUN_004db014(local_90,0);
  if ((param_2 == (char *)0x0) || (*param_2 == '\0')) {
    pCVar2 = (LPCSTR)*param_1;
    if ((pCVar2 == (LPCSTR)0x0) || (*pCVar2 == '\0')) {
      uVar8 = 0;
      FUN_004db0ec(local_90,2);
      return uVar8;
    }
    FUN_004da5f8(local_90,pCVar2,2,DAT_00520540);
  }
  else {
    FUN_004da5f8(local_90,param_2,2,DAT_00520540);
  }
  if ((*(byte *)(local_90[0] + 0xc) & 0x86) != 0) {
    local_90[0] = 0;
  }
  if (local_90[0] == 0) {
    uVar8 = 0;
    FUN_004db0ec(local_90,2);
  }
  else {
    FUN_00405400((int)param_1,local_4c,1);
    FUN_004da44c(local_90);
    if ((param_2 != (char *)0x0) && (*param_2 != '\0')) {
      if ((int *)*param_1 != (int *)0x0) {
        FUN_004022d0((int *)*param_1);
      }
      iVar3 = FUN_004d4a78(param_2);
      pcVar4 = (char *)FUN_004022b0(iVar3 + 1);
      *param_1 = pcVar4;
      uVar5 = 0xffffffff;
      do {
        pcVar7 = param_2;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar7 = param_2 + 1;
        cVar1 = *param_2;
        param_2 = pcVar7;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar7 = pcVar7 + -uVar5;
      for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar4 = *(undefined4 *)pcVar7;
        pcVar7 = pcVar7 + 4;
        pcVar4 = pcVar4 + 4;
      }
      for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar4 = *pcVar7;
        pcVar7 = pcVar7 + 1;
        pcVar4 = pcVar4 + 1;
      }
    }
    param_1[5] = 0;
    uVar8 = 1;
    FUN_004db0ec(local_90,2);
  }
  return uVar8;
}



/* @00404eb8 file=? name=FUN_00404eb8 */

int __cdecl FUN_00404eb8(int param_1)

{
  int iVar1;
  int local_90 [17];
  int local_4c [18];
  
  FUN_004db014(local_90,0);
  iVar1 = FUN_00405400(param_1,local_4c,0);
  FUN_004db0ec(local_90,2);
  return iVar1;
}



/* @00404f00 file=? name=FUN_00404f00 */

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

{
  int iVar1;
  int local_8c [15];
  int local_4e [18];
  
  FUN_004db158(local_8c,0,param_2,param_3,2);
  iVar1 = FUN_00405400(param_1,local_4e,2);
  if (param_3 < iVar1) {
    iVar1 = -1;
    FUN_004db428(local_8c,2);
  }
  else {
    *(undefined4 *)(param_1 + 0x14) = 0;
    FUN_004db428(local_8c,2);
  }
  return iVar1;
}



/* @00404f78 file=? name=FUN_00404f78 */

void __cdecl FUN_00404f78(int *param_1)

{
  int *piVar1;
  int iVar2;
  int local_24 [8];
  
  param_1[5] = 0;
  FUN_00403ecc(param_1,2);
  piVar1 = FUN_00403e84(local_24,(char *)0x0,1);
  for (iVar2 = 8; iVar2 != 0; iVar2 = iVar2 + -1) {
    *param_1 = *piVar1;
    piVar1 = piVar1 + 1;
    param_1 = param_1 + 1;
  }
  FUN_00403ecc(local_24,2);
  return;
}



/* @00404fc4 file=? name=FUN_00404fc4 */

void __cdecl FUN_00404fc4(int param_1)

{
  char *pcVar1;
  int *piVar2;
  int *piVar3;
  char *pcVar4;
  char *pcVar5;
  bool bVar6;
  int *local_8;
  
  local_8 = (int *)0x0;
  piVar2 = *(int **)(param_1 + 4);
joined_r0x00404fd8:
  do {
    do {
      piVar3 = local_8;
      local_8 = piVar2;
      if (local_8 == (int *)0x0) {
        return;
      }
      piVar2 = (int *)local_8[1];
      pcVar4 = (char *)local_8[6];
    } while (*pcVar4 == '_');
    pcVar5 = s_LAB_ONLY_004e0b95;
    do {
      bVar6 = *pcVar4 == *pcVar5;
      if (!bVar6) break;
      if (*pcVar4 == '\0') goto joined_r0x00404fd8;
      pcVar1 = pcVar4 + 1;
      bVar6 = *pcVar1 == pcVar5[1];
      if (!bVar6) break;
      pcVar4 = pcVar4 + 2;
      pcVar5 = pcVar5 + 2;
      bVar6 = *pcVar1 == '\0';
    } while (!bVar6);
    if (!bVar6) {
      FUN_00405224(param_1,local_8,(int)piVar3);
      local_8 = piVar3;
    }
  } while( true );
}



/* @00405030 file=? name=FUN_00405030 */

void __cdecl FUN_00405030(int param_1)

{
  int iVar1;
  
  iVar1 = FUN_00403f84(param_1,s_LAB_ONLY_004e0b9e);
  if (iVar1 == 0) {
    FUN_00403fdc(param_1,s_LAB_ONLY_004e0ba7,s____this_file_has_not_been_approv_004e0bb0);
    FUN_00404490(param_1,s_LAB_ONLY_004e0be0,(char *)0x0,(char *)0x0);
  }
  return;
}



/* @00405074 file=? name=FUN_00405074 */

void __cdecl FUN_00405074(int param_1,int param_2)

{
  if (*(int *)(param_1 + 8) == 0) {
    *(int *)(param_1 + 4) = param_2;
  }
  else {
    *(int *)(*(int *)(param_1 + 8) + 4) = param_2;
  }
  *(int *)(param_1 + 8) = param_2;
  *(undefined4 *)(param_2 + 4) = 0;
  if (*(int *)(param_2 + 0x20) != 0) {
    *(int *)(param_1 + 0x10) = *(int *)(param_1 + 0x10) + 1;
  }
  *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;
  return;
}



/* @004050ac file=? name=FUN_004050ac */

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

{
  char *pcVar1;
  int iVar2;
  char *pcVar3;
  int iVar4;
  char *pcVar5;
  bool bVar6;
  
  if ((*(int *)(param_1 + 0x18) != 0) && (*(int *)(*(int *)(param_1 + 0x18) + 0x18) != 0)) {
    if (((*(byte *)(param_1 + 0x1c) & 8) != 0) &&
       (iVar2 = FUN_004d4b58(*(char **)(*(int *)(param_1 + 0x18) + 0x18),param_2), iVar2 == 0)) {
LAB_0040510c:
      *param_3 = *(int *)(param_1 + 0x18);
      return 1;
    }
    if ((*(byte *)(param_1 + 0x1c) & 8) == 0) {
      pcVar3 = *(char **)(*(int *)(param_1 + 0x18) + 0x18);
      pcVar5 = param_2;
      do {
        if (*pcVar3 != *pcVar5) goto LAB_0040511b;
        bVar6 = true;
        if (*pcVar3 == '\0') break;
        pcVar1 = pcVar3 + 1;
        if (*pcVar1 != pcVar5[1]) goto LAB_0040511b;
        pcVar3 = pcVar3 + 2;
        pcVar5 = pcVar5 + 2;
        bVar6 = *pcVar1 == '\0';
      } while (!bVar6);
      if (bVar6) goto LAB_0040510c;
    }
  }
LAB_0040511b:
  iVar2 = *(int *)(param_1 + 4);
  do {
    if (iVar2 == 0) {
      *param_3 = 0;
      return 0;
    }
    if (*(int *)(iVar2 + 0x18) != 0) {
      if (((*(byte *)(param_1 + 0x1c) & 8) != 0) &&
         (iVar4 = FUN_004d4b58(*(char **)(iVar2 + 0x18),param_2), iVar4 == 0)) {
LAB_00405169:
        *(int *)(param_1 + 0x18) = iVar2;
        *param_3 = iVar2;
        return 1;
      }
      if ((*(byte *)(param_1 + 0x1c) & 8) == 0) {
        pcVar3 = *(char **)(iVar2 + 0x18);
        pcVar5 = param_2;
        do {
          if (*pcVar3 != *pcVar5) goto LAB_00405178;
          bVar6 = true;
          if (*pcVar3 == '\0') break;
          pcVar1 = pcVar3 + 1;
          if (*pcVar1 != pcVar5[1]) goto LAB_00405178;
          pcVar3 = pcVar3 + 2;
          pcVar5 = pcVar5 + 2;
          bVar6 = *pcVar1 == '\0';
        } while (!bVar6);
        if (bVar6) goto LAB_00405169;
      }
    }
LAB_00405178:
    iVar2 = *(int *)(iVar2 + 4);
  } while( true );
}



/* @00405190 file=? name=FUN_00405190 */

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

{
  char *pcVar1;
  int iVar2;
  int iVar3;
  char *pcVar4;
  char *pcVar5;
  bool bVar6;
  int local_8;
  
  local_8 = 0;
  iVar3 = *(int *)(param_1 + 4);
  do {
    iVar2 = iVar3;
    if (iVar2 == 0) {
      *param_4 = 0;
      *param_3 = 0;
      return 0;
    }
    if (*(int *)(iVar2 + 0x18) != 0) {
      if (((*(byte *)(param_1 + 0x1c) & 8) != 0) &&
         (iVar3 = FUN_004d4b58(*(char **)(iVar2 + 0x18),param_2), iVar3 == 0)) {
LAB_004051f0:
        *param_3 = iVar2;
        *param_4 = local_8;
        return 1;
      }
      if ((*(byte *)(param_1 + 0x1c) & 8) == 0) {
        pcVar4 = *(char **)(iVar2 + 0x18);
        pcVar5 = param_2;
        do {
          if (*pcVar4 != *pcVar5) goto LAB_00405204;
          bVar6 = true;
          if (*pcVar4 == '\0') break;
          pcVar1 = pcVar4 + 1;
          if (*pcVar1 != pcVar5[1]) goto LAB_00405204;
          pcVar4 = pcVar4 + 2;
          pcVar5 = pcVar5 + 2;
          bVar6 = *pcVar1 == '\0';
        } while (!bVar6);
        if (bVar6) goto LAB_004051f0;
      }
    }
LAB_00405204:
    iVar3 = *(int *)(iVar2 + 4);
    local_8 = iVar2;
  } while( true );
}



/* @00405224 file=? name=FUN_00405224 */

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

{
  *(undefined4 *)(param_1 + 0x14) = 1;
  if (param_3 == 0) {
    *(int *)(param_1 + 4) = param_2[1];
  }
  else {
    *(int *)(param_3 + 4) = param_2[1];
  }
  if (param_2 == *(int **)(param_1 + 8)) {
    *(int *)(param_1 + 8) = param_3;
  }
  if (param_2 == *(int **)(param_1 + 0x18)) {
    *(undefined4 *)(param_1 + 0x18) = 0;
  }
  if (param_2[8] != 0) {
    *(int *)(param_1 + 0x10) = *(int *)(param_1 + 0x10) + -1;
  }
  *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + -1;
  FUN_004056ac(param_2,3);
  return;
}



/* @0040527c file=? name=FUN_0040527c */

void __cdecl FUN_0040527c(int param_1,char *param_2)

{
  bool bVar1;
  char *pcVar2;
  undefined4 *puVar3;
  char *local_8;
  
  if (param_2 == (char *)0x0) {
    DAT_004e0b34 = 0;
  }
  else {
    for (; (*param_2 == ' ' || (*param_2 == '\t')); param_2 = param_2 + 1) {
    }
    if (*param_2 == '[') {
      pcVar2 = FUN_004d49f4(param_2 + 1,']');
      if (pcVar2 != (char *)0x0) {
        *pcVar2 = '\0';
        pcVar2 = pcVar2 + 1;
      }
      DAT_004e0b34 = FUN_0040402c(param_1,param_2 + 1,pcVar2);
    }
    else {
      if (((*param_2 == ';') || (*param_2 == '#')) || ((*param_2 == '/' && (param_2[1] == '/')))) {
        bVar1 = true;
      }
      else {
        bVar1 = false;
      }
      local_8 = FUN_004d49f4(param_2,'=');
      if (local_8 == (char *)0x0) {
        local_8 = (char *)0x0;
      }
      else {
        *local_8 = '\0';
        local_8 = local_8 + 1;
      }
      if (*param_2 == '\0') {
        param_2 = (char *)0x0;
      }
      if ((param_2 != (char *)0x0) && (!bVar1)) {
        pcVar2 = FUN_004d49f4(param_2,'\0');
        pcVar2 = pcVar2 + -1;
        do {
          if ((*pcVar2 != ' ') && (*pcVar2 != '\t')) break;
          *pcVar2 = '\0';
          pcVar2 = pcVar2 + -1;
        } while (param_2 <= pcVar2);
      }
      if (DAT_004e0b34 == 0) {
        puVar3 = (undefined4 *)FUN_00402298(0x24);
        if (puVar3 == (undefined4 *)0x0) {
          DAT_004e0b34 = 0;
        }
        else {
          DAT_004e0b34 = FUN_0040567c(puVar3,param_1);
        }
        FUN_00405074(param_1,DAT_004e0b34);
      }
      puVar3 = (undefined4 *)FUN_00402298(0x10);
      if (puVar3 != (undefined4 *)0x0) {
        *puVar3 = 0;
        puVar3[2] = 0;
        puVar3[1] = 0;
        puVar3[3] = 0;
      }
      FUN_0040548c((int)puVar3,param_2,(int *)(DAT_004e0b34 + 0x14));
      FUN_00405548((int)puVar3,local_8);
      FUN_00405834(DAT_004e0b34,puVar3);
    }
  }
  return;
}



/* @00405400 file=? name=FUN_00405400 */

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

{
  int iVar1;
  int iVar2;
  int iVar3;
  
  iVar3 = 0;
  for (iVar1 = *(int *)(param_1 + 4); iVar1 != 0; iVar1 = *(int *)(iVar1 + 4)) {
    iVar2 = FUN_004059fc(iVar1,param_2,param_3);
    iVar3 = iVar3 + iVar2;
  }
  return iVar3;
}



/* @00405434 file=? name=FUN_00405434 */

undefined4 FUN_00405434(void)

{
  return 1;
}



/* @00405454 file=? name=FUN_00405454 */

void __cdecl FUN_00405454(int *param_1,byte param_2)

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



/* @0040548c file=? name=FUN_0040548c */

void __cdecl FUN_0040548c(int param_1,char *param_2,int *param_3)

{
  char cVar1;
  bool bVar2;
  int iVar3;
  char *pcVar4;
  undefined4 uVar5;
  uint uVar6;
  uint uVar7;
  char *pcVar8;
  
  if (*(int *)(param_1 + 4) != 0) {
    if (*(int *)(param_1 + 0xc) != 0) {
      *(undefined4 *)(param_1 + 0xc) = 0;
      *param_3 = *param_3 + -1;
    }
    FUN_004022d0(*(int **)(param_1 + 4));
  }
  if (param_2 == (char *)0x0) {
    *(undefined4 *)(param_1 + 4) = 0;
    return;
  }
  iVar3 = FUN_004d4a78(param_2);
  pcVar4 = (char *)FUN_004022b0(iVar3 + 1);
  *(char **)(param_1 + 4) = pcVar4;
  uVar6 = 0xffffffff;
  do {
    pcVar8 = param_2;
    if (uVar6 == 0) break;
    uVar6 = uVar6 - 1;
    pcVar8 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar8;
  } while (cVar1 != '\0');
  uVar6 = ~uVar6;
  pcVar8 = pcVar8 + -uVar6;
  for (uVar7 = uVar6 >> 2; uVar7 != 0; uVar7 = uVar7 - 1) {
    *(undefined4 *)pcVar4 = *(undefined4 *)pcVar8;
    pcVar8 = pcVar8 + 4;
    pcVar4 = pcVar4 + 4;
  }
  for (uVar6 = uVar6 & 3; uVar6 != 0; uVar6 = uVar6 - 1) {
    *pcVar4 = *pcVar8;
    pcVar8 = pcVar8 + 1;
    pcVar4 = pcVar4 + 1;
  }
  pcVar4 = *(char **)(param_1 + 4);
  if (*pcVar4 != '\0') {
    if (((*pcVar4 == ';') || (*pcVar4 == '#')) || ((*pcVar4 == '/' && (pcVar4[1] == '/')))) {
      bVar2 = true;
    }
    else {
      bVar2 = false;
    }
    if (!bVar2) {
      uVar5 = 1;
      goto LAB_00405538;
    }
  }
  uVar5 = 0;
LAB_00405538:
  *(undefined4 *)(param_1 + 0xc) = uVar5;
  return;
}



/* @00405548 file=? name=FUN_00405548 */

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

{
  char cVar1;
  int iVar2;
  char *pcVar3;
  uint uVar4;
  uint uVar5;
  char *pcVar6;
  char *pcVar7;
  
  if (*(int **)(param_1 + 8) != (int *)0x0) {
    FUN_004022d0(*(int **)(param_1 + 8));
  }
  if (param_2 == (char *)0x0) {
    pcVar3 = (char *)0x0;
    *(undefined4 *)(param_1 + 8) = 0;
  }
  else {
    iVar2 = FUN_004d4a78(param_2);
    pcVar3 = (char *)FUN_004022b0(iVar2 + 1);
    *(char **)(param_1 + 8) = pcVar3;
    uVar4 = 0xffffffff;
    do {
      pcVar6 = param_2;
      if (uVar4 == 0) break;
      uVar4 = uVar4 - 1;
      pcVar6 = param_2 + 1;
      cVar1 = *param_2;
      param_2 = pcVar6;
    } while (cVar1 != '\0');
    uVar4 = ~uVar4;
    pcVar6 = pcVar6 + -uVar4;
    pcVar7 = pcVar3;
    for (uVar5 = uVar4 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {
      *(undefined4 *)pcVar7 = *(undefined4 *)pcVar6;
      pcVar6 = pcVar6 + 4;
      pcVar7 = pcVar7 + 4;
    }
    for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
      *pcVar7 = *pcVar6;
      pcVar6 = pcVar6 + 1;
      pcVar7 = pcVar7 + 1;
    }
  }
  return pcVar3;
}



/* @004055b0 file=? name=FUN_004055b0 */

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

{
  char *pcVar1;
  int iVar2;
  int iVar3;
  
  iVar3 = 0;
  if (*(char **)(param_1 + 4) != (char *)0x0) {
    if (param_3 != 0) {
      FUN_004dbb24(param_2,*(char **)(param_1 + 4),(char *)0x0);
    }
    if (param_3 != 1) {
      iVar3 = FUN_004d4a78(*(char **)(param_1 + 4));
    }
  }
  pcVar1 = *(char **)(param_1 + 8);
  if (pcVar1 != (char *)0x0) {
    if (param_3 != 0) {
      FUN_004dbb24(param_2,&DAT_004e0be9,(char *)0x0);
      FUN_004dbb24(param_2,pcVar1,(char *)0x0);
    }
    if (param_3 != 1) {
      iVar2 = FUN_004d4a78(*(char **)(param_1 + 8));
      iVar3 = iVar2 + iVar3 + 1;
    }
  }
  if (param_3 == 1) {
    FUN_004d9c38(param_2);
  }
  else if (param_3 != 0) {
    FUN_004d9c58(param_2);
  }
  if (param_3 != 1) {
    iVar3 = iVar3 + 1;
  }
  return iVar3;
}



/* @00405660 file=? name=FUN_00405660 */

undefined4 FUN_00405660(void)

{
  return 1;
}



/* @0040567c file=? name=FUN_0040567c */

void __cdecl FUN_0040567c(undefined4 *param_1,undefined4 param_2)

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



/* @004056ac file=? name=FUN_004056ac */

void __cdecl FUN_004056ac(int *param_1,byte param_2)

{
  int *piVar1;
  
  if (param_1 != (int *)0x0) {
    piVar1 = (int *)param_1[2];
    while (piVar1 != (int *)0x0) {
      param_1[2] = *piVar1;
      FUN_00405454(piVar1,3);
      piVar1 = (int *)param_1[2];
    }
    if ((int *)param_1[6] != (int *)0x0) {
      FUN_004022d0((int *)param_1[6]);
    }
    if ((int *)param_1[7] != (int *)0x0) {
      FUN_004022d0((int *)param_1[7]);
    }
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00405704 file=? name=FUN_00405704 */

void __cdecl FUN_00405704(int param_1,char *param_2,int *param_3)

{
  char *pcVar1;
  char cVar2;
  int iVar3;
  char *pcVar4;
  undefined4 uVar5;
  uint uVar6;
  uint uVar7;
  char *pcVar8;
  bool bVar9;
  
  if (*(int *)(param_1 + 0x18) != 0) {
    if (*(int *)(param_1 + 0x20) != 0) {
      *(undefined4 *)(param_1 + 0x20) = 0;
      *param_3 = *param_3 + -1;
    }
    FUN_004022d0(*(int **)(param_1 + 0x18));
  }
  if (param_2 == (char *)0x0) {
    *(undefined4 *)(param_1 + 0x18) = 0;
    return;
  }
  iVar3 = FUN_004d4a78(param_2);
  pcVar4 = (char *)FUN_004022b0(iVar3 + 1);
  *(char **)(param_1 + 0x18) = pcVar4;
  uVar6 = 0xffffffff;
  do {
    pcVar8 = param_2;
    if (uVar6 == 0) break;
    uVar6 = uVar6 - 1;
    pcVar8 = param_2 + 1;
    cVar2 = *param_2;
    param_2 = pcVar8;
  } while (cVar2 != '\0');
  uVar6 = ~uVar6;
  pcVar8 = pcVar8 + -uVar6;
  for (uVar7 = uVar6 >> 2; uVar7 != 0; uVar7 = uVar7 - 1) {
    *(undefined4 *)pcVar4 = *(undefined4 *)pcVar8;
    pcVar8 = pcVar8 + 4;
    pcVar4 = pcVar4 + 4;
  }
  for (uVar6 = uVar6 & 3; uVar6 != 0; uVar6 = uVar6 - 1) {
    *pcVar4 = *pcVar8;
    pcVar8 = pcVar8 + 1;
    pcVar4 = pcVar4 + 1;
  }
  pcVar4 = *(char **)(param_1 + 0x18);
  if ((*pcVar4 != '\0') && (**(char **)(param_1 + 0x18) != '!')) {
    pcVar8 = s_LAB_ONLY_004e0beb;
    do {
      if (*pcVar4 != *pcVar8) goto LAB_004057b2;
      bVar9 = true;
      if (*pcVar4 == '\0') break;
      pcVar1 = pcVar4 + 1;
      if (*pcVar1 != pcVar8[1]) goto LAB_004057b2;
      pcVar4 = pcVar4 + 2;
      pcVar8 = pcVar8 + 2;
      bVar9 = *pcVar1 == '\0';
    } while (!bVar9);
    if (!bVar9) {
LAB_004057b2:
      uVar5 = 1;
      goto LAB_004057b7;
    }
  }
  uVar5 = 0;
LAB_004057b7:
  *(undefined4 *)(param_1 + 0x20) = uVar5;
  return;
}



/* @004057c8 file=? name=FUN_004057c8 */

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

{
  char cVar1;
  int iVar2;
  char *pcVar3;
  uint uVar4;
  uint uVar5;
  char *pcVar6;
  char *pcVar7;
  
  if (*(int **)(param_1 + 0x1c) != (int *)0x0) {
    FUN_004022d0(*(int **)(param_1 + 0x1c));
  }
  if ((param_2 == (char *)0x0) || (*param_2 == '\0')) {
    pcVar3 = (char *)0x0;
    *(undefined4 *)(param_1 + 0x1c) = 0;
  }
  else {
    iVar2 = FUN_004d4a78(param_2);
    pcVar3 = (char *)FUN_004022b0(iVar2 + 1);
    *(char **)(param_1 + 0x1c) = pcVar3;
    uVar4 = 0xffffffff;
    do {
      pcVar6 = param_2;
      if (uVar4 == 0) break;
      uVar4 = uVar4 - 1;
      pcVar6 = param_2 + 1;
      cVar1 = *param_2;
      param_2 = pcVar6;
    } while (cVar1 != '\0');
    uVar4 = ~uVar4;
    pcVar6 = pcVar6 + -uVar4;
    pcVar7 = pcVar3;
    for (uVar5 = uVar4 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {
      *(undefined4 *)pcVar7 = *(undefined4 *)pcVar6;
      pcVar6 = pcVar6 + 4;
      pcVar7 = pcVar7 + 4;
    }
    for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
      *pcVar7 = *pcVar6;
      pcVar6 = pcVar6 + 1;
      pcVar7 = pcVar7 + 1;
    }
  }
  return pcVar3;
}



/* @00405834 file=? name=FUN_00405834 */

void __cdecl FUN_00405834(int param_1,undefined4 *param_2)

{
  if (*(int *)(param_1 + 0xc) == 0) {
    *(undefined4 **)(param_1 + 8) = param_2;
  }
  else {
    **(undefined4 **)(param_1 + 0xc) = param_2;
  }
  *(undefined4 **)(param_1 + 0xc) = param_2;
  *param_2 = 0;
  if (param_2[3] != 0) {
    *(int *)(param_1 + 0x14) = *(int *)(param_1 + 0x14) + 1;
  }
  *(int *)(param_1 + 0x10) = *(int *)(param_1 + 0x10) + 1;
  return;
}



/* @00405868 file=? name=FUN_00405868 */

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

{
  undefined4 local_8;
  
  FUN_00405888(param_1,param_2,param_3,&local_8);
  return;
}



/* @00405888 file=? name=FUN_00405888 */

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

{
  char *pcVar1;
  undefined4 *puVar2;
  undefined4 *puVar3;
  int iVar4;
  char *pcVar5;
  char *pcVar6;
  bool bVar7;
  undefined4 *local_8;
  
  local_8 = (undefined4 *)0x0;
  puVar3 = (undefined4 *)param_1[2];
  do {
    puVar2 = puVar3;
    if (puVar2 == (undefined4 *)0x0) {
      *param_4 = 0;
      *param_3 = 0;
      return 0;
    }
    if (puVar2[1] != 0) {
      if (((*(byte *)(*param_1 + 0x1c) & 0x10) != 0) &&
         (iVar4 = FUN_004d4b58((char *)puVar2[1],param_2), iVar4 == 0)) {
LAB_004058ec:
        *param_3 = puVar2;
        *param_4 = local_8;
        return 1;
      }
      if ((*(byte *)(*param_1 + 0x1c) & 0x10) == 0) {
        pcVar5 = (char *)puVar2[1];
        pcVar6 = param_2;
        do {
          if (*pcVar5 != *pcVar6) goto LAB_00405900;
          bVar7 = true;
          if (*pcVar5 == '\0') break;
          pcVar1 = pcVar5 + 1;
          if (*pcVar1 != pcVar6[1]) goto LAB_00405900;
          pcVar5 = pcVar5 + 2;
          pcVar6 = pcVar6 + 2;
          bVar7 = *pcVar1 == '\0';
        } while (!bVar7);
        if (bVar7) goto LAB_004058ec;
      }
    }
LAB_00405900:
    puVar3 = (undefined4 *)*puVar2;
    local_8 = puVar2;
  } while( true );
}



/* @00405920 file=? name=FUN_00405920 */

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

{
  int iVar1;
  undefined4 *local_c;
  int *local_8;
  
  iVar1 = FUN_00405888(param_1,(char *)param_2[1],&local_8,&local_c);
  if (iVar1 == 0) {
    FUN_00405834((int)param_1,param_2);
  }
  else {
    if (local_c == (undefined4 *)0x0) {
      param_1[2] = (int)param_2;
    }
    else {
      *local_c = param_2;
    }
    iVar1 = *local_8;
    *param_2 = iVar1;
    if (iVar1 == 0) {
      param_1[3] = (int)param_2;
    }
    FUN_00405454(local_8,3);
  }
  return;
}



/* @00405988 file=? name=FUN_00405988 */

void __cdecl FUN_00405988(int *param_1,char *param_2)

{
  int iVar1;
  int *local_c;
  int *local_8;
  
  iVar1 = FUN_00405888(param_1,param_2,&local_8,&local_c);
  if (iVar1 != 0) {
    if (local_c == (int *)0x0) {
      param_1[2] = *local_8;
    }
    else {
      *local_c = *local_8;
    }
    if ((int *)param_1[3] == local_8) {
      param_1[3] = (int)local_c;
    }
    if (local_8[3] != 0) {
      param_1[5] = param_1[5] + -1;
    }
    param_1[4] = param_1[4] + -1;
    FUN_00405454(local_8,3);
  }
  return;
}



/* @004059fc file=? name=FUN_004059fc */

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

{
  undefined4 *puVar1;
  char *pcVar2;
  int iVar3;
  int iVar4;
  
  puVar1 = *(undefined4 **)(param_1 + 8);
  iVar4 = 0;
  pcVar2 = *(char **)(param_1 + 0x18);
  if (pcVar2 != (char *)0x0) {
    if (param_3 != 0) {
      FUN_004dbb24(param_2,&DAT_004e0bf4,(char *)0x0);
      FUN_004dbb24(param_2,pcVar2,(char *)0x0);
      FUN_004dbb24(param_2,&DAT_004e0bf6,(char *)0x0);
    }
    if (param_3 != 1) {
      iVar4 = FUN_004d4a78(*(char **)(param_1 + 0x18));
      iVar4 = iVar4 + 2;
    }
  }
  if (*(char **)(param_1 + 0x1c) != (char *)0x0) {
    if (param_3 != 0) {
      FUN_004dbb24(param_2,*(char **)(param_1 + 0x1c),(char *)0x0);
    }
    if (param_3 != 1) {
      iVar3 = FUN_004d4a78(*(char **)(param_1 + 0x1c));
      iVar4 = iVar3 + iVar4;
    }
  }
  if ((*(int *)(param_1 + 0x18) != 0) || (*(int *)(param_1 + 0x1c) != 0)) {
    if (param_3 == 1) {
      FUN_004d9c38(param_2);
    }
    else if (param_3 != 0) {
      FUN_004d9c58(param_2);
    }
    if (param_3 != 1) {
      iVar4 = iVar4 + 1;
    }
  }
  for (; puVar1 != (undefined4 *)0x0; puVar1 = (undefined4 *)*puVar1) {
    iVar3 = FUN_004055b0((int)puVar1,param_2,param_3);
    iVar4 = iVar4 + iVar3;
  }
  return iVar4;
}



/* @00405b00 file=? name=FUN_00405b00 */

undefined4 FUN_00405b00(void)

{
  return 1;
}



/* @00405f44 file=? name=FUN_00405f44 */

void __cdecl FUN_00405f44(undefined4 param_1)

{
  DAT_004e0c18 = param_1;
  return;
}



/* @00406018 file=? name=FUN_00406018 */

undefined4 * __cdecl FUN_00406018(char *param_1,char *param_2,char *param_3)

{
  char cVar1;
  int iVar2;
  char *pcVar3;
  int iVar4;
  int iVar5;
  uint uVar6;
  uint uVar7;
  char *pcVar8;
  
  if (param_1 == (char *)0x0) {
    param_1 = &DAT_004e0c88;
  }
  iVar2 = FUN_004d4a78(param_1);
  if (param_3 == (char *)0x0) {
    pcVar3 = FUN_004061e8(param_2);
    iVar5 = FUN_004d4a78(pcVar3);
    iVar5 = iVar5 + iVar2;
  }
  else {
    pcVar3 = FUN_004061e8(param_2);
    pcVar3 = (char *)FUN_00406224(pcVar3);
    iVar4 = FUN_004d4a78(pcVar3);
    cVar1 = *param_3;
    iVar5 = FUN_004d4a78(param_3);
    iVar5 = iVar5 + iVar4 + iVar2 + (uint)(cVar1 != '.');
  }
  if (0x1ff < iVar5) {
    FUN_004dbb24(&DAT_00524e20,s___Program_Error___buffer___too_s_004e0c8a,(char *)0x0);
    FUN_004036a0(1);
  }
  uVar6 = 0xffffffff;
  do {
    pcVar3 = param_1;
    if (uVar6 == 0) break;
    uVar6 = uVar6 - 1;
    pcVar3 = param_1 + 1;
    cVar1 = *param_1;
    param_1 = pcVar3;
  } while (cVar1 != '\0');
  uVar6 = ~uVar6;
  pcVar3 = pcVar3 + -uVar6;
  pcVar8 = (char *)&DAT_005214f4;
  for (uVar7 = uVar6 >> 2; uVar7 != 0; uVar7 = uVar7 - 1) {
    *(undefined4 *)pcVar8 = *(undefined4 *)pcVar3;
    pcVar3 = pcVar3 + 4;
    pcVar8 = pcVar8 + 4;
  }
  for (uVar6 = uVar6 & 3; uVar6 != 0; uVar6 = uVar6 - 1) {
    *pcVar8 = *pcVar3;
    pcVar3 = pcVar3 + 1;
    pcVar8 = pcVar8 + 1;
  }
  if (param_3 == (char *)0x0) {
    pcVar3 = FUN_004061e8(param_2);
    FUN_004d49b8((char *)&DAT_005214f4,pcVar3);
  }
  else {
    pcVar3 = FUN_004061e8(param_2);
    pcVar3 = (char *)FUN_00406224(pcVar3);
    FUN_004d49b8((char *)&DAT_005214f4,pcVar3);
    if (*param_3 != '.') {
      FUN_004d49b8((char *)&DAT_005214f4,&DAT_004e0ccd);
    }
    FUN_004d49b8((char *)&DAT_005214f4,param_3);
  }
  return &DAT_005214f4;
}



/* @00406140 file=? name=FUN_00406140 */

void __cdecl FUN_00406140(char *param_1,char *param_2)

{
  FUN_00406018(DAT_004e0c00,param_1,param_2);
  return;
}



/* @0040615c file=? name=FUN_0040615c */

void __cdecl FUN_0040615c(char *param_1,char *param_2)

{
  FUN_00406018(DAT_004e0c04,param_1,param_2);
  return;
}



/* @00406178 file=? name=FUN_00406178 */

void __cdecl FUN_00406178(char *param_1,char *param_2)

{
  FUN_00406018(DAT_004e0c08,param_1,param_2);
  return;
}



/* @00406194 file=? name=FUN_00406194 */

void __cdecl FUN_00406194(char *param_1,char *param_2)

{
  FUN_00406018(DAT_004e0c0c,param_1,param_2);
  return;
}



/* @004061b0 file=? name=FUN_004061b0 */

void __cdecl FUN_004061b0(char *param_1,char *param_2)

{
  FUN_00406018(DAT_004e0c10,param_1,param_2);
  return;
}



/* @004061cc file=? name=FUN_004061cc */

void __cdecl FUN_004061cc(char *param_1,char *param_2)

{
  FUN_00406018(DAT_004e0c18,param_1,param_2);
  return;
}



/* @004061e8 file=? name=FUN_004061e8 */

char * __cdecl FUN_004061e8(char *param_1)

{
  int iVar1;
  char *pcVar2;
  
  iVar1 = FUN_004064bc(param_1);
  pcVar2 = param_1;
  if (iVar1 != 0) {
    for (pcVar2 = FUN_004d49f4(param_1,'\0'); (*pcVar2 != '\\' && (param_1 != pcVar2));
        pcVar2 = pcVar2 + -1) {
    }
    if (*pcVar2 == '\\') {
      pcVar2 = pcVar2 + 1;
    }
  }
  return pcVar2;
}



/* @00406224 file=? name=FUN_00406224 */

undefined4 * __cdecl FUN_00406224(char *param_1)

{
  char cVar1;
  uint uVar2;
  char *pcVar3;
  uint uVar4;
  char *pcVar5;
  
  uVar2 = FUN_004d4a78(param_1);
  if (0x1ff < uVar2) {
    FUN_004dbb24(&DAT_00524e20,s___Program_Error___buffer___too_s_004e0ccf,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    FUN_004036a0(1);
  }
  uVar2 = 0xffffffff;
  do {
    pcVar3 = param_1;
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    pcVar3 = param_1 + 1;
    cVar1 = *param_1;
    param_1 = pcVar3;
  } while (cVar1 != '\0');
  uVar2 = ~uVar2;
  pcVar3 = pcVar3 + -uVar2;
  pcVar5 = (char *)&DAT_005216f4;
  for (uVar4 = uVar2 >> 2; uVar4 != 0; uVar4 = uVar4 - 1) {
    *(undefined4 *)pcVar5 = *(undefined4 *)pcVar3;
    pcVar3 = pcVar3 + 4;
    pcVar5 = pcVar5 + 4;
  }
  for (uVar2 = uVar2 & 3; uVar2 != 0; uVar2 = uVar2 - 1) {
    *pcVar5 = *pcVar3;
    pcVar3 = pcVar3 + 1;
    pcVar5 = pcVar5 + 1;
  }
  for (pcVar3 = FUN_004d49f4((char *)&DAT_005216f4,'\0');
      (*pcVar3 != '.' && (pcVar3 != (char *)&DAT_005216f4)); pcVar3 = pcVar3 + -1) {
  }
  if (*pcVar3 == '.') {
    *pcVar3 = '\0';
  }
  return &DAT_005216f4;
}



/* @004062bc file=? name=FUN_004062bc */

undefined * __cdecl FUN_004062bc(int param_1)

{
  DAT_005218f4 = 0;
  if (0x3f < param_1) {
    param_1 = 0x3f;
  }
  for (; 0 < param_1; param_1 = param_1 + -1) {
    FUN_004d49b8(&DAT_005218f4,&DAT_004e0d0a);
  }
  return &DAT_005218f4;
}



/* @004062f8 file=? name=FUN_004062f8 */

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

{
  int *piVar1;
  undefined4 uVar2;
  int iVar3;
  char *pcVar4;
  char *pcVar5;
  
  piVar1 = FUN_004dad10(param_1,param_2,param_3,10);
  iVar3 = *piVar1;
  if ((*(byte *)(iVar3 + 0xc) & 0x86) != 0) {
    iVar3 = 0;
  }
  if (iVar3 == 0) {
    *param_2 = '\0';
    uVar2 = 0;
  }
  else {
    while (iVar3 = FUN_004d4a78(param_2), iVar3 <= param_3 + -2) {
      pcVar5 = param_2 + iVar3;
      do {
        pcVar4 = pcVar5;
        pcVar5 = pcVar4 + -1;
        if (pcVar4 <= param_2) break;
      } while (((&DAT_005207dd)[*pcVar5] & 1) != 0);
      if ((pcVar5 < param_2) || (*pcVar5 != '\\')) goto LAB_004063cc;
      piVar1 = FUN_004dad10(param_1,&DAT_00521974,0x200,10);
      iVar3 = *piVar1;
      if ((*(byte *)(iVar3 + 0xc) & 0x86) != 0) {
        iVar3 = 0;
      }
      if (iVar3 == 0) goto LAB_004063cc;
      *pcVar5 = ' ';
      FUN_004d4a94(pcVar4,&DAT_00521974,param_3 - ((int)pcVar4 - (int)param_2));
    }
    FUN_004dbb24(&DAT_00524e20,s___ERROR___Input_line_too_long__004e0d0d,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
LAB_004063cc:
    uVar2 = 1;
  }
  return uVar2;
}



/* @004063e0 file=? name=FUN_004063e0 */

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

float10 __cdecl FUN_004063e0(float param_1)

{
  return (float10)param_1 * (float10)_DAT_004063f0;
}



/* @004064bc file=? name=FUN_004064bc */

undefined4 __cdecl FUN_004064bc(char *param_1)

{
  char *pcVar1;
  
  pcVar1 = FUN_004d49f4(param_1,'/');
  if (((pcVar1 == (char *)0x0) && (pcVar1 = FUN_004d49f4(param_1,':'), pcVar1 == (char *)0x0)) &&
     (pcVar1 = FUN_004d49f4(param_1,'\\'), pcVar1 == (char *)0x0)) {
    return 0;
  }
  return 1;
}



/* @004064fc file=? name=FUN_004064fc */

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

{
  char cVar1;
  int iVar2;
  char *pcVar3;
  int iVar4;
  uint uVar5;
  uint uVar6;
  char *pcVar7;
  char *pcVar8;
  
  iVar2 = FUN_004064bc(param_2);
  if (iVar2 == 0) {
    if (param_1 == (char *)0x0) {
      iVar2 = FUN_004d4a78(param_2);
      pcVar3 = (char *)FUN_004022b0(iVar2 + 1);
      uVar5 = 0xffffffff;
      do {
        pcVar7 = param_2;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar7 = param_2 + 1;
        cVar1 = *param_2;
        param_2 = pcVar7;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar7 = pcVar7 + -uVar5;
      pcVar8 = pcVar3;
      for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
        pcVar7 = pcVar7 + 4;
        pcVar8 = pcVar8 + 4;
      }
      for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar8 = *pcVar7;
        pcVar7 = pcVar7 + 1;
        pcVar8 = pcVar8 + 1;
      }
    }
    else {
      iVar2 = FUN_004d4a78(param_1);
      iVar4 = FUN_004d4a78(param_2);
      pcVar3 = (char *)FUN_004022b0(iVar2 + iVar4 + 1);
      uVar5 = 0xffffffff;
      do {
        pcVar7 = param_1;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar7 = param_1 + 1;
        cVar1 = *param_1;
        param_1 = pcVar7;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar7 = pcVar7 + -uVar5;
      pcVar8 = pcVar3;
      for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
        pcVar7 = pcVar7 + 4;
        pcVar8 = pcVar8 + 4;
      }
      for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar8 = *pcVar7;
        pcVar7 = pcVar7 + 1;
        pcVar8 = pcVar8 + 1;
      }
      FUN_004d49b8(pcVar3,param_2);
    }
  }
  else {
    iVar2 = FUN_004d4a78(param_2);
    pcVar3 = (char *)FUN_004022b0(iVar2 + 1);
    uVar5 = 0xffffffff;
    do {
      pcVar7 = param_2;
      if (uVar5 == 0) break;
      uVar5 = uVar5 - 1;
      pcVar7 = param_2 + 1;
      cVar1 = *param_2;
      param_2 = pcVar7;
    } while (cVar1 != '\0');
    uVar5 = ~uVar5;
    pcVar7 = pcVar7 + -uVar5;
    pcVar8 = pcVar3;
    for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
      *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
      pcVar7 = pcVar7 + 4;
      pcVar8 = pcVar8 + 4;
    }
    for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
      *pcVar8 = *pcVar7;
      pcVar7 = pcVar7 + 1;
      pcVar8 = pcVar8 + 1;
    }
  }
  return pcVar3;
}



/* @004065d8 file=? name=FUN_004065d8 */

void __cdecl FUN_004065d8(int *param_1,char *param_2,char *param_3)

{
  char cVar1;
  int iVar2;
  int *piVar3;
  int iVar4;
  uint uVar5;
  uint uVar6;
  int *piVar7;
  char *pcVar8;
  int *piVar9;
  
  iVar2 = FUN_004064bc(param_3);
  if ((iVar2 == 0) && (param_2 != (char *)0x0)) {
    iVar2 = FUN_004d4a78(param_2);
    iVar4 = FUN_004d4a78(param_3);
    piVar3 = (int *)FUN_004022b0(iVar2 + iVar4 + 1);
    uVar5 = 0xffffffff;
    do {
      pcVar8 = param_2;
      if (uVar5 == 0) break;
      uVar5 = uVar5 - 1;
      pcVar8 = param_2 + 1;
      cVar1 = *param_2;
      param_2 = pcVar8;
    } while (cVar1 != '\0');
    uVar5 = ~uVar5;
    piVar7 = (int *)(pcVar8 + -uVar5);
    piVar9 = piVar3;
    for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
      *piVar9 = *piVar7;
      piVar7 = piVar7 + 1;
      piVar9 = piVar9 + 1;
    }
    for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
      *(char *)piVar9 = (char)*piVar7;
      piVar7 = (int *)((int)piVar7 + 1);
      piVar9 = (int *)((int)piVar9 + 1);
    }
    FUN_004d49b8((char *)piVar3,param_3);
  }
  else {
    iVar2 = FUN_004d4a78(param_3);
    piVar3 = (int *)FUN_004022b0(iVar2 + 1);
    uVar5 = 0xffffffff;
    do {
      pcVar8 = param_3;
      if (uVar5 == 0) break;
      uVar5 = uVar5 - 1;
      pcVar8 = param_3 + 1;
      cVar1 = *param_3;
      param_3 = pcVar8;
    } while (cVar1 != '\0');
    uVar5 = ~uVar5;
    piVar7 = (int *)(pcVar8 + -uVar5);
    piVar9 = piVar3;
    for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
      *piVar9 = *piVar7;
      piVar7 = piVar7 + 1;
      piVar9 = piVar9 + 1;
    }
    for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
      *(char *)piVar9 = (char)*piVar7;
      piVar7 = (int *)((int)piVar7 + 1);
      piVar9 = (int *)((int)piVar9 + 1);
    }
  }
  FUN_004da5f8(param_1,(LPCSTR)piVar3,2,DAT_00520540);
  FUN_004022d0(piVar3);
  return;
}



/* @00406698 file=? name=FUN_00406698 */

void __cdecl FUN_00406698(int *param_1,char *param_2,char *param_3)

{
  char cVar1;
  int iVar2;
  uint uVar3;
  uint uVar4;
  char *pcVar5;
  char *pcVar6;
  char local_68 [100];
  
  iVar2 = FUN_004064bc(param_3);
  if (iVar2 == 0) {
    if (param_2 == (char *)0x0) {
      uVar3 = 0xffffffff;
      do {
        pcVar5 = param_3;
        if (uVar3 == 0) break;
        uVar3 = uVar3 - 1;
        pcVar5 = param_3 + 1;
        cVar1 = *param_3;
        param_3 = pcVar5;
      } while (cVar1 != '\0');
      uVar3 = ~uVar3;
      pcVar5 = pcVar5 + -uVar3;
      pcVar6 = local_68;
      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;
      }
    }
    else {
      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_68;
      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_68,param_3);
    }
  }
  else {
    uVar3 = 0xffffffff;
    do {
      pcVar5 = param_3;
      if (uVar3 == 0) break;
      uVar3 = uVar3 - 1;
      pcVar5 = param_3 + 1;
      cVar1 = *param_3;
      param_3 = pcVar5;
    } while (cVar1 != '\0');
    uVar3 = ~uVar3;
    pcVar5 = pcVar5 + -uVar3;
    pcVar6 = local_68;
    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_004da5f8(param_1,local_68,1,DAT_00520540);
  return;
}



/* @00406750 file=? name=FUN_00406750 */

undefined4 __cdecl FUN_00406750(int param_1)

{
  int iVar1;
  
  iVar1 = FUN_00403f84(param_1,s_LAB_ONLY_004e0d2f);
  if (iVar1 != 0) {
    FUN_004dbb24(&DAT_00524e20,s_WARNING__LAB_ONLY_004e0d38,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    return 1;
  }
  return 0;
}



/* @00406794 file=? name=FUN_00406794 */

void __cdecl FUN_00406794(int param_1)

{
  int iVar1;
  
  iVar1 = FUN_00403f84(param_1,s_LAB_ONLY_004e0d4a);
  if (iVar1 == 0) {
    FUN_00404528(param_1,s_LAB_ONLY_004e0d53,(char *)0x0,0);
  }
  return;
}



/* @004067c4 file=? name=FUN_004067c4 */

uint __cdecl FUN_004067c4(undefined4 *param_1)

{
  uint uVar1;
  int local_94 [36];
  
  FUN_004da66c(local_94,0,(LPCSTR)*param_1,1,DAT_00520540);
  if ((*(byte *)(local_94[0] + 0xc) & 0x86) != 0) {
    local_94[0] = 0;
  }
  uVar1 = (uint)(local_94[0] != 0);
  FUN_004da754(local_94,2);
  return uVar1;
}



/* @00406824 file=? name=FUN_00406824 */

void __cdecl FUN_00406824(char *param_1,float *param_2)

{
  uint *puVar1;
  float10 fVar2;
  uint local_44 [2];
  char *local_3c;
  uint local_34 [2];
  char *local_2c;
  uint local_24 [2];
  char *local_1c;
  uint *local_14;
  uint *local_10;
  uint *local_c;
  uint *local_8;
  
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_8 = (uint *)0x0;
  }
  else {
    local_8 = FUN_00402460(puVar1,param_1);
  }
  local_8[3] = local_8[3] + 1;
  FUN_00402838(local_24,local_8,0,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_c = (uint *)0x0;
  }
  else {
    local_c = FUN_00402460(puVar1,local_1c);
  }
  local_c[3] = local_c[3] + 1;
  FUN_004024d8((int *)local_24,2);
  fVar2 = (float10)FUN_004dd1cc(local_c[2]);
  *param_2 = (float)fVar2;
  puVar1 = local_c + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_c,3);
  }
  FUN_00402838(local_34,local_8,1,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_10 = (uint *)0x0;
  }
  else {
    local_10 = FUN_00402460(puVar1,local_2c);
  }
  local_10[3] = local_10[3] + 1;
  FUN_004024d8((int *)local_34,2);
  fVar2 = (float10)FUN_004dd1cc(local_10[2]);
  param_2[1] = (float)fVar2;
  puVar1 = local_10 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_10,3);
  }
  FUN_00402838(local_44,local_8,2,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_14 = (uint *)0x0;
  }
  else {
    local_14 = FUN_00402460(puVar1,local_3c);
  }
  local_14[3] = local_14[3] + 1;
  FUN_004024d8((int *)local_44,2);
  fVar2 = (float10)FUN_004dd1cc(local_14[2]);
  param_2[2] = (float)fVar2;
  puVar1 = local_14 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_14,3);
  }
  puVar1 = local_8 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_8,3);
  }
  return;
}



/* @004069b8 file=? name=FUN_004069b8 */

undefined4 FUN_004069b8(void)

{
  return 1;
}



/* @004069c4 file=? name=FUN_004069c4 */

void __cdecl FUN_004069c4(char *param_1,float *param_2)

{
  uint *puVar1;
  float10 fVar2;
  uint local_58 [2];
  char *local_50;
  uint local_48 [2];
  char *local_40;
  uint local_38 [2];
  char *local_30;
  uint local_28 [2];
  char *local_20;
  uint *local_18;
  uint *local_14;
  uint *local_10;
  uint *local_c;
  uint *local_8;
  
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_8 = (uint *)0x0;
  }
  else {
    local_8 = FUN_00402460(puVar1,param_1);
  }
  local_8[3] = local_8[3] + 1;
  FUN_00402838(local_28,local_8,0,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_c = (uint *)0x0;
  }
  else {
    local_c = FUN_00402460(puVar1,local_20);
  }
  local_c[3] = local_c[3] + 1;
  FUN_004024d8((int *)local_28,2);
  fVar2 = (float10)FUN_004dd1cc(local_c[2]);
  *param_2 = (float)fVar2;
  puVar1 = local_c + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_c,3);
  }
  FUN_00402838(local_38,local_8,1,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_10 = (uint *)0x0;
  }
  else {
    local_10 = FUN_00402460(puVar1,local_30);
  }
  local_10[3] = local_10[3] + 1;
  FUN_004024d8((int *)local_38,2);
  fVar2 = (float10)FUN_004dd1cc(local_10[2]);
  param_2[1] = (float)fVar2;
  puVar1 = local_10 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_10,3);
  }
  FUN_00402838(local_48,local_8,2,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_14 = (uint *)0x0;
  }
  else {
    local_14 = FUN_00402460(puVar1,local_40);
  }
  local_14[3] = local_14[3] + 1;
  FUN_004024d8((int *)local_48,2);
  fVar2 = (float10)FUN_004dd1cc(local_14[2]);
  param_2[2] = (float)fVar2;
  puVar1 = local_14 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_14,3);
  }
  FUN_00402838(local_58,local_8,3,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_18 = (uint *)0x0;
  }
  else {
    local_18 = FUN_00402460(puVar1,local_50);
  }
  local_18[3] = local_18[3] + 1;
  FUN_004024d8((int *)local_58,2);
  fVar2 = (float10)FUN_004dd1cc(local_18[2]);
  param_2[3] = (float)fVar2;
  puVar1 = local_18 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_18,3);
  }
  puVar1 = local_8 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_8,3);
  }
  return;
}



/* @00406bc8 file=? name=FUN_00406bc8 */

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

{
  char cVar1;
  int iVar2;
  undefined4 *puVar3;
  uint uVar4;
  uint uVar5;
  undefined1 *puVar6;
  char *pcVar7;
  char *pcVar8;
  
  param_1[0xe] = param_2;
  *param_1 = param_9;
  param_1[2] = param_4;
  uVar4 = 0xffffffff;
  do {
    pcVar7 = param_3;
    if (uVar4 == 0) break;
    uVar4 = uVar4 - 1;
    pcVar7 = param_3 + 1;
    cVar1 = *param_3;
    param_3 = pcVar7;
  } while (cVar1 != '\0');
  uVar4 = ~uVar4;
  pcVar7 = pcVar7 + -uVar4;
  pcVar8 = (char *)(param_1 + 3);
  for (uVar5 = uVar4 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {
    *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
    pcVar7 = pcVar7 + 4;
    pcVar8 = pcVar8 + 4;
  }
  for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
    *pcVar8 = *pcVar7;
    pcVar7 = pcVar7 + 1;
    pcVar8 = pcVar8 + 1;
  }
  iVar2 = FUN_004d4a78((char *)(param_1 + 3));
  puVar6 = (undefined1 *)((int)param_1 + iVar2 + 0xd);
  while (iVar2 = iVar2 + 1, iVar2 < 0x20) {
    *puVar6 = 0;
    puVar6 = puVar6 + 1;
  }
  param_1[0xb] = param_5;
  param_1[0xc] = param_6;
  param_1[0xd] = 0;
  param_1[0x10] = param_8;
  param_1[0xf] = 0;
  param_1[1] = 0;
  if (param_7 != (undefined4 *)0x0) {
    puVar3 = (undefined4 *)FUN_004022b0(param_1[0x10]);
    param_1[0xf] = puVar3;
    FUN_004d4918(puVar3,param_7,param_1[0x10]);
    param_1[0xc] = param_1[0xc] | 1;
  }
  return param_1;
}



/* @00406c78 file=? name=FUN_00406c78 */

void __cdecl FUN_00406c78(int *param_1,byte param_2)

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



/* @00406ca4 file=? name=FUN_00406ca4 */

void __cdecl FUN_00406ca4(int param_1)

{
  if ((*(int *)(param_1 + 4) < 1) && ((*(byte *)(param_1 + 0x30) & 1) != 0)) {
    *(uint *)(param_1 + 0x30) = *(uint *)(param_1 + 0x30) & 0xfffffffe;
    FUN_004022e8(*(int **)(param_1 + 0x3c));
    *(undefined4 *)(param_1 + 0x3c) = 0;
  }
  return;
}



/* @00406cd0 file=? name=FUN_00406cd0 */

void __cdecl FUN_00406cd0(int param_1)

{
  if ((*(byte *)(param_1 + 0x30) & 1) == 0) {
    (**(code **)**(undefined4 **)(param_1 + 0x38))(*(undefined4 **)(param_1 + 0x38),param_1);
  }
  return;
}



/* @00406cec file=? name=FUN_00406cec */

undefined4 FUN_00406cec(void)

{
  return 1;
}



/* @00406cf8 file=? name=FUN_00406cf8 */

void __cdecl FUN_00406cf8(undefined4 *param_1)

{
  *param_1 = &PTR_FUN_004e0e78;
  param_1[2] = 0;
  param_1[3] = 0;
  param_1[4] = 0;
  param_1[5] = 0xffffffff;
  param_1[6] = 0xffffffff;
  *(undefined1 *)(param_1 + 1) = 1;
  *(undefined1 *)((int)param_1 + 5) = 0;
  *(undefined1 *)((int)param_1 + 6) = 0;
  *(undefined1 *)((int)param_1 + 7) = 0;
  return;
}



/* @00406d34 file=? name=FUN_00406d34 */

void __cdecl FUN_00406d34(int *param_1,byte param_2)

{
  int *piVar1;
  int iVar2;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004e0e78;
    if (param_1[3] != 0) {
      for (iVar2 = param_1[6]; -1 < iVar2; iVar2 = iVar2 + -1) {
        piVar1 = *(int **)(param_1[3] + iVar2 * 4);
        if (piVar1 != (int *)0x0) {
          FUN_00406c78(piVar1,3);
        }
      }
      FUN_004022e8((int *)param_1[3]);
    }
    *(undefined1 *)(param_1 + 1) = 1;
    *(undefined1 *)((int)param_1 + 5) = 0;
    *(undefined1 *)((int)param_1 + 6) = 0;
    *(undefined1 *)((int)param_1 + 7) = 0;
    param_1[2] = 0;
    param_1[4] = 0;
    param_1[6] = -1;
    param_1[3] = 0;
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00406db4 file=? name=FUN_00406db4 */

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

{
  int *piVar1;
  undefined4 uVar2;
  undefined4 *puVar3;
  undefined4 *puVar4;
  int iVar5;
  
  if ((param_8 == -1) && (param_8 = *(int *)(param_1 + 0x14) + 1, *(int *)(param_1 + 0xc) != 0)) {
    for (piVar1 = (int *)(*(int *)(param_1 + 0xc) + param_8 * 4);
        (param_8 <= *(int *)(param_1 + 0x10) && (*piVar1 != 0)); piVar1 = piVar1 + 1) {
      param_8 = param_8 + 1;
    }
  }
  if (*(int *)(param_1 + 0xc) == 0) {
    *(int *)(param_1 + 0x10) = param_8 + 0x32;
    uVar2 = FUN_004022b0((param_8 + 0x32) * 4);
    *(undefined4 *)(param_1 + 0xc) = uVar2;
    for (iVar5 = 0; iVar5 < *(int *)(param_1 + 0x10); iVar5 = iVar5 + 1) {
      *(undefined4 *)(*(int *)(param_1 + 0xc) + iVar5 * 4) = 0;
    }
  }
  if (*(int *)(param_1 + 0x10) <= param_8) {
    puVar3 = (undefined4 *)FUN_004022b0((param_8 + 0x32) * 4);
    puVar4 = puVar3;
    for (iVar5 = 0; iVar5 < *(int *)(param_1 + 0x10); iVar5 = iVar5 + 1) {
      *puVar4 = *(undefined4 *)(*(int *)(param_1 + 0xc) + iVar5 * 4);
      puVar4 = puVar4 + 1;
    }
    FUN_004022e8(*(int **)(param_1 + 0xc));
    *(undefined4 **)(param_1 + 0xc) = puVar3;
    *(int *)(param_1 + 0x10) = param_8 + 0x32;
    for (; iVar5 < *(int *)(param_1 + 0x10); iVar5 = iVar5 + 1) {
      *(undefined4 *)(*(int *)(param_1 + 0xc) + iVar5 * 4) = 0;
    }
  }
  if (*(int *)(param_1 + 0x18) < param_8) {
    *(int *)(param_1 + 0x18) = param_8;
  }
  puVar4 = (undefined4 *)FUN_00402298(0x44);
  if (puVar4 == (undefined4 *)0x0) {
    puVar4 = (undefined4 *)0x0;
  }
  else {
    puVar4 = FUN_00406bc8(puVar4,param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8);
  }
  *(undefined4 **)(*(int *)(param_1 + 0xc) + param_8 * 4) = puVar4;
  return *(undefined4 *)(*(int *)(param_1 + 0xc) + param_8 * 4);
}



/* @00406ec4 file=? name=FUN_00406ec4 */

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

{
  int *piVar1;
  undefined4 uVar2;
  int iVar3;
  int *piVar4;
  
  piVar1 = (int *)FUN_004022b0((param_7 + 1) * 4);
  iVar3 = 0;
  piVar4 = piVar1;
  if (0 < param_7) {
    do {
      piVar4 = piVar4 + 1;
      *piVar4 = *param_6;
      iVar3 = iVar3 + 1;
      param_6 = param_6 + 1;
    } while (iVar3 < param_7);
  }
  *piVar1 = param_7;
  uVar2 = FUN_00406db4(param_1,param_2,param_3,param_4,param_5,piVar1,(param_7 + 1) * 4,param_8);
  FUN_004022e8(piVar1);
  return uVar2;
}



/* @00406f3c file=? name=FUN_00406f3c */

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

{
  undefined4 *puVar1;
  int iVar2;
  
  iVar2 = param_6[2] - param_6[1];
  (**(code **)(*param_6 + 0xc))(param_6,0);
  puVar1 = (undefined4 *)(**(code **)*param_6)(param_6);
  FUN_00406db4(param_1,param_2,param_3,param_4,param_5,puVar1,iVar2,param_7);
  return;
}



/* @00406f84 file=? name=FUN_00406f84 */

void __cdecl FUN_00406f84(int param_1,int *param_2)

{
  int iVar1;
  int *piVar2;
  
  if (*param_2 != -1) {
    *(undefined4 *)(*(int *)(param_1 + 0xc) + *param_2 * 4) = 0;
    iVar1 = *(int *)(param_1 + 0x18);
    if (iVar1 == *param_2) {
      for (piVar2 = (int *)(*(int *)(param_1 + 0xc) + iVar1 * 4); (-1 < iVar1 && (*piVar2 == 0));
          piVar2 = piVar2 + -1) {
        iVar1 = iVar1 + -1;
      }
      *(int *)(param_1 + 0x18) = iVar1;
    }
  }
  FUN_00406c78(param_2,3);
  return;
}



/* @00406fd4 file=? name=FUN_00406fd4 */

undefined4 __cdecl FUN_00406fd4(int param_1,int param_2)

{
  if (((-1 < param_2) && (param_2 <= *(int *)(param_1 + 0x18))) && (*(int *)(param_1 + 0xc) != 0)) {
    return *(undefined4 *)(*(int *)(param_1 + 0xc) + param_2 * 4);
  }
  return 0;
}



/* @00406ff8 file=? name=FUN_00406ff8 */

int __cdecl FUN_00406ff8(int param_1,char *param_2,int param_3,int param_4)

{
  char *pcVar1;
  char *pcVar2;
  char *pcVar3;
  int unaff_ESI;
  bool bVar4;
  
LAB_0040704b:
  do {
    do {
      param_4 = param_4 + 1;
      if (*(int *)(param_1 + 0x18) < param_4) goto LAB_00407052;
      unaff_ESI = FUN_00406fd4(param_1,param_4);
    } while ((unaff_ESI == 0) || (param_3 != *(int *)(unaff_ESI + 8)));
    if (param_2 == (char *)0x0) break;
    pcVar3 = (char *)(unaff_ESI + 0xc);
    pcVar2 = param_2;
    do {
      if (*pcVar2 != *pcVar3) goto LAB_0040704b;
      bVar4 = true;
      if (*pcVar2 == '\0') break;
      pcVar1 = pcVar2 + 1;
      if (*pcVar1 != pcVar3[1]) goto LAB_0040704b;
      pcVar2 = pcVar2 + 2;
      pcVar3 = pcVar3 + 2;
      bVar4 = *pcVar1 == '\0';
    } while (!bVar4);
  } while (!bVar4);
LAB_00407052:
  if (*(int *)(param_1 + 0x18) < param_4) {
    unaff_ESI = 0;
  }
  return unaff_ESI;
}



/* @00407064 file=? name=FUN_00407064 */

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

{
  int *piVar1;
  int iVar2;
  int iVar3;
  int *piVar4;
  int iVar5;
  
  iVar2 = FUN_00406fd4(param_1,param_2);
  if (iVar2 != 0) {
    iVar5 = *(int *)(iVar2 + 4);
    *(int *)(iVar2 + 4) = *(int *)(iVar2 + 4) + 1;
    if (iVar5 == 0) {
      FUN_00406cd0(iVar2);
    }
    piVar1 = *(int **)(iVar2 + 0x3c);
    piVar4 = piVar1;
    for (iVar5 = 1; piVar4 = piVar4 + 1, iVar5 <= *piVar1; iVar5 = iVar5 + 1) {
      iVar3 = FUN_00406fd4(param_1,*piVar4);
      if (*(int *)(iVar3 + 8) == param_3) {
        *(int *)(iVar2 + 4) = *(int *)(iVar2 + 4) + -1;
        return iVar3;
      }
    }
    *(int *)(iVar2 + 4) = *(int *)(iVar2 + 4) + -1;
  }
  return 0;
}



/* @004070dc file=? name=FUN_004070dc */

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

{
  char *pcVar1;
  int *piVar2;
  int iVar3;
  int iVar4;
  char *pcVar5;
  char *pcVar6;
  int *piVar7;
  bool bVar8;
  int local_c;
  
  iVar3 = FUN_00406fd4(param_1,param_2);
  if (iVar3 != 0) {
    iVar4 = *(int *)(iVar3 + 4);
    *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + 1;
    if (iVar4 == 0) {
      FUN_00406cd0(iVar3);
    }
    piVar2 = *(int **)(iVar3 + 0x3c);
    piVar7 = piVar2;
    for (local_c = 1; piVar7 = piVar7 + 1, local_c <= *piVar2; local_c = local_c + 1) {
      iVar4 = FUN_00406fd4(param_1,*piVar7);
      pcVar6 = (char *)(iVar4 + 0xc);
      pcVar5 = param_3;
      do {
        if (*pcVar5 != *pcVar6) goto LAB_0040715d;
        bVar8 = true;
        if (*pcVar5 == '\0') break;
        pcVar1 = pcVar5 + 1;
        if (*pcVar1 != pcVar6[1]) goto LAB_0040715d;
        pcVar5 = pcVar5 + 2;
        pcVar6 = pcVar6 + 2;
        bVar8 = *pcVar1 == '\0';
      } while (!bVar8);
      if (bVar8) {
        *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + -1;
        return iVar4;
      }
LAB_0040715d:
    }
    *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + -1;
  }
  return 0;
}



/* @0040717c file=? name=FUN_0040717c */

void __cdecl FUN_0040717c(int param_1)

{
  int iVar1;
  int iVar2;
  
  for (iVar2 = *(int *)(param_1 + 0x18); -1 < iVar2; iVar2 = iVar2 + -1) {
    iVar1 = *(int *)(*(int *)(param_1 + 0xc) + iVar2 * 4);
    if (iVar1 != 0) {
      FUN_00406ca4(iVar1);
    }
  }
  return;
}



/* @004071a8 file=? name=FUN_004071a8 */

undefined4 FUN_004071a8(void)

{
  return 1;
}



/* @004071b4 file=? name=FUN_004071b4 */

undefined4 * __cdecl FUN_004071b4(undefined4 *param_1)

{
  FUN_00406cf8(param_1);
  *param_1 = &PTR_FUN_004e0e74;
  FUN_004034b0(param_1 + 7,(LPCSTR)0x0,0);
  return param_1;
}



/* @004071e0 file=? name=FUN_004071e0 */

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

{
  FUN_00406cf8(param_1);
  *param_1 = &PTR_FUN_004e0e74;
  FUN_004034b0(param_1 + 7,(LPCSTR)0x0,0);
  FUN_00407390((int)param_1,param_2);
  return param_1;
}



/* @00407218 file=? name=FUN_00407218 */

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

{
  byte bVar1;
  byte bVar2;
  byte bVar3;
  byte bVar4;
  int iVar5;
  int *piVar6;
  char *pcVar7;
  byte bVar8;
  byte bVar9;
  byte bVar10;
  
  FUN_00406cf8(param_1);
  *param_1 = &PTR_FUN_004e0e74;
  FUN_004034b0(param_1 + 7,(LPCSTR)0x0,0);
  FUN_00407390((int)param_1,param_2);
  iVar5 = 0;
  pcVar7 = (char *)((int)param_1 + 5);
  if (0 < param_4) {
    do {
      if (*pcVar7 != *param_3) break;
      iVar5 = iVar5 + 1;
      pcVar7 = pcVar7 + 1;
      param_3 = param_3 + 1;
    } while (iVar5 < param_4);
  }
  if (iVar5 < param_4) {
    bVar1 = *(byte *)((int)param_1 + 7);
    bVar10 = 0x2e;
    bVar2 = *(byte *)((int)param_1 + 6);
    bVar9 = 0x2e;
    bVar3 = *(byte *)((int)param_1 + 5);
    bVar8 = 0x2e;
    bVar4 = *(byte *)(param_1 + 1);
    FUN_004dbb24(&DAT_00524e20,s_Error___Resource_file_004e0d5c,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004e0d75,(char *)0x0);
    piVar6 = FUN_004db78c(&DAT_00524e20,(uint)bVar4);
    piVar6 = FUN_004db92c(piVar6,bVar8);
    piVar6 = FUN_004db78c(piVar6,(uint)bVar3);
    piVar6 = FUN_004db92c(piVar6,bVar9);
    piVar6 = FUN_004db78c(piVar6,(uint)bVar2);
    piVar6 = FUN_004db92c(piVar6,bVar10);
    piVar6 = FUN_004db78c(piVar6,(uint)bVar1);
    FUN_004dbb24(piVar6,s_is_obsolete__004e0d78,(char *)0x0);
    FUN_004036a0(1);
  }
  return param_1;
}



/* @00407354 file=? name=FUN_00407354 */

void __cdecl FUN_00407354(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004e0e74;
    param_1[7] = (int)&PTR_FUN_004e09e0;
    FUN_00403564((int)(param_1 + 7));
    FUN_00406d34(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @00407390 file=? name=FUN_00407390 */

undefined4 __cdecl FUN_00407390(int param_1,char *param_2)

{
  char cVar1;
  byte bVar2;
  int iVar3;
  int iVar4;
  int *piVar5;
  int *piVar6;
  char *pcVar7;
  int iVar8;
  undefined4 uVar9;
  uint uVar10;
  uint uVar11;
  CHAR *pCVar12;
  char *pcVar13;
  LPCSTR pCVar14;
  byte bVar15;
  byte bVar16;
  byte bVar17;
  int local_60;
  int local_5c;
  char local_58 [32];
  undefined4 local_38;
  int local_34;
  undefined4 local_30;
  uint local_2c;
  int *local_28;
  int *local_24;
  int local_20;
  char *local_1c;
  uint local_18;
  int *local_14;
  uint local_10;
  int *local_c;
  uint local_8;
  
  uVar10 = 0xffffffff;
  pcVar7 = param_2;
  do {
    pcVar13 = pcVar7;
    if (uVar10 == 0) break;
    uVar10 = uVar10 - 1;
    pcVar13 = pcVar7 + 1;
    cVar1 = *pcVar7;
    pcVar7 = pcVar13;
  } while (cVar1 != '\0');
  uVar10 = ~uVar10;
  pCVar12 = pcVar13 + -uVar10;
  pCVar14 = (LPCSTR)(param_1 + 0x34);
  for (uVar11 = uVar10 >> 2; uVar11 != 0; uVar11 = uVar11 - 1) {
    *(undefined4 *)pCVar14 = *(undefined4 *)pCVar12;
    pCVar12 = pCVar12 + 4;
    pCVar14 = pCVar14 + 4;
  }
  for (uVar10 = uVar10 & 3; uVar10 != 0; uVar10 = uVar10 - 1) {
    *pCVar14 = *pCVar12;
    pCVar12 = pCVar12 + 1;
    pCVar14 = pCVar14 + 1;
  }
  piVar6 = (int *)(param_1 + 0x1c);
  FUN_004034e4((int)piVar6,(LPCSTR)(param_1 + 0x34),0);
  if (*(int *)(param_1 + 0x2c) != -1) {
    *(undefined4 *)(param_1 + 0x18) = 0;
    (**(code **)(*(int *)(param_1 + 0x1c) + 0x1c))(piVar6,param_1 + 4,4);
    if (*(char *)(param_1 + 4) != '\x01') {
      bVar2 = *(byte *)(param_1 + 7);
      bVar17 = 0x2e;
      local_8 = (uint)*(byte *)(param_1 + 6);
      bVar16 = 0x2e;
      local_10 = (uint)*(byte *)(param_1 + 5);
      bVar15 = 0x2e;
      local_18 = (uint)*(byte *)(param_1 + 4);
      local_1c = param_2;
      FUN_004dbb24(&DAT_00524e20,s_Error___Resource_file_004e0d88,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_1c,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,&DAT_004e0da1,(char *)0x0);
      piVar5 = FUN_004db78c(&DAT_00524e20,local_18);
      local_14 = FUN_004db92c(piVar5,bVar15);
      piVar5 = FUN_004db78c(local_14,local_10);
      local_c = FUN_004db92c(piVar5,bVar16);
      piVar5 = FUN_004db78c(local_c,local_8);
      piVar5 = FUN_004db92c(piVar5,bVar17);
      piVar5 = FUN_004db78c(piVar5,(uint)bVar2);
      FUN_004dbb24(piVar5,s_is_obsolete__004e0da4,(char *)0x0);
      FUN_004036a0(1);
    }
    piVar6 = (int *)(**(code **)(*piVar6 + 0x1c))(piVar6,param_1 + 8,4);
    (**(code **)(*piVar6 + 0x1c))(piVar6,param_1 + 0x18,4);
    pcVar7 = (char *)FUN_004dee74(s_PRELOAD_004e0db4);
    if ((pcVar7 == (char *)0x0) || (iVar8 = FUN_004d4b58(pcVar7,&DAT_004e0dbc), iVar8 != 0)) {
      local_20 = 1;
    }
    else {
      local_20 = 0;
    }
    local_24 = (int *)FUN_004022b0(*(int *)(param_1 + 0x18) << 2);
    (**(code **)(*(int *)(param_1 + 0x1c) + 0x1c))
              (param_1 + 0x1c,local_24,*(int *)(param_1 + 0x18) << 2);
    iVar8 = *(int *)(param_1 + 0x18) + 0x32;
    *(int *)(param_1 + 0x10) = iVar8;
    uVar9 = FUN_004022b0(iVar8 * 4);
    *(undefined4 *)(param_1 + 0xc) = uVar9;
    for (iVar8 = 0; iVar8 < *(int *)(param_1 + 0x10); iVar8 = iVar8 + 1) {
      *(undefined4 *)(*(int *)(param_1 + 0xc) + iVar8 * 4) = 0;
    }
    *(int *)(param_1 + 0x18) = *(int *)(param_1 + 0x18) + -1;
    local_28 = local_24;
    for (iVar8 = 0; iVar8 <= *(int *)(param_1 + 0x18); iVar8 = iVar8 + 1) {
      if (*local_28 == 0) {
        *(undefined4 *)(*(int *)(param_1 + 0xc) + iVar8 * 4) = 0;
      }
      else {
        piVar6 = (int *)(param_1 + 0x1c);
        (**(code **)(*(int *)(param_1 + 0x1c) + 0xc))(piVar6,*local_28);
        (**(code **)(*piVar6 + 0x1c))(piVar6,&local_60,0x38);
        piVar6 = (int *)0x0;
        if (((local_34 == 0) && (local_2c != 0)) && (local_20 != 0)) {
          piVar6 = (int *)FUN_004022b0(local_2c);
          (**(code **)(*(int *)(param_1 + 0x1c) + 0xc))(param_1 + 0x1c,local_30);
          (**(code **)(*(int *)(param_1 + 0x1c) + 0x1c))(param_1 + 0x1c,piVar6,local_2c);
        }
        if ((local_5c < 9) && (piVar6 != (int *)0x0)) {
          uVar9 = FUN_00406ec4(param_1,local_58,local_5c,local_38,local_34,piVar6 + 1,*piVar6,
                               local_60);
          *(undefined4 *)(*(int *)(param_1 + 0xc) + iVar8 * 4) = uVar9;
        }
        else {
          uVar9 = FUN_00406db4(param_1,local_58,local_5c,local_38,local_34,piVar6,local_2c,local_60)
          ;
          *(undefined4 *)(*(int *)(param_1 + 0xc) + iVar8 * 4) = uVar9;
        }
        iVar3 = *(int *)(*(int *)(param_1 + 0xc) + iVar8 * 4);
        *(undefined4 *)(iVar3 + 0x34) = local_30;
        if (piVar6 != (int *)0x0) {
          iVar4 = *(int *)(iVar3 + 4);
          *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + 1;
          if (iVar4 == 0) {
            FUN_00406cd0(iVar3);
          }
          FUN_004022e8(piVar6);
        }
      }
      local_28 = local_28 + 1;
    }
    FUN_004022e8(local_24);
    return 1;
  }
  return 0;
}



/* @004076c0 file=? name=FUN_004076c0 */

undefined4 __cdecl FUN_004076c0(int param_1)

{
  int *piVar1;
  int iVar2;
  undefined4 *puVar3;
  undefined4 uVar4;
  int *piVar5;
  int iVar6;
  undefined4 local_44;
  undefined4 local_40;
  undefined4 local_3c [8];
  undefined4 local_1c;
  uint local_18;
  int local_14;
  undefined4 local_10;
  int *local_c;
  int *local_8;
  
  if (*(int *)(param_1 + 0xc) == 0) {
    uVar4 = 0;
  }
  else {
    for (iVar6 = 0; iVar6 <= *(int *)(param_1 + 0x18); iVar6 = iVar6 + 1) {
      iVar2 = *(int *)(*(int *)(param_1 + 0xc) + iVar6 * 4);
      if (iVar2 != 0) {
        FUN_00406cd0(iVar2);
      }
    }
    if (*(int *)(param_1 + 0x2c) != -1) {
      FUN_00403564(param_1 + 0x1c);
    }
    piVar1 = (int *)(param_1 + 0x1c);
    FUN_004034e4((int)piVar1,(LPCSTR)(param_1 + 0x34),1);
    *(int *)(param_1 + 0x18) = *(int *)(param_1 + 0x18) + 1;
    (**(code **)(*(int *)(param_1 + 0x1c) + 0x20))(piVar1,param_1 + 4,4);
    piVar5 = (int *)(**(code **)(*piVar1 + 0x20))(piVar1,param_1 + 8,4);
    (**(code **)(*piVar5 + 0x20))(piVar5,param_1 + 0x18,4);
    local_8 = (int *)FUN_004022b0(*(int *)(param_1 + 0x18) << 2);
    (**(code **)(*(int *)(param_1 + 0x1c) + 0x20))(piVar1,local_8,*(int *)(param_1 + 0x18) << 2);
    local_c = local_8;
    for (iVar6 = 0; iVar6 < *(int *)(param_1 + 0x18); iVar6 = iVar6 + 1) {
      puVar3 = *(undefined4 **)(*(int *)(param_1 + 0xc) + iVar6 * 4);
      if (puVar3 == (undefined4 *)0x0) {
        *local_c = 0;
      }
      else {
        local_14 = *(int *)(param_1 + 0x24) - *(int *)(param_1 + 0x20);
        (**(code **)(*(int *)(param_1 + 0x1c) + 0x20))(param_1 + 0x1c,puVar3[0xf],puVar3[0x10]);
        *local_c = *(int *)(param_1 + 0x24) - *(int *)(param_1 + 0x20);
        local_44 = *puVar3;
        local_40 = puVar3[2];
        FUN_004d4918(local_3c,puVar3 + 3,0x20);
        local_10 = puVar3[0x10];
        local_1c = puVar3[0xb];
        local_18 = puVar3[0xc] & 0xfffffffe;
        (**(code **)(*(int *)(param_1 + 0x1c) + 0x20))((int *)(param_1 + 0x1c),&local_44,0x38);
      }
      local_c = local_c + 1;
    }
    iVar6 = param_1 + 0x1c;
    (**(code **)(*(int *)(param_1 + 0x1c) + 0xc))(iVar6,0xc);
    (**(code **)(*(int *)(param_1 + 0x1c) + 0x20))(iVar6,local_8,*(int *)(param_1 + 0x18) << 2);
    FUN_004022d0(local_8);
    *(int *)(param_1 + 0x18) = *(int *)(param_1 + 0x18) + -1;
    FUN_00403564(iVar6);
    uVar4 = 1;
  }
  return uVar4;
}



/* @00407860 file=? name=FUN_00407860 */

void __cdecl FUN_00407860(int param_1,char *param_2)

{
  char cVar1;
  uint uVar2;
  uint uVar3;
  char *pcVar4;
  char *pcVar5;
  
  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 + 0x34);
  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_004076c0(param_1);
  return;
}



/* @0040789c file=? name=FUN_0040789c */

void __cdecl FUN_0040789c(int param_1,int param_2)

{
  undefined4 uVar1;
  
  *(uint *)(param_2 + 0x30) = *(uint *)(param_2 + 0x30) | 1;
  uVar1 = FUN_004022b0(*(uint *)(param_2 + 0x40));
  *(undefined4 *)(param_2 + 0x3c) = uVar1;
  (**(code **)(*(int *)(param_1 + 0x1c) + 0xc))(param_1 + 0x1c,*(undefined4 *)(param_2 + 0x34));
  (**(code **)(*(int *)(param_1 + 0x1c) + 0x1c))
            (param_1 + 0x1c,*(undefined4 *)(param_2 + 0x3c),*(undefined4 *)(param_2 + 0x40));
  return;
}



/* @004078e4 file=? name=FUN_004078e4 */

undefined4 FUN_004078e4(void)

{
  return 1;
}



/* @004078ee file=? name=FUN_004078ee */

void __cdecl FUN_004078ee(undefined4 param_1,int param_2)

{
  *(uint *)(param_2 + 0x30) = *(uint *)(param_2 + 0x30) | 1;
  return;
}



/* @004078fc file=? name=FUN_004078fc */

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

int __cdecl FUN_004078fc(float param_1)

{
  int iVar1;
  
  FUN_004dcd10((double)param_1);
  iVar1 = FUN_004dcd94();
  if (_DAT_00407940 <= param_1 - (float)iVar1) {
    iVar1 = iVar1 + 1;
  }
  return iVar1;
}



/* @004079fc file=munga/scalar.cpp name=FUN_004079fc */

void __cdecl FUN_004079fc(char *param_1,int param_2)

{
  if (param_1 == (char *)0x0) {
    FUN_0040385c(s_Convert_From_Ascii___str____NULL_004e0e7c,s_d__tesla_bt_munga_SCALAR_CPP_004e0e9d
                 ,0x5d);
  }
  if (param_2 == 0) {
    FUN_0040385c(s_Convert_From_Ascii___value____NU_004e0eba,s_d__tesla_bt_munga_SCALAR_CPP_004e0edd
                 ,0x61);
  }
  if (((&DAT_005207dd)[*param_1] & 0xc) != 0) {
    FUN_004dbb24(&DAT_00524e20,s_Convert_From_Ascii___str____004e0efa,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,param_1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_004e0f17,(char *)0x0);
    FUN_0040385c(s_Convert_From_Ascii___isalpha__st_004e0f19,s_d__tesla_bt_munga_SCALAR_CPP_004e0f3c
                 ,0x66);
  }
  return;
}



/* @00407a90 file=? name=FUN_00407a90 */

void __cdecl FUN_00407a90(char *param_1,undefined1 *param_2)

{
  int iVar1;
  
  FUN_004079fc(param_1,(int)param_2);
  iVar1 = FUN_004dd1e0(param_1);
  *param_2 = (char)iVar1;
  return;
}



/* @00407ab8 file=? name=FUN_00407ab8 */

void __cdecl FUN_00407ab8(char *param_1,undefined1 *param_2)

{
  int iVar1;
  
  FUN_004079fc(param_1,(int)param_2);
  iVar1 = FUN_004dd1e0(param_1);
  *param_2 = (char)iVar1;
  return;
}



/* @00407ae0 file=? name=FUN_00407ae0 */

void __cdecl FUN_00407ae0(char *param_1,int *param_2)

{
  int iVar1;
  
  FUN_004079fc(param_1,(int)param_2);
  iVar1 = FUN_004dd1e0(param_1);
  *param_2 = iVar1;
  return;
}



/* @00407b08 file=? name=FUN_00407b08 */

void __cdecl FUN_00407b08(char *param_1,int *param_2)

{
  int iVar1;
  
  FUN_004079fc(param_1,(int)param_2);
  iVar1 = FUN_004dd1e0(param_1);
  *param_2 = iVar1;
  return;
}



/* @00407b30 file=? name=FUN_00407b30 */

void __cdecl FUN_00407b30(char *param_1,int *param_2)

{
  int iVar1;
  
  FUN_004079fc(param_1,(int)param_2);
  iVar1 = FUN_004dd1e0(param_1);
  *param_2 = iVar1;
  return;
}



/* @00407b54 file=? name=FUN_00407b54 */

void __cdecl FUN_00407b54(char *param_1,int *param_2)

{
  int iVar1;
  
  FUN_004079fc(param_1,(int)param_2);
  iVar1 = FUN_004dd1e0(param_1);
  *param_2 = iVar1;
  return;
}



/* @00407b78 file=? name=FUN_00407b78 */

void __cdecl FUN_00407b78(char *param_1,float *param_2)

{
  float10 fVar1;
  
  FUN_004079fc(param_1,(int)param_2);
  fVar1 = (float10)FUN_004dd1cc(param_1);
  *param_2 = (float)fVar1;
  return;
}



/* @00407b9c file=? name=FUN_00407b9c */

void __cdecl FUN_00407b9c(undefined4 *param_1)

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



/* @00407bb0 file=? name=FUN_00407bb0 */

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

{
  *param_1 = param_2;
  param_1[1] = param_3;
  param_1[2] = param_4;
  param_1[3] = param_5;
  return;
}



/* @00407bd0 file=? name=FUN_00407bd0 */

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

{
  *param_1 = param_2;
  param_1[1] = param_3;
  param_1[2] = param_4;
  param_1[3] = param_5;
  return;
}



/* @00407bf0 file=? name=FUN_00407bf0 */

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

{
  bool bVar1;
  int iVar2;
  
  if ((param_2[2] < *param_2) || (param_2[3] < param_2[1])) {
    bVar1 = true;
  }
  else {
    bVar1 = false;
  }
  if (!bVar1) {
    if ((param_3[2] < *param_3) || (param_3[3] < param_3[1])) {
      bVar1 = true;
    }
    else {
      bVar1 = false;
    }
    if (bVar1) {
      *param_1 = *param_2;
      param_1[1] = param_2[1];
      param_1[2] = param_2[2];
      param_1[3] = param_2[3];
      return;
    }
    if (*param_2 < *param_3) {
      iVar2 = *param_2;
    }
    else {
      iVar2 = *param_3;
    }
    *param_1 = iVar2;
    if (param_2[1] < param_3[1]) {
      iVar2 = param_2[1];
    }
    else {
      iVar2 = param_3[1];
    }
    param_1[1] = iVar2;
    if (param_3[2] < param_2[2]) {
      iVar2 = param_2[2];
    }
    else {
      iVar2 = param_3[2];
    }
    param_1[2] = iVar2;
    if (param_3[3] < param_2[3]) {
      iVar2 = param_2[3];
    }
    else {
      iVar2 = param_3[3];
    }
    param_1[3] = iVar2;
    return;
  }
  bVar1 = true;
  if ((*param_3 <= param_3[2]) && (param_3[1] <= param_3[3])) {
    bVar1 = false;
  }
  if (bVar1) {
    *param_1 = 1;
    param_1[2] = 0;
    return;
  }
  *param_1 = *param_3;
  param_1[1] = param_3[1];
  param_1[2] = param_3[2];
  param_1[3] = param_3[3];
  return;
}



/* @00407cd0 file=? name=FUN_00407cd0 */

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

{
  bool bVar1;
  int iVar2;
  
  if ((param_2[2] < *param_2) || (param_2[3] < param_2[1])) {
    bVar1 = true;
  }
  else {
    bVar1 = false;
  }
  if (bVar1) {
    *param_1 = 1;
    param_1[2] = 0;
    return;
  }
  if ((param_3[2] < *param_3) || (param_3[3] < param_3[1])) {
    bVar1 = true;
  }
  else {
    bVar1 = false;
  }
  if (bVar1) {
    *param_1 = 1;
    param_1[2] = 0;
    return;
  }
  if (*param_3 < *param_2) {
    iVar2 = *param_2;
  }
  else {
    iVar2 = *param_3;
  }
  *param_1 = iVar2;
  if (param_3[1] < param_2[1]) {
    iVar2 = param_2[1];
  }
  else {
    iVar2 = param_3[1];
  }
  param_1[1] = iVar2;
  if (param_2[2] < param_3[2]) {
    iVar2 = param_2[2];
  }
  else {
    iVar2 = param_3[2];
  }
  param_1[2] = iVar2;
  if (param_2[3] < param_3[3]) {
    iVar2 = param_2[3];
  }
  else {
    iVar2 = param_3[3];
  }
  param_1[3] = iVar2;
  return;
}



/* @00407d78 file=? name=FUN_00407d78 */

void __cdecl FUN_00407d78(int *param_1,uint *param_2)

{
  int *piVar1;
  byte bVar2;
  uint *puVar3;
  byte bVar4;
  
  bVar4 = 0x29;
  puVar3 = param_2 + 2;
  bVar2 = 0x2c;
  piVar1 = FUN_004db92c(param_1,0x28);
  piVar1 = (int *)FUN_00407f08(piVar1,param_2);
  piVar1 = FUN_004db92c(piVar1,bVar2);
  piVar1 = (int *)FUN_00407f08(piVar1,puVar3);
  FUN_004db92c(piVar1,bVar4);
  return;
}



/* @00407dc0 file=? name=FUN_00407dc0 */

undefined4 FUN_00407dc0(void)

{
  return 1;
}



/* @00407dca file=? name=FUN_00407dca */

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

{
  *param_1 = -*param_2;
  param_1[1] = -param_2[1];
  return;
}



/* @00407de3 file=? name=FUN_00407de3 */

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

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



/* @00407e04 file=? name=FUN_00407e04 */

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

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



/* @00407e25 file=? name=FUN_00407e25 */

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

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



/* @00407e45 file=? name=FUN_00407e45 */

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

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



/* @00407e66 file=? name=FUN_00407e66 */

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

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



/* @00407e8a file=? name=FUN_00407e8a */

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

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



/* @00407eaf file=? name=FUN_00407eaf */

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

{
  int iVar1;
  
  FUN_004dd138((double)(*param_2 * *param_2 + param_2[1] * param_2[1]));
  iVar1 = FUN_004dcd94();
  *param_1 = *param_2 / iVar1;
  param_1[1] = param_2[1] / iVar1;
  return param_1;
}



/* @00407efe file=? name=FUN_00407efe */

undefined4 FUN_00407efe(void)

{
  return 1;
}



/* @00407f08 file=? name=FUN_00407f08 */

void __cdecl FUN_00407f08(int *param_1,uint *param_2)

{
  uint uVar1;
  uint uVar2;
  int *piVar3;
  byte bVar4;
  byte bVar5;
  
  bVar5 = 0x3e;
  uVar1 = param_2[1];
  bVar4 = 0x2c;
  uVar2 = *param_2;
  piVar3 = FUN_004db92c(param_1,0x3c);
  piVar3 = FUN_004db78c(piVar3,uVar2);
  piVar3 = FUN_004db92c(piVar3,bVar4);
  piVar3 = FUN_004db78c(piVar3,uVar1);
  FUN_004db92c(piVar3,bVar5);
  return;
}



/* @00407f68 file=? name=FUN_00407f68 */

void FUN_00407f68(void)

{
  char *pcVar1;
  int iVar2;
  uint uVar3;
  uint *puVar4;
  uint uVar5;
  
  pcVar1 = (char *)FUN_004dee74(s_RANDOM_004e0f60);
  if (pcVar1 == (char *)0x0) {
    iVar2 = FUN_004dfda8((int *)0x0);
  }
  else {
    iVar2 = FUN_004dd1e0(pcVar1);
  }
  FUN_004dd4c0(iVar2);
  DAT_004e0f5c = 0;
  iVar2 = 0;
  puVar4 = &DAT_00521b74;
  do {
    uVar3 = FUN_004dd4d4();
    *puVar4 = uVar3;
    iVar2 = iVar2 + 1;
    puVar4 = puVar4 + 1;
  } while (iVar2 < 0xfa);
  uVar5 = 0x3fff;
  iVar2 = 0;
  uVar3 = 0x4000;
  while ((1 << ((byte)iVar2 & 0x1f) & 0x4000U) == 0) {
    iVar2 = iVar2 + 1;
  }
  puVar4 = &DAT_00521bac;
  while (iVar2 != 0) {
    *puVar4 = *puVar4 & uVar5;
    *puVar4 = *puVar4 | uVar3;
    uVar5 = (int)uVar5 >> 1;
    uVar3 = (int)uVar3 >> 1;
    puVar4 = puVar4 + 0xb;
    iVar2 = iVar2 + -1;
  }
  return;
}



/* @00407fec file=? name=FUN_00407fec */

void FUN_00407fec(void)

{
  int iVar1;
  
  if (DAT_004e0f5c < 0x93) {
    iVar1 = DAT_004e0f5c + 0x67;
  }
  else {
    iVar1 = DAT_004e0f5c + -0x93;
  }
  (&DAT_00521b74)[DAT_004e0f5c] = (&DAT_00521b74)[DAT_004e0f5c] ^ (&DAT_00521b74)[iVar1];
  DAT_004e0f5c = DAT_004e0f5c + 1;
  if (DAT_004e0f5c == 0xfa) {
    DAT_004e0f5c = 0;
  }
  return;
}



/* @00408050 file=? name=FUN_00408050 */

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

float10 FUN_00408050(void)

{
  int iVar1;
  
  iVar1 = FUN_00407fec();
  return (float10)(_DAT_00408078 * (float)iVar1);
}



/* @0040807c file=? name=FUN_0040807c */

int __cdecl FUN_0040807c(undefined4 param_1,uint param_2)

{
  int iVar1;
  
  do {
    iVar1 = FUN_00407fec();
  } while (0x7fff - (int)(0x8000 % (ulonglong)param_2) < iVar1);
  return iVar1 % (int)param_2;
}



/* @004080ac file=? name=FUN_004080ac */

int * __cdecl FUN_004080ac(int *param_1,uint param_2)

{
  if ((int)param_2 < 2) {
    param_2 = 2;
  }
  param_1[1] = param_2;
  *param_1 = 0x7fff - (int)(0x8000 % (ulonglong)param_2);
  return param_1;
}



/* @004080e0 file=? name=FUN_004080e0 */

int __cdecl FUN_004080e0(int *param_1)

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



/* @00408110 file=? name=FUN_00408110 */

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

float10 __cdecl FUN_00408110(float param_1)

{
  float10 fVar1;
  undefined4 local_8;
  
  fVar1 = FUN_004dcd2c((double)param_1,6.2831854820251465);
  local_8 = (float)fVar1;
  if (local_8 <= _DAT_00408170) {
    if (local_8 < _DAT_00408178) {
      local_8 = _DAT_00408174 + local_8;
    }
  }
  else {
    local_8 = local_8 - _DAT_00408174;
  }
  return (float10)local_8;
}



/* @0040817c file=? name=FUN_0040817c */

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

float * __cdecl FUN_0040817c(float *param_1)

{
  float10 fVar1;
  
  fVar1 = FUN_004dcd2c((double)*param_1,6.2831854820251465);
  *param_1 = (float)fVar1;
  if (*param_1 <= _DAT_004081d4) {
    if (*param_1 < _DAT_004081dc) {
      *param_1 = _DAT_004081d8 + *param_1;
    }
  }
  else {
    *param_1 = *param_1 - _DAT_004081d8;
  }
  return param_1;
}



/* @004081e0 file=? name=FUN_004081e0 */

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

float * __cdecl FUN_004081e0(float *param_1,float *param_2,float *param_3,float param_4)

{
  float fVar1;
  float10 fVar2;
  undefined4 local_c;
  
  fVar2 = FUN_00408110(*param_2);
  fVar1 = (float)fVar2;
  fVar2 = FUN_00408110(*param_3);
  local_c = (float)fVar2;
  if (local_c - fVar1 <= _DAT_00408260) {
    if (local_c - fVar1 < _DAT_00408268) {
      local_c = _DAT_00408264 + local_c;
    }
  }
  else {
    local_c = local_c - _DAT_00408264;
  }
  *param_1 = local_c * param_4 + (_DAT_0040826c - param_4) * fVar1;
  return param_1;
}



/* @00408270 file=? name=FUN_00408270 */

int * __cdecl FUN_00408270(int *param_1,float *param_2)

{
  int *piVar1;
  
  piVar1 = FUN_004db634(param_1,(float10)*param_2);
  FUN_004dbb24(piVar1,&DAT_004e0f68,(char *)0x0);
  return piVar1;
}



/* @004082ac file=? name=FUN_004082ac */

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

undefined4 __cdecl FUN_004082ac(float *param_1)

{
  undefined4 uVar1;
  
  if ((*param_1 < _DAT_004082d8) || (_DAT_004082dc < *param_1)) {
    uVar1 = 0;
  }
  else {
    uVar1 = 1;
  }
  return uVar1;
}



/* @0040831c file=? name=FUN_0040831c */

undefined4 FUN_0040831c(void)

{
  return 1;
}



/* @00408328 file=? name=FUN_00408328 */

float * __cdecl FUN_00408328(float *param_1,float *param_2)

{
  float10 fVar1;
  
  fVar1 = (float10)FUN_004dc9b4(SUB84((double)*param_2,0),(int)((ulonglong)(double)*param_2 >> 0x20)
                               );
  param_1[1] = (float)fVar1;
  fVar1 = (float10)FUN_004dd0f4(SUB84((double)*param_2,0),(int)((ulonglong)(double)*param_2 >> 0x20)
                               );
  *param_1 = (float)fVar1;
  fVar1 = (float10)FUN_004dc9b4(SUB84((double)*param_2,0),(int)((ulonglong)(double)*param_2 >> 0x20)
                               );
  param_1[1] = (float)fVar1;
  return param_1;
}



/* @00408374 file=? name=FUN_00408374 */

void __cdecl FUN_00408374(int *param_1,float *param_2)

{
  float fVar1;
  float fVar2;
  int *piVar3;
  byte bVar4;
  byte bVar5;
  
  bVar5 = 0x7d;
  fVar1 = *param_2;
  bVar4 = 0x2c;
  fVar2 = param_2[1];
  piVar3 = FUN_004db92c(param_1,0x7b);
  piVar3 = FUN_004db634(piVar3,(float10)fVar2);
  piVar3 = FUN_004db92c(piVar3,bVar4);
  piVar3 = FUN_004db634(piVar3,(float10)fVar1);
  FUN_004db92c(piVar3,bVar5);
  return;
}



/* @004083e0 file=? name=FUN_004083e0 */

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

bool __cdecl FUN_004083e0(float *param_1)

{
  float10 fVar1;
  
  fVar1 = FUN_004dcd00((double)((param_1[1] * param_1[1] + *param_1 * *param_1) - _DAT_00408438));
  return fVar1 <= (float10)_DAT_0040843c;
}



/* @00408440 file=? name=FUN_00408440 */

void __cdecl FUN_00408440(undefined4 *param_1,undefined4 *param_2)

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



/* @0040845c file=? name=FUN_0040845c */

undefined4 __cdecl FUN_0040845c(float *param_1,float param_2)

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



/* @004084fc file=? name=FUN_004084fc */

undefined4 __cdecl FUN_004084fc(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)) &&
     (fVar1 = FUN_004dcd00((double)(param_1[2] - param_2[2])), fVar1 <= (float10)param_3)) {
    return 1;
  }
  return 0;
}



/* @004085bc file=? name=FUN_004085bc */

undefined4 FUN_004085bc(void)

{
  return 1;
}



/* @004085c8 file=? name=FUN_004085c8 */

void __cdecl FUN_004085c8(float *param_1,float *param_2)

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



/* @004085ec file=? name=FUN_004085ec */

void __cdecl FUN_004085ec(float *param_1,float *param_2,float *param_3)

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



/* @00408614 file=? name=FUN_00408614 */

void __cdecl FUN_00408614(float *param_1,float *param_2,float *param_3,float param_4)

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



/* @00408644 file=? name=FUN_00408644 */

void __cdecl FUN_00408644(float *param_1,float *param_2,float *param_3)

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



/* @0040866c file=? name=FUN_0040866c */

float * __cdecl FUN_0040866c(float *param_1,float *param_2,float *param_3)

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



/* @004086ac file=? name=FUN_004086ac */

void __cdecl FUN_004086ac(float *param_1,float *param_2,float param_3)

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



/* @004086d0 file=? name=FUN_004086d0 */

void __cdecl FUN_004086d0(float *param_1,float *param_2,float *param_3)

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



/* @004086f8 file=? name=FUN_004086f8 */

void __cdecl FUN_004086f8(float *param_1,float *param_2,float param_3)

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



/* @0040871c file=? name=FUN_0040871c */

void __cdecl FUN_0040871c(float *param_1,float *param_2,float *param_3)

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



/* @00408744 file=? name=FUN_00408744 */

float * __cdecl FUN_00408744(float *param_1,float *param_2,float *param_3)

{
  *param_1 = param_2[2] * param_3[2] + param_2[1] * param_3[1] + *param_2 * *param_3;
  param_1[1] = param_2[2] * param_3[6] + param_2[1] * param_3[5] + *param_2 * param_3[4];
  param_1[2] = param_2[2] * param_3[10] + param_2[1] * param_3[9] + *param_2 * param_3[8];
  return param_1;
}



/* @0040879c file=? name=FUN_0040879c */

float * __cdecl FUN_0040879c(float *param_1,float *param_2,float *param_3)

{
  *param_1 = param_2[2] * param_3[8] + param_2[1] * param_3[4] + *param_2 * *param_3;
  param_1[1] = param_2[2] * param_3[9] + param_2[1] * param_3[5] + *param_2 * param_3[1];
  param_1[2] = param_2[2] * param_3[10] + param_2[1] * param_3[6] + *param_2 * param_3[2];
  return param_1;
}



/* @004087f4 file=? name=FUN_004087f4 */

float * __cdecl FUN_004087f4(float *param_1,float *param_2)

{
  float fVar1;
  float10 fVar2;
  
  fVar2 = FUN_004dd138((double)(param_2[2] * param_2[2] +
                               param_2[1] * param_2[1] + *param_2 * *param_2));
  fVar1 = (float)fVar2;
  *param_1 = *param_2 / fVar1;
  param_1[1] = param_2[1] / fVar1;
  param_1[2] = param_2[2] / fVar1;
  return param_1;
}



/* @00408848 file=? name=FUN_00408848 */

void __cdecl FUN_00408848(float *param_1,float *param_2,float param_3,float *param_4,float param_5)

{
  *param_1 = param_5 * *param_4 + param_3 * *param_2;
  param_1[1] = param_5 * param_4[1] + param_3 * param_2[1];
  param_1[2] = param_5 * param_4[2] + param_3 * param_2[2];
  return;
}



/* @00408888 file=? name=FUN_00408888 */

void __cdecl FUN_00408888(int *param_1,float *param_2)

{
  int *piVar1;
  int iVar2;
  byte bVar3;
  byte bVar4;
  byte bVar5;
  byte bVar6;
  code *local_20;
  undefined4 local_1c;
  int *local_18;
  float local_14;
  int *local_10;
  float local_c;
  float local_8;
  
  bVar6 = 0x3e;
  local_8 = param_2[2];
  bVar5 = 0x2c;
  local_c = param_2[1];
  bVar4 = 0x2c;
  local_14 = *param_2;
  bVar3 = 0x3c;
  FUN_004db000(&local_20,4);
  if (param_1 == (int *)0x0) {
    iVar2 = 0;
  }
  else {
    iVar2 = *param_1;
  }
  (*local_20)(iVar2,local_1c);
  local_18 = FUN_004db92c(param_1,bVar3);
  piVar1 = FUN_004db634(local_18,(float10)local_14);
  local_10 = FUN_004db92c(piVar1,bVar4);
  piVar1 = FUN_004db634(local_10,(float10)local_c);
  piVar1 = FUN_004db92c(piVar1,bVar5);
  piVar1 = FUN_004db634(piVar1,(float10)local_8);
  FUN_004db92c(piVar1,bVar6);
  return;
}



/* @00408944 file=? name=FUN_00408944 */

void __cdecl FUN_00408944(char *param_1,float *param_2)

{
  uint *puVar1;
  float10 fVar2;
  uint local_44 [2];
  char *local_3c;
  uint local_34 [2];
  char *local_2c;
  uint local_24 [2];
  char *local_1c;
  uint *local_14;
  uint *local_10;
  uint *local_c;
  uint *local_8;
  
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_8 = (uint *)0x0;
  }
  else {
    local_8 = FUN_00402460(puVar1,param_1);
  }
  local_8[3] = local_8[3] + 1;
  FUN_00402838(local_24,local_8,0,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_c = (uint *)0x0;
  }
  else {
    local_c = FUN_00402460(puVar1,local_1c);
  }
  local_c[3] = local_c[3] + 1;
  FUN_004024d8((int *)local_24,2);
  fVar2 = (float10)FUN_004dd1cc(local_c[2]);
  *param_2 = (float)fVar2;
  puVar1 = local_c + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_c,3);
  }
  FUN_00402838(local_34,local_8,1,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_10 = (uint *)0x0;
  }
  else {
    local_10 = FUN_00402460(puVar1,local_2c);
  }
  local_10[3] = local_10[3] + 1;
  FUN_004024d8((int *)local_34,2);
  fVar2 = (float10)FUN_004dd1cc(local_10[2]);
  param_2[1] = (float)fVar2;
  puVar1 = local_10 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_10,3);
  }
  FUN_00402838(local_44,local_8,2,(char *)0x0);
  puVar1 = (uint *)FUN_00402298(0x10);
  if (puVar1 == (uint *)0x0) {
    local_14 = (uint *)0x0;
  }
  else {
    local_14 = FUN_00402460(puVar1,local_3c);
  }
  local_14[3] = local_14[3] + 1;
  FUN_004024d8((int *)local_44,2);
  fVar2 = (float10)FUN_004dd1cc(local_14[2]);
  param_2[2] = (float)fVar2;
  puVar1 = local_14 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_14,3);
  }
  puVar1 = local_8 + 3;
  *puVar1 = *puVar1 - 1;
  if (*puVar1 == 0) {
    FUN_004024d8((int *)local_8,3);
  }
  return;
}



/* @00408ad8 file=? name=FUN_00408ad8 */

void __cdecl FUN_00408ad8(undefined4 *param_1,undefined4 *param_2)

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



/* @00408af4 file=? name=FUN_00408af4 */

void __cdecl FUN_00408af4(undefined4 *param_1,undefined4 *param_2)

{
  *param_1 = *param_2;
  param_1[1] = -(float)param_2[2];
  param_1[2] = param_2[1];
  return;
}



/* @00408b14 file=? name=FUN_00408b14 */

void __cdecl FUN_00408b14(undefined4 *param_1,undefined4 *param_2)

{
  *param_1 = *param_2;
  param_1[1] = param_2[1];
  param_1[2] = -(float)param_2[2];
  return;
}



/* @00408b34 file=? name=FUN_00408b34 */

void __cdecl FUN_00408b34(undefined4 *param_1,undefined4 *param_2)

{
  *param_1 = *param_2;
  param_1[1] = param_2[2];
  param_1[2] = -(float)param_2[1];
  return;
}



/* @00408b98 file=? name=FUN_00408b98 */

float * __cdecl FUN_00408b98(float *param_1,float *param_2,float *param_3)

{
  *param_1 = param_2[2] * param_3[2] + param_2[1] * param_3[1] + *param_2 * *param_3 + param_3[3];
  param_1[1] = param_2[2] * param_3[6] + param_2[1] * param_3[5] + *param_2 * param_3[4] +
               param_3[7];
  param_1[2] = param_2[2] * param_3[10] + param_2[1] * param_3[9] + *param_2 * param_3[8] +
               param_3[0xb];
  return param_1;
}



/* @00408bf8 file=? name=FUN_00408bf8 */

float * __cdecl FUN_00408bf8(float *param_1,float *param_2,float *param_3)

{
  *param_1 = (((param_2[2] * param_3[8] + param_2[1] * param_3[4] + *param_2 * *param_3) -
              param_3[3] * *param_3) - param_3[7] * param_3[4]) - param_3[0xb] * param_3[8];
  param_1[1] = (((param_2[2] * param_3[9] + param_2[1] * param_3[5] + *param_2 * param_3[1]) -
                param_3[3] * param_3[1]) - param_3[7] * param_3[5]) - param_3[0xb] * param_3[9];
  param_1[2] = (((param_2[2] * param_3[10] + param_2[1] * param_3[6] + *param_2 * param_3[2]) -
                param_3[3] * param_3[2]) - param_3[7] * param_3[6]) - param_3[0xb] * param_3[10];
  return param_1;
}



/* @00408cbc file=? name=FUN_00408cbc */

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

undefined4 __cdecl FUN_00408cbc(float *param_1)

{
  float10 fVar1;
  
  fVar1 = FUN_004dcd00((double)(_DAT_00408d70 -
                               (param_1[2] * param_1[2] +
                               param_1[1] * param_1[1] + *param_1 * *param_1)));
  if (((float10)_DAT_00408d74 < fVar1) &&
     (fVar1 = FUN_004dcd00((double)(_DAT_00408d70 -
                                   (param_1[2] * param_1[2] +
                                   param_1[1] * param_1[1] + *param_1 * *param_1))),
     (float10)_DAT_00408d74 < fVar1)) {
    return 0;
  }
  return 1;
}



/* @00408d78 file=? name=FUN_00408d78 */

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

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



/* @00408dd4 file=? name=FUN_00408dd4 */

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

{
  *param_1 = *param_2;
  FUN_004081e0((float *)(param_1 + 1),(float *)(param_2 + 1),(float *)(param_3 + 4),param_4);
  return param_1;
}



/* @00408e04 file=? name=FUN_00408e04 */

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

{
  int iVar1;
  int *piVar2;
  
  piVar2 = FUN_00408270(param_1,(float *)(param_2 + 1));
  FUN_004dbb24(piVar2,s_about_004e0fb4,(char *)0x0);
  iVar1 = *param_2;
  if (iVar1 == 0) {
    FUN_004dbb24(param_1,s_X_Axis_004e0fbc,(char *)0x0);
  }
  else if (iVar1 == 1) {
    FUN_004dbb24(param_1,s_Y_Axis_004e0fc3,(char *)0x0);
  }
  else if (iVar1 == 2) {
    FUN_004dbb24(param_1,s_Z_Axis_004e0fca,(char *)0x0);
  }
  return param_1;
}



/* @00408e78 file=? name=FUN_00408e78 */

bool __cdecl FUN_00408e78(uint *param_1)

{
  return *param_1 < 3;
}



/* @00408e90 file=? name=FUN_00408e90 */

void __cdecl FUN_00408e90(undefined4 *param_1,undefined4 *param_2)

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



/* @00408ec0 file=? name=FUN_00408ec0 */

float * __cdecl FUN_00408ec0(float *param_1,float *param_2)

{
  float local_34 [12];
  
  FUN_0040aadc(local_34);
  FUN_0040ad2c(local_34,param_2);
  FUN_00408f7c(param_1,local_34);
  return param_1;
}



/* @00408ef8 file=? name=FUN_00408ef8 */

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

{
  int iVar1;
  
  *param_1 = 0;
  param_1[1] = 0;
  param_1[2] = 0;
  iVar1 = *param_2;
  if (iVar1 == 0) {
    *param_1 = param_2[1];
  }
  else if (iVar1 == 1) {
    param_1[1] = param_2[1];
  }
  else if (iVar1 == 2) {
    param_1[2] = param_2[1];
  }
  return;
}



/* @00408f44 file=? name=FUN_00408f44 */

void __cdecl FUN_00408f44(float *param_1,float *param_2)

{
  float local_34 [12];
  
  FUN_0040aadc(local_34);
  FUN_0040adec(local_34,param_2);
  FUN_00408f7c(param_1,local_34);
  return;
}



/* @00408f7c file=? name=FUN_00408f7c */

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

float * __cdecl FUN_00408f7c(float *param_1,float *param_2)

{
  float10 fVar1;
  float local_1c;
  float local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  local_14 = -param_2[8];
  fVar1 = FUN_004dcd00((double)(local_14 - _DAT_00409148));
  if ((float10)_DAT_0040914c < fVar1) {
    fVar1 = FUN_004dcd00((double)(local_14 - _DAT_00409150));
    if ((float10)_DAT_0040914c < fVar1) {
      fVar1 = FUN_004dd138((double)(_DAT_00409148 - local_14 * local_14));
      local_10 = (float)fVar1;
      local_c = param_2[9] / local_10;
      local_8 = param_2[10] / local_10;
      local_1c = param_2[4] / local_10;
      local_18 = *param_2 / local_10;
      fVar1 = FUN_004dcd00((double)((local_c * local_14 * local_18 - local_8 * local_1c) -
                                   param_2[1]));
      if ((float10)_DAT_0040914c < fVar1) {
        local_14 = -local_14;
        local_c = -local_c;
        local_8 = -local_8;
        local_1c = -local_1c;
        local_18 = -local_18;
      }
    }
    else {
      local_10 = 0.0;
      local_1c = 0.0;
      local_18 = 1.0;
      local_c = -param_2[1];
      local_8 = -param_2[2];
    }
  }
  else {
    local_10 = 0.0;
    local_1c = 0.0;
    local_18 = 1.0;
    local_c = param_2[1];
    local_8 = param_2[2];
  }
  fVar1 = FUN_004dc8ec((double)local_c,SUB84((double)local_8,0),
                       (uint)((ulonglong)(double)local_8 >> 0x20));
  *param_1 = (float)fVar1;
  fVar1 = FUN_004dc8ec((double)local_14,SUB84((double)local_10,0),
                       (uint)((ulonglong)(double)local_10 >> 0x20));
  param_1[1] = (float)fVar1;
  fVar1 = FUN_004dc8ec((double)local_1c,SUB84((double)local_18,0),
                       (uint)((ulonglong)(double)local_18 >> 0x20));
  param_1[2] = (float)fVar1;
  return param_1;
}



/* @004091f4 file=? name=FUN_004091f4 */

undefined4 __cdecl FUN_004091f4(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)) &&
     (fVar1 = FUN_004dcd00((double)(param_1[2] - param_2[2])), fVar1 <= (float10)param_3)) {
    return 1;
  }
  return 0;
}



/* @004092b4 file=? name=FUN_004092b4 */

void __cdecl FUN_004092b4(float *param_1,float *param_2,float *param_3)

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



/* @004092fc file=? name=FUN_004092fc */

void __cdecl FUN_004092fc(float *param_1,float *param_2,float param_3)

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



/* @00409340 file=? name=FUN_00409340 */

void __cdecl FUN_00409340(float *param_1,float *param_2,float *param_3,float param_4)

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



/* @00409390 file=? name=FUN_00409390 */

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

void __cdecl FUN_00409390(float *param_1,float *param_2,float *param_3,float param_4)

{
  *param_1 = *param_3 * param_4 + (_DAT_00409400 - param_4) * *param_2;
  param_1[1] = param_3[1] * param_4 + (_DAT_00409400 - param_4) * param_2[1];
  param_1[2] = param_3[2] * param_4 + (_DAT_00409400 - param_4) * param_2[2];
  return;
}



/* @0040942c file=? name=FUN_0040942c */

void __cdecl FUN_0040942c(int *param_1,float *param_2)

{
  int *piVar1;
  byte bVar2;
  float *pfVar3;
  byte bVar4;
  float *pfVar5;
  byte bVar6;
  
  bVar6 = 0x3e;
  pfVar5 = param_2 + 2;
  pfVar3 = param_2 + 1;
  bVar4 = 0x2c;
  bVar2 = 0x2c;
  piVar1 = FUN_004db92c(param_1,0x3c);
  piVar1 = FUN_00408270(piVar1,param_2);
  piVar1 = FUN_004db92c(piVar1,bVar2);
  piVar1 = FUN_00408270(piVar1,pfVar3);
  piVar1 = FUN_004db92c(piVar1,bVar4);
  piVar1 = FUN_00408270(piVar1,pfVar5);
  FUN_004db92c(piVar1,bVar6);
  return;
}



/* @0040948c file=? name=FUN_0040948c */

undefined4 FUN_0040948c(void)

{
  return 1;
}



/* @00409498 file=? name=FUN_00409498 */

void __cdecl FUN_00409498(undefined4 *param_1,undefined4 *param_2)

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



/* @004094c8 file=? name=FUN_004094c8 */

float * __cdecl FUN_004094c8(float *param_1,float *param_2)

{
  float local_34 [12];
  
  FUN_0040aadc(local_34);
  FUN_0040ac6c(local_34,param_2);
  FUN_00409584(param_1,local_34);
  return param_1;
}



/* @00409500 file=? name=FUN_00409500 */

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

{
  int iVar1;
  
  param_1[1] = 0;
  *param_1 = 0;
  param_1[2] = 0;
  iVar1 = *param_2;
  if (iVar1 == 0) {
    param_1[1] = param_2[1];
  }
  else if (iVar1 == 1) {
    *param_1 = param_2[1];
  }
  else if (iVar1 == 2) {
    param_1[2] = param_2[1];
  }
  return;
}



/* @0040954c file=? name=FUN_0040954c */

void __cdecl FUN_0040954c(float *param_1,float *param_2)

{
  float local_34 [12];
  
  FUN_0040aadc(local_34);
  FUN_0040adec(local_34,param_2);
  FUN_00409584(param_1,local_34);
  return;
}



/* @00409584 file=? name=FUN_00409584 */

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

float * __cdecl FUN_00409584(float *param_1,float *param_2)

{
  float10 fVar1;
  float local_1c;
  float local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  local_c = -param_2[6];
  fVar1 = FUN_004dcd00((double)(local_c - _DAT_00409748));
  if ((float10)_DAT_0040974c < fVar1) {
    fVar1 = FUN_004dcd00((double)(local_c - _DAT_00409750));
    if ((float10)_DAT_0040974c < fVar1) {
      fVar1 = FUN_004dd138((double)(_DAT_00409748 - local_c * local_c));
      local_8 = (float)fVar1;
      local_14 = param_2[2] / local_8;
      local_10 = param_2[10] / local_8;
      local_1c = param_2[4] / local_8;
      local_18 = param_2[5] / local_8;
      fVar1 = FUN_004dcd00((double)((local_c * local_14 * local_1c + local_10 * local_18) - *param_2
                                   ));
      if ((float10)_DAT_0040974c < fVar1) {
        local_c = -local_c;
        local_14 = -local_14;
        local_10 = -local_10;
        local_1c = -local_1c;
        local_18 = -local_18;
      }
    }
    else {
      local_8 = 0.0;
      local_1c = 0.0;
      local_18 = 1.0;
      local_14 = param_2[8];
      local_10 = *param_2;
    }
  }
  else {
    local_8 = 0.0;
    local_1c = 0.0;
    local_18 = 1.0;
    local_14 = param_2[1];
    local_10 = *param_2;
  }
  fVar1 = FUN_004dc8ec((double)local_c,SUB84((double)local_8,0),
                       (uint)((ulonglong)(double)local_8 >> 0x20));
  param_1[1] = (float)fVar1;
  fVar1 = FUN_004dc8ec((double)local_14,SUB84((double)local_10,0),
                       (uint)((ulonglong)(double)local_10 >> 0x20));
  *param_1 = (float)fVar1;
  fVar1 = FUN_004dc8ec((double)local_1c,SUB84((double)local_18,0),
                       (uint)((ulonglong)(double)local_18 >> 0x20));
  param_1[2] = (float)fVar1;
  return param_1;
}



/* @004097f4 file=? name=FUN_004097f4 */

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

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



/* @004098b4 file=? name=FUN_004098b4 */

float * __cdecl FUN_004098b4(float *param_1)

{
  FUN_0040817c(param_1 + 1);
  FUN_0040817c(param_1);
  FUN_0040817c(param_1 + 2);
  return param_1;
}



/* @004098dc file=? name=FUN_004098dc */

void __cdecl FUN_004098dc(int *param_1,float *param_2)

{
  int *piVar1;
  byte bVar2;
  float *pfVar3;
  byte bVar4;
  float *pfVar5;
  byte bVar6;
  
  bVar6 = 0x3e;
  pfVar5 = param_2 + 2;
  pfVar3 = param_2 + 1;
  bVar4 = 0x2c;
  bVar2 = 0x2c;
  piVar1 = FUN_004db92c(param_1,0x3c);
  piVar1 = FUN_00408270(piVar1,param_2);
  piVar1 = FUN_004db92c(piVar1,bVar2);
  piVar1 = FUN_00408270(piVar1,pfVar3);
  piVar1 = FUN_004db92c(piVar1,bVar4);
  piVar1 = FUN_00408270(piVar1,pfVar5);
  FUN_004db92c(piVar1,bVar6);
  return;
}



/* @0040993c file=? name=FUN_0040993c */

undefined4 FUN_0040993c(void)

{
  return 1;
}



/* @00409948 file=? name=FUN_00409948 */

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

{
  *param_1 = param_2;
  param_1[1] = param_3;
  param_1[2] = param_4;
  param_1[3] = param_5;
  return;
}



/* @00409968 file=? name=FUN_00409968 */

void __cdecl FUN_00409968(undefined4 *param_1,undefined4 *param_2)

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



/* @0040998c file=? name=FUN_0040998c */

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

float * __cdecl FUN_0040998c(float *param_1,int *param_2)

{
  int iVar1;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  local_c = (float)param_2[1] * _DAT_004099fc;
  local_8 = local_c;
  FUN_00408328(&local_14,&local_8);
  param_1[3] = local_10;
  *param_1 = 0.0;
  param_1[1] = 0.0;
  param_1[2] = 0.0;
  iVar1 = *param_2;
  if (iVar1 == 0) {
    *param_1 = local_14;
  }
  else if (iVar1 == 1) {
    param_1[1] = local_14;
  }
  else if (iVar1 == 2) {
    param_1[2] = local_14;
  }
  return param_1;
}



/* @00409a00 file=? name=FUN_00409a00 */

float * __cdecl FUN_00409a00(float *param_1,float *param_2)

{
  float local_34 [12];
  
  FUN_0040aadc(local_34);
  FUN_0040ac6c(local_34,param_2);
  FUN_00409a70(param_1,local_34);
  return param_1;
}



/* @00409a38 file=? name=FUN_00409a38 */

float * __cdecl FUN_00409a38(float *param_1,float *param_2)

{
  float local_34 [12];
  
  FUN_0040aadc(local_34);
  FUN_0040ad2c(local_34,param_2);
  FUN_00409a70(param_1,local_34);
  return param_1;
}



/* @00409a70 file=? name=FUN_00409a70 */

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

float * __cdecl FUN_00409a70(float *param_1,float *param_2)

{
  float fVar1;
  float10 fVar2;
  
  param_1[3] = (_DAT_00409c44 + *param_2 + param_2[5] + param_2[10]) * _DAT_00409c48;
  fVar2 = FUN_004dcd00((double)param_1[3]);
  if ((float10)_DAT_00409c4c < fVar2) {
    fVar2 = FUN_004dd138((double)param_1[3]);
    param_1[3] = (float)fVar2;
    *param_1 = ((param_2[9] - param_2[6]) * _DAT_00409c48) / param_1[3];
    param_1[1] = ((param_2[2] - param_2[8]) * _DAT_00409c48) / param_1[3];
    param_1[2] = ((param_2[4] - param_2[1]) * _DAT_00409c48) / param_1[3];
  }
  else {
    if (param_1[3] < _DAT_00409c50) {
      param_1[3] = 0.0;
    }
    fVar1 = (_DAT_00409c44 + *param_2) * _DAT_00409c54 - param_1[3];
    if (fVar1 < _DAT_00409c50) {
      fVar1 = _DAT_00409c50;
    }
    fVar2 = FUN_004dd138((double)fVar1);
    *param_1 = (float)fVar2;
    fVar1 = (_DAT_00409c44 + param_2[5]) * _DAT_00409c54 - param_1[3];
    if (fVar1 < _DAT_00409c50) {
      fVar1 = _DAT_00409c50;
    }
    fVar2 = FUN_004dd138((double)fVar1);
    param_1[1] = (float)fVar2;
    fVar1 = (_DAT_00409c44 + param_2[10]) * _DAT_00409c54 - param_1[3];
    if (fVar1 < _DAT_00409c50) {
      fVar1 = _DAT_00409c50;
    }
    fVar2 = FUN_004dd138((double)fVar1);
    param_1[2] = (float)fVar2;
    fVar2 = FUN_004dd138((double)param_1[3]);
    param_1[3] = (float)fVar2;
    if (param_2[4] < param_2[1]) {
      param_1[2] = -param_1[2];
    }
    if (param_2[2] < param_2[8]) {
      param_1[1] = -param_1[1];
    }
    if (param_2[9] < param_2[6]) {
      *param_1 = -*param_1;
    }
  }
  return param_1;
}



/* @00409d9c file=? name=FUN_00409d9c */

float * __cdecl FUN_00409d9c(float *param_1,float *param_2,float *param_3)

{
  *param_1 = (param_2[1] * param_3[2] + param_3[3] * *param_2 + param_2[3] * *param_3) -
             param_2[2] * param_3[1];
  param_1[1] = (param_2[2] * *param_3 + param_3[3] * param_2[1] + param_2[3] * param_3[1]) -
               *param_2 * param_3[2];
  param_1[2] = (*param_2 * param_3[1] + param_3[3] * param_2[2] + param_2[3] * param_3[2]) -
               param_2[1] * *param_3;
  param_1[3] = ((param_2[3] * param_3[3] - *param_2 * *param_3) - param_2[1] * param_3[1]) -
               param_2[2] * param_3[2];
  return param_1;
}



/* @00409e28 file=? name=FUN_00409e28 */

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

float * __cdecl FUN_00409e28(float *param_1,float *param_2,float param_3)

{
  float10 fVar1;
  float local_20;
  float local_1c;
  float local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  fVar1 = FUN_004dd138((double)(param_2[2] * param_2[2] +
                               param_2[1] * param_2[1] + *param_2 * *param_2));
  local_c = (float)fVar1;
  local_8 = local_c;
  fVar1 = FUN_004dcd00((double)local_c);
  if ((float10)_DAT_00409f1c < fVar1) {
    local_18 = param_2[3];
    local_1c = local_8;
    local_14 = local_8;
    local_10 = local_18;
    fVar1 = FUN_004dc8ec((double)local_8,SUB84((double)local_18,0),
                         (uint)((ulonglong)(double)local_18 >> 0x20));
    local_20 = param_3 * (float)fVar1;
    FUN_00408328(&local_14,&local_20);
    param_1[3] = local_10;
    local_14 = local_14 / local_8;
    *param_1 = *param_2 * local_14;
    param_1[1] = param_2[1] * local_14;
    param_1[2] = param_2[2] * local_14;
  }
  else {
    FUN_00409968(param_1,&DAT_004e0fa4);
  }
  return param_1;
}



/* @00409f58 file=? name=FUN_00409f58 */

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

void __cdecl FUN_00409f58(float *param_1,float *param_2,float *param_3)

{
  float10 fVar1;
  float local_2c [4];
  float local_1c;
  float local_18;
  float local_14;
  undefined4 local_10;
  float local_c;
  float local_8;
  
  fVar1 = FUN_004dd138((double)(param_3[2] * param_3[2] +
                               param_3[1] * param_3[1] + *param_3 * *param_3));
  local_c = (float)fVar1;
  local_8 = local_c;
  fVar1 = FUN_004dcd00((double)local_c);
  if ((float10)_DAT_0040a040 < fVar1) {
    fVar1 = FUN_00408110(local_8);
    local_1c = (float)(fVar1 * (float10)_DAT_0040a044);
    local_18 = local_1c;
    FUN_00408328(&local_14,&local_1c);
    local_8 = local_14 / local_8;
    FUN_00409948(local_2c,*param_3 * local_8,param_3[1] * local_8,param_3[2] * local_8,local_10);
    FUN_00409d9c(param_1,param_2,local_2c);
  }
  else {
    FUN_00409968(param_1,param_2);
  }
  return;
}



/* @0040a048 file=? name=FUN_0040a048 */

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

void __cdecl FUN_0040a048(float *param_1,float *param_2,float *param_3,float param_4)

{
  float10 fVar1;
  float local_2c [4];
  float local_1c;
  float local_18;
  float local_14;
  undefined4 local_10;
  float local_c;
  float local_8;
  
  fVar1 = FUN_004dd138((double)(param_3[2] * param_3[2] +
                               param_3[1] * param_3[1] + *param_3 * *param_3));
  local_c = (float)fVar1;
  local_8 = local_c;
  fVar1 = FUN_004dcd00((double)local_c);
  if ((float10)_DAT_0040a130 < fVar1) {
    local_8 = param_4 * local_8;
    local_1c = _DAT_0040a134 * local_8;
    local_18 = local_1c;
    FUN_00408328(&local_14,&local_1c);
    local_8 = local_14 / local_8;
    FUN_00409948(local_2c,*param_3 * local_8,param_3[1] * local_8,param_3[2] * local_8,local_10);
    FUN_00409d9c(param_1,param_2,local_2c);
  }
  else {
    FUN_00409968(param_1,param_2);
  }
  return;
}



/* @0040a138 file=? name=FUN_0040a138 */

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

float * __cdecl FUN_0040a138(float *param_1)

{
  float fVar1;
  float10 fVar2;
  
  fVar1 = param_1[2] * param_1[2] + param_1[1] * param_1[1] + *param_1 * *param_1;
  if (_DAT_0040a1e4 < fVar1) {
    fVar2 = FUN_004dd138((double)fVar1);
    fVar1 = (float)fVar2;
    *param_1 = *param_1 / fVar1;
    param_1[1] = param_1[1] / fVar1;
    param_1[2] = param_1[2] / fVar1;
    param_1[3] = 0.0;
  }
  else {
    fVar2 = FUN_004dd138((double)(_DAT_0040a1e4 - fVar1));
    if (param_1[3] < _DAT_0040a1e8) {
      *param_1 = -*param_1;
      param_1[1] = -param_1[1];
      param_1[2] = -param_1[2];
    }
    param_1[3] = (float)fVar2;
  }
  return param_1;
}



/* @0040a22c file=? name=FUN_0040a22c */

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

float * __cdecl FUN_0040a22c(float *param_1,float *param_2,float *param_3)

{
  float fVar1;
  int iVar2;
  float *pfVar3;
  float10 fVar4;
  float local_3c [3];
  float local_30 [4];
  float local_20;
  float local_1c;
  int local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  local_10 = param_3[2] * param_2[2] + param_3[1] * param_2[1] + *param_3 * *param_2;
  local_8 = local_10;
  fVar4 = FUN_004dcd00((double)(local_10 - _DAT_0040a484));
  if ((float10)_DAT_0040a488 < fVar4) {
    local_14 = local_8;
    fVar4 = FUN_004dcd00((double)(local_8 - _DAT_0040a48c));
    if ((float10)_DAT_0040a488 < fVar4) {
      FUN_0040866c(local_30,param_3,param_2);
      fVar4 = FUN_004dd138((double)(local_30[2] * local_30[2] +
                                   local_30[1] * local_30[1] + local_30[0] * local_30[0]));
      local_30[3] = (float)fVar4;
      local_c = local_30[3];
      FUN_004086f8(local_30,local_30,local_30[3]);
      fVar4 = FUN_004dd138((double)((_DAT_0040a484 - local_8) * _DAT_0040a494));
      local_c = (float)fVar4;
      *param_1 = local_30[0] * local_c;
      param_1[1] = local_30[1] * local_c;
      param_1[2] = local_30[2] * local_c;
      fVar4 = FUN_004dd138((double)((_DAT_0040a484 + local_8) * _DAT_0040a494));
      param_1[3] = (float)fVar4;
    }
    else {
      local_18 = 0;
      local_1c = 2.0;
      iVar2 = 0;
      pfVar3 = param_3;
      do {
        if (*pfVar3 <= _DAT_0040a490) {
          fVar1 = -*pfVar3;
        }
        else {
          fVar1 = *pfVar3;
        }
        if (fVar1 < local_1c) {
          local_18 = iVar2;
          if (*pfVar3 <= _DAT_0040a490) {
            local_1c = -*pfVar3;
          }
          else {
            local_1c = *pfVar3;
          }
        }
        iVar2 = iVar2 + 1;
        pfVar3 = pfVar3 + 1;
      } while (iVar2 < 3);
      local_30[0] = 0.0;
      local_30[1] = 0.0;
      local_30[2] = 0.0;
      local_30[local_18] = 1.0;
      local_20 = local_1c;
      fVar4 = FUN_004dcd00((double)local_1c);
      if ((float10)_DAT_0040a488 < fVar4) {
        FUN_004086ac(local_3c,param_3,
                     param_3[2] * local_30[2] + param_3[1] * local_30[1] + *param_3 * local_30[0]);
        FUN_00408644(local_30,local_30,local_3c);
        FUN_004087f4(local_30,local_30);
      }
      *param_1 = local_30[0];
      param_1[1] = local_30[1];
      param_1[2] = local_30[2];
      param_1[3] = 0.0;
    }
  }
  else {
    *param_1 = 0.0;
    param_1[1] = 0.0;
    param_1[2] = 0.0;
    param_1[3] = 1.0;
  }
  return param_1;
}



/* @0040a4d8 file=? name=FUN_0040a4d8 */

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

float * __cdecl FUN_0040a4d8(float *param_1,float *param_2,float *param_3,float param_4)

{
  float fVar1;
  float10 fVar2;
  
  if (param_2[3] * param_3[3] +
      param_2[2] * param_3[2] + param_2[1] * param_3[1] + *param_2 * *param_3 < _DAT_0040a670) {
    *param_1 = -*param_3 * param_4 + (_DAT_0040a674 - param_4) * *param_2;
    param_1[1] = -param_3[1] * param_4 + (_DAT_0040a674 - param_4) * param_2[1];
    param_1[2] = -param_3[2] * param_4 + (_DAT_0040a674 - param_4) * param_2[2];
    param_1[3] = -param_3[3] * param_4 + (_DAT_0040a674 - param_4) * param_2[3];
  }
  else {
    *param_1 = *param_3 * param_4 + (_DAT_0040a674 - param_4) * *param_2;
    param_1[1] = param_3[1] * param_4 + (_DAT_0040a674 - param_4) * param_2[1];
    param_1[2] = param_3[2] * param_4 + (_DAT_0040a674 - param_4) * param_2[2];
    param_1[3] = param_3[3] * param_4 + (_DAT_0040a674 - param_4) * param_2[3];
  }
  fVar1 = param_1[3] * param_1[3] +
          param_1[2] * param_1[2] + param_1[1] * param_1[1] + *param_1 * *param_1;
  fVar2 = FUN_004dcd00((double)fVar1);
  if ((float10)_DAT_0040a678 < fVar2) {
    fVar2 = FUN_004dd138((double)fVar1);
    fVar1 = (float)((float10)_DAT_0040a674 / fVar2);
    *param_1 = fVar1 * *param_1;
    param_1[1] = fVar1 * param_1[1];
    param_1[2] = fVar1 * param_1[2];
    param_1[3] = fVar1 * param_1[3];
  }
  else {
    *param_1 = 0.0;
    param_1[1] = 0.0;
    param_1[2] = 0.0;
    param_1[3] = 1.0;
  }
  return param_1;
}



/* @0040a738 file=? name=FUN_0040a738 */

undefined4 FUN_0040a738(void)

{
  return 1;
}



/* @0040a7c0 file=? name=FUN_0040a7c0 */

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

{
  FUN_00408440(param_1 + 3,param_2 + 3);
  FUN_00408440(param_1,param_2);
  return param_1;
}



/* @0040a7f4 file=? name=FUN_0040a7f4 */

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

{
  FUN_00408440(param_1 + 3,param_2 + 3);
  FUN_00408440(param_1,param_2);
  return param_1;
}



/* @0040a824 file=? name=FUN_0040a824 */

bool __cdecl FUN_0040a824(byte *param_1,byte *param_2)

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



/* @0040a848 file=? name=FUN_0040a848 */

float * __cdecl FUN_0040a848(float *param_1,float *param_2,float *param_3,float param_4)

{
  FUN_00408614(param_1,param_2,param_3,param_4);
  FUN_00408614(param_1 + 3,param_2 + 3,param_3 + 3,param_4);
  return param_1;
}



/* @0040a884 file=? name=FUN_0040a884 */

void __cdecl FUN_0040a884(int *param_1,float *param_2)

{
  int *piVar1;
  byte bVar2;
  float *pfVar3;
  byte bVar4;
  
  bVar4 = 0x7d;
  pfVar3 = param_2 + 3;
  bVar2 = 0x2c;
  piVar1 = FUN_004db92c(param_1,0x7b);
  piVar1 = (int *)FUN_00408888(piVar1,param_2);
  piVar1 = FUN_004db92c(piVar1,bVar2);
  piVar1 = (int *)FUN_00408888(piVar1,pfVar3);
  FUN_004db92c(piVar1,bVar4);
  return;
}



/* @0040a8cc file=? name=FUN_0040a8cc */

void FUN_0040a8cc(void)

{
  FUN_004085bc();
  return;
}



/* @0040a938 file=? name=FUN_0040a938 */

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

{
  FUN_00409968(param_1 + 3,param_2 + 3);
  FUN_00408440(param_1,param_2);
  return param_1;
}



/* @0040a968 file=? name=FUN_0040a968 */

undefined4 * __cdecl FUN_0040a968(undefined4 *param_1,float *param_2)

{
  FUN_00409a70((float *)(param_1 + 3),param_2);
  FUN_0040b058((int)param_2,3,param_1);
  return param_1;
}



/* @0040a994 file=? name=FUN_0040a994 */

bool __cdecl FUN_0040a994(byte *param_1,byte *param_2)

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



/* @0040a9b8 file=? name=FUN_0040a9b8 */

float * __cdecl FUN_0040a9b8(float *param_1,float *param_2,float *param_3,float param_4)

{
  FUN_00408614(param_1,param_2,param_3,param_4);
  FUN_0040a048(param_1 + 3,param_2 + 3,param_3 + 3,param_4);
  return param_1;
}



/* @0040a9f4 file=? name=FUN_0040a9f4 */

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

float * __cdecl FUN_0040a9f4(float *param_1,float *param_2,float *param_3,float param_4)

{
  FUN_00408848(param_1,param_2,_DAT_0040aa54 - param_4,param_3,param_4);
  FUN_0040a4d8(param_1 + 3,param_2 + 3,param_3 + 3,param_4);
  return param_1;
}



/* @0040aaa0 file=? name=FUN_0040aaa0 */

void FUN_0040aaa0(void)

{
  FUN_0040a738();
  return;
}



/* @0040aadc file=? name=FUN_0040aadc */

void __cdecl FUN_0040aadc(undefined4 *param_1)

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



/* @0040ab28 file=? name=FUN_0040ab28 */

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

{
  FUN_004d4918(param_1,param_2,0x30);
  return param_1;
}



/* @0040ab44 file=? name=FUN_0040ab44 */

float * __cdecl FUN_0040ab44(float *param_1,undefined4 *param_2)

{
  FUN_0040adec(param_1,(float *)(param_2 + 3));
  FUN_0040b0ac((int)param_1,3,param_2);
  return param_1;
}



/* @0040ab70 file=? name=FUN_0040ab70 */

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

{
  int iVar1;
  float local_1c;
  undefined4 local_18;
  float local_14;
  undefined4 local_10;
  float local_c;
  undefined4 local_8;
  
  iVar1 = *param_2;
  if (iVar1 == 0) {
    FUN_00408328(&local_c,(float *)(param_2 + 1));
    *param_1 = 0x3f800000;
    param_1[4] = 0;
    param_1[8] = 0;
    param_1[1] = 0;
    param_1[5] = local_8;
    param_1[9] = -local_c;
    param_1[2] = 0;
    param_1[6] = local_c;
    param_1[10] = local_8;
  }
  else if (iVar1 == 1) {
    FUN_00408328(&local_14,(float *)(param_2 + 1));
    *param_1 = local_10;
    param_1[4] = 0;
    param_1[8] = local_14;
    param_1[1] = 0;
    param_1[5] = 0x3f800000;
    param_1[9] = 0;
    param_1[2] = -local_14;
    param_1[6] = 0;
    param_1[10] = local_10;
  }
  else if (iVar1 == 2) {
    FUN_00408328(&local_1c,(float *)(param_2 + 1));
    *param_1 = local_18;
    param_1[4] = -local_1c;
    param_1[8] = 0;
    param_1[1] = local_1c;
    param_1[5] = local_18;
    param_1[9] = 0;
    param_1[2] = 0;
    param_1[6] = 0;
    param_1[10] = 0x3f800000;
  }
  return param_1;
}



/* @0040ac6c file=? name=FUN_0040ac6c */

float * __cdecl FUN_0040ac6c(float *param_1,float *param_2)

{
  float local_1c;
  float local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  FUN_00408328(&local_c,param_2);
  FUN_00408328(&local_14,param_2 + 1);
  FUN_00408328(&local_1c,param_2 + 2);
  *param_1 = local_10 * local_18;
  param_1[4] = local_10 * local_1c;
  param_1[8] = -local_14;
  param_1[1] = local_c * local_14 * local_18 - local_8 * local_1c;
  param_1[5] = local_8 * local_18 + local_c * local_14 * local_1c;
  param_1[9] = local_c * local_10;
  param_1[2] = local_c * local_1c + local_8 * local_14 * local_18;
  param_1[6] = local_8 * local_14 * local_1c - local_c * local_18;
  param_1[10] = local_8 * local_10;
  return param_1;
}



/* @0040ad2c file=? name=FUN_0040ad2c */

float * __cdecl FUN_0040ad2c(float *param_1,float *param_2)

{
  float local_1c;
  float local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  FUN_00408328(&local_c,param_2 + 1);
  FUN_00408328(&local_14,param_2);
  FUN_00408328(&local_1c,param_2 + 2);
  *param_1 = local_c * local_14 * local_1c + local_10 * local_18;
  param_1[4] = local_8 * local_1c;
  param_1[8] = local_c * local_10 * local_1c - local_14 * local_18;
  param_1[1] = local_c * local_14 * local_18 - local_10 * local_1c;
  param_1[5] = local_8 * local_18;
  param_1[9] = local_c * local_10 * local_18 + local_14 * local_1c;
  param_1[2] = local_8 * local_14;
  param_1[6] = -local_c;
  param_1[10] = local_8 * local_10;
  return param_1;
}



/* @0040adec file=? name=FUN_0040adec */

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

float * __cdecl FUN_0040adec(float *param_1,float *param_2)

{
  float fVar1;
  float fVar2;
  float fVar3;
  float fVar4;
  float fVar5;
  float fVar6;
  float fVar7;
  float fVar8;
  float fVar9;
  float fVar10;
  float fVar11;
  float fVar12;
  float fVar13;
  float fVar14;
  float fVar15;
  float fVar16;
  
  fVar1 = *param_2;
  fVar2 = param_2[1];
  fVar3 = param_2[1];
  fVar4 = param_2[2];
  fVar5 = param_2[2];
  fVar6 = *param_2;
  fVar7 = param_2[3];
  fVar8 = *param_2;
  fVar9 = param_2[3];
  fVar10 = param_2[1];
  fVar11 = param_2[3];
  fVar12 = param_2[2];
  fVar13 = param_2[3] * param_2[3];
  fVar14 = *param_2 * *param_2;
  fVar15 = param_2[1] * param_2[1];
  fVar16 = param_2[2] * param_2[2];
  *param_1 = ((fVar13 + fVar14) - fVar15) - fVar16;
  param_1[1] = (fVar1 * fVar2 - fVar11 * fVar12) * _DAT_0040aedc;
  param_1[2] = (fVar5 * fVar6 + fVar9 * fVar10) * _DAT_0040aedc;
  param_1[4] = (fVar11 * fVar12 + fVar1 * fVar2) * _DAT_0040aedc;
  param_1[5] = ((fVar13 - fVar14) + fVar15) - fVar16;
  param_1[6] = (fVar3 * fVar4 - fVar7 * fVar8) * _DAT_0040aedc;
  param_1[8] = (fVar5 * fVar6 - fVar9 * fVar10) * _DAT_0040aedc;
  param_1[9] = (fVar3 * fVar4 + fVar7 * fVar8) * _DAT_0040aedc;
  param_1[10] = ((fVar13 - fVar14) - fVar15) + fVar16;
  return param_1;
}



