// Decompiled from acclient.exe — chunk 0x00680000
// Ghidra 12.0.4 + pyghidra headless

// --- thunk_FUN_0067fac0 at 0x00680010 (size: 5) ---


uint thunk_FUN_0067fac0(void)



{

  int iVar1;

  ushort uVar2;

  short sVar3;

  uint uVar4;

  undefined *puVar5;

  char cVar6;

  LONG LVar7;

  uint uVar8;

  int iVar9;

  undefined4 uVar10;

  short *psVar11;

  short *psVar12;

  undefined2 *puVar13;

  ushort *puVar14;

  uint uVar15;

  uint uStack_c;

  uint uStack_8;

  uint uStack_4;

  

  puVar5 = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  uVar4 = *(uint *)(DAT_008f8990 + -4);

  uVar15 = uVar4 - 1;

  uStack_4 = uVar15;

  if (uVar15 <= DAT_008f8928) {

    LVar7 = InterlockedDecrement((LONG *)(puVar5 + -0x10));

    if ((LVar7 == 0) && ((undefined4 *)(puVar5 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(puVar5 + -0x14))(1);

    }

    return 0xffffffff;

  }

  psVar11 = (short *)(DAT_008f8990 + -2 + uVar4 * 2);

  if (DAT_008f8928 < uVar4) {

    psVar11 = (short *)(DAT_008f8990 + DAT_008f8928 * 2);

  }

  if (*psVar11 != 1) {

    psVar11 = (short *)(DAT_008f8990 + -2 + uVar4 * 2);

    if (DAT_008f8928 < uVar4) {

      psVar11 = (short *)(DAT_008f8990 + DAT_008f8928 * 2);

    }

    if (*psVar11 == 0x7b) {

      psVar11 = (short *)(DAT_008f8990 + -2 + uVar4 * 2);

      if (DAT_008f8928 + 1 < uVar4) {

        psVar11 = (short *)(DAT_008f8990 + (DAT_008f8928 + 1) * 2);

      }

      if ((*psVar11 == 0x7b) && (cVar6 = FUN_0067e6a0(), cVar6 == '\0')) {

        uVar4 = *(uint *)(DAT_008f8990 + -4);

        uVar8 = DAT_008f8928 + 2;

        uVar15 = DAT_008f8928 + 3;

        psVar11 = (short *)(DAT_008f8990 + uVar8 * 2);

        DAT_008f8928 = uVar8;

        do {

          psVar12 = (short *)(DAT_008f8990 + -2 + uVar4 * 2);

          if (DAT_008f8928 < uVar4) {

            psVar12 = psVar11;

          }

          if (*psVar12 == 0x7d) {

            psVar12 = (short *)(DAT_008f8990 + -2 + uVar4 * 2);

            if (uVar15 < uVar4) {

              psVar12 = psVar11 + 1;

            }

            if (*psVar12 == 0x7d) {

LAB_0067fc58:

              FUN_0040b220();

              iVar9 = DAT_008f8928 - uVar8;

              if (iVar9 != 0) {

                uVar10 = FUN_004075c0(uVar8);

                FUN_00402490(uVar10,iVar9);

              }

              uVar15 = DAT_008f8928;

              psVar11 = (short *)FUN_004075c0(DAT_008f8928);

              if ((*psVar11 == 0x7d) &&

                 (psVar11 = (short *)FUN_004075c0(uVar15 + 1), *psVar11 == 0x7d)) {

                DAT_008f8928 = uVar15 + 2;

              }

              FUN_004011b0();

              return 0x105;

            }

          }

          psVar12 = (short *)(DAT_008f8990 + -2 + uVar4 * 2);

          if (DAT_008f8928 < uVar4) {

            psVar12 = psVar11;

          }

          if (*psVar12 == 0) goto LAB_0067fc58;

          DAT_008f8928 = DAT_008f8928 + 1;

          uVar15 = uVar15 + 1;

          psVar11 = psVar11 + 1;

        } while( true );

      }

    }

    cVar6 = FUN_0067f5e0();

    if (cVar6 != '\0') {

      if (DAT_008f8928 < *(uint *)(DAT_008f8990 + -4)) {

        puVar14 = (ushort *)(DAT_008f8990 + DAT_008f8928 * 2);

      }

      else {

        puVar14 = (ushort *)(DAT_008f8990 + -2 + *(uint *)(DAT_008f8990 + -4) * 2);

      }

      uVar2 = *puVar14;

      DAT_008f8928 = DAT_008f8928 + 1;

      LVar7 = InterlockedDecrement((LONG *)(puVar5 + -0x10));

      if ((LVar7 == 0) && ((undefined4 *)(puVar5 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(puVar5 + -0x14))(1);

      }

      return (uint)uVar2;

    }

    cVar6 = FUN_0067f630(&uStack_8);

    if (cVar6 != '\0') {

      DAT_008f8928 = uStack_c;

      FUN_0040b220();

      FUN_0047b520(uStack_8);

      FUN_004011b0();

      return 0x103;

    }

    cVar6 = FUN_0067f930(DAT_008f8928);

    if (cVar6 != '\0') {

      DAT_008f8928 = uStack_c;

      FUN_0040b220();

      iVar9 = *(int *)(puVar5 + -4);

      uVar15 = 0;

      if (0 < iVar9 + -1) {

        do {

          uVar4 = *(uint *)(puVar5 + -4);

          iVar1 = uVar4 * 2 + -2;

          if (uVar15 < uVar4) {

            iVar1 = uVar15 * 2;

          }

          if (*(short *)(puVar5 + iVar1) != 0x20) {

            iVar1 = uVar4 * 2 + -2;

            if (uVar15 < uVar4) {

              iVar1 = uVar15 * 2;

            }

            uStack_8 = (uint)*(ushort *)(puVar5 + iVar1);

            FUN_00402490(&uStack_8,1);

          }

          uVar15 = uVar15 + 1;

        } while ((int)uVar15 < iVar9 + -1);

      }

      psVar11 = (short *)(DAT_008f8990 + DAT_008f8928 * 2);

      while( true ) {

        psVar12 = (short *)(DAT_008f8990 + -2 + *(uint *)(DAT_008f8990 + -4) * 2);

        if (DAT_008f8928 < *(uint *)(DAT_008f8990 + -4)) {

          psVar12 = psVar11;

        }

        if ((*psVar12 != 0x20) && (*psVar12 != 9)) break;

        DAT_008f8928 = DAT_008f8928 + 1;

        psVar11 = psVar11 + 1;

      }

      LVar7 = InterlockedDecrement((LONG *)(puVar5 + -0x10));

      if ((LVar7 == 0) && ((undefined4 *)(puVar5 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(puVar5 + -0x14))(1);

      }

      return 0x104;

    }

    FUN_0040b220();

    if (DAT_008f8928 < uVar15) {

      while( true ) {

        uVar15 = *(uint *)(DAT_008f8990 + -4);

        psVar11 = (short *)(DAT_008f8990 + -2 + uVar15 * 2);

        if (DAT_008f8928 < uVar15) {

          psVar11 = (short *)(DAT_008f8990 + DAT_008f8928 * 2);

        }

        if (*psVar11 == 1) break;

        if (DAT_008f8928 < uVar15) {

          psVar11 = (short *)(DAT_008f8990 + DAT_008f8928 * 2);

        }

        else {

          psVar11 = (short *)(DAT_008f8990 + -2 + uVar15 * 2);

        }

        sVar3 = *psVar11;

        cVar6 = FUN_0067e6a0();

        if ((sVar3 == 0x7d) || (sVar3 == 0x7c)) {

          if (cVar6 != '\0') break;

        }

        else if (((sVar3 == 0x7b) || (sVar3 == 0x5e)) && (cVar6 == '\0')) break;

        cVar6 = FUN_0067f630(&uStack_8);

        if ((cVar6 != '\0') || (cVar6 = FUN_0067f930(DAT_008f8928), cVar6 != '\0')) break;

        uVar15 = *(uint *)(DAT_008f8990 + -4);

        psVar11 = (short *)(DAT_008f8990 + -2 + uVar15 * 2);

        if (DAT_008f8928 < uVar15) {

          psVar11 = (short *)(DAT_008f8990 + DAT_008f8928 * 2);

        }

        if (*psVar11 == 0x5c) {

          if (DAT_008f8928 + 1 < uVar15) {

            puVar13 = (undefined2 *)(DAT_008f8990 + (DAT_008f8928 + 1) * 2);

          }

          else {

            puVar13 = (undefined2 *)(DAT_008f8990 + -2 + uVar15 * 2);

          }

          cVar6 = FUN_0067c690(*puVar13);

          if (cVar6 != '\0') {

            DAT_008f8928 = DAT_008f8928 + 1;

            uStack_8 = 0x5c;

            FUN_00402490(&uStack_8,1);

          }

        }

        if (DAT_008f8928 < *(uint *)(DAT_008f8990 + -4)) {

          puVar14 = (ushort *)(DAT_008f8990 + DAT_008f8928 * 2);

        }

        else {

          puVar14 = (ushort *)(DAT_008f8990 + -2 + *(uint *)(DAT_008f8990 + -4) * 2);

        }

        uStack_8 = (uint)*puVar14;

        DAT_008f8928 = DAT_008f8928 + 1;

        FUN_00402490(&uStack_8,1);

        if (uStack_4 <= DAT_008f8928) break;

      }

    }

    FUN_004011b0();

    return 0x101;

  }

  uVar8 = DAT_008f8928 + 1;

  DAT_008f8928 = uVar8;

  if (uVar8 < uVar15) {

    psVar11 = (short *)(DAT_008f8990 + uVar8 * 2);

    do {

      psVar12 = (short *)(DAT_008f8990 + -2 + uVar4 * 2);

      if (DAT_008f8928 < uVar4) {

        psVar12 = psVar11;

      }

      if (*psVar12 == 1) break;

      DAT_008f8928 = DAT_008f8928 + 1;

      psVar11 = psVar11 + 1;

    } while (DAT_008f8928 < uVar15);

  }

  FUN_0040b220();

  if (DAT_008f8928 - uVar8 != 0) {

    if (uVar8 < *(uint *)(DAT_008f8990 + -4)) {

      iVar9 = DAT_008f8990 + uVar8 * 2;

    }

    else {

      iVar9 = DAT_008f8990 + -2 + *(uint *)(DAT_008f8990 + -4) * 2;

    }

    FUN_00402490(iVar9,DAT_008f8928 - uVar8);

  }

  DAT_008f8928 = DAT_008f8928 + 1;

  LVar7 = InterlockedDecrement((LONG *)(puVar5 + -0x10));

  if ((LVar7 == 0) && ((undefined4 *)(puVar5 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(puVar5 + -0x14))(1);

  }

  return 0x102;

}





// --- FUN_00680020 at 0x00680020 (size: 712) ---


void FUN_00680020(int *param_1,int *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  wchar_t *pwVar3;

  bool bVar4;

  undefined *puVar5;

  LONG LVar6;

  int iVar7;

  uint uVar8;

  wchar_t *pwStack_c;

  uint local_8;

  int local_4;

  

  if (DAT_008f8990 != PTR_DAT_00818340) {

    puVar1 = (undefined4 *)(DAT_008f8990 + -0x14);

    LVar6 = InterlockedDecrement((LONG *)(DAT_008f8990 + -0x10));

    if ((LVar6 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    DAT_008f8990 = PTR_DAT_00818340;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  }

  local_8 = 0;

  if (param_1[2] == 0) {

    DAT_008f8928 = 0;

    return;

  }

  do {

    uVar8 = local_8;

    iVar7 = *(int *)(*param_1 + local_8 * 4);

    iVar2 = local_8 * 4;

    local_4 = iVar7;

    InterlockedIncrement((LONG *)(iVar7 + -0x10));

    if (*(int *)(iVar7 + -4) != 1) {

      FUN_00402490(iVar7,*(int *)(iVar7 + -4) + -1);

    }

    puVar5 = DAT_008f8990;

    if (uVar8 < (uint)param_2[2]) {

      pwStack_c = (wchar_t *)0x1;

      iVar7 = *(int *)(DAT_008f8990 + -4);

      if ((*(int *)(DAT_008f8990 + -0x10) == 1) && (iVar7 + 1U <= *(uint *)(DAT_008f8990 + -0xc))) {

        *(uint *)(DAT_008f8990 + -4) = iVar7 + 1U;

        *(undefined4 *)(DAT_008f8990 + -8) = 0xffffffff;

      }

      else {

        puVar1 = (undefined4 *)(DAT_008f8990 + -0x14);

        FUN_004022d0(iVar7);

        wcscpy((wchar_t *)DAT_008f8990,(wchar_t *)puVar5);

        LVar6 = InterlockedDecrement((LONG *)(puVar5 + -0x10));

        if ((LVar6 == 0) && (puVar1 != (undefined4 *)0x0)) {

          (**(code **)*puVar1)(1);

        }

      }

      wcsncpy((wchar_t *)(DAT_008f8990 + iVar7 * 2 + -2),(wchar_t *)&pwStack_c,1);

      *(undefined2 *)(DAT_008f8990 + *(int *)(DAT_008f8990 + -4) * 2 + -2) = 0;

      pwStack_c = (wchar_t *)PTR_DAT_00818340;

      InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

      pwVar3 = *(wchar_t **)(*param_2 + iVar2);

      if (*(int *)(pwVar3 + -2) == *(int *)(pwStack_c + -2)) {

        if ((((*(int *)(pwVar3 + -4) != *(int *)(pwStack_c + -4)) && (*(int *)(pwVar3 + -4) != -1))

            && (*(int *)(pwStack_c + -4) != -1)) || (iVar7 = wcscmp(pwVar3,pwStack_c), iVar7 != 0))

        goto LAB_006801a9;

LAB_006801b8:

        bVar4 = false;

      }

      else {

LAB_006801a9:

        if (*(int *)(*(int *)(*param_2 + iVar2) + -4) == 1) goto LAB_006801b8;

        bVar4 = true;

      }

      pwVar3 = pwStack_c + -10;

      LVar6 = InterlockedDecrement((LONG *)(pwStack_c + -8));

      if ((LVar6 == 0) && (pwVar3 != (wchar_t *)0x0)) {

        (*(code *)**(undefined4 **)pwVar3)(1);

      }

      if (bVar4) {

        iVar7 = *(int *)(*(int *)(*param_2 + iVar2) + -4);

        if (iVar7 != 1) {

          FUN_00402490(*(int *)(*param_2 + iVar2),iVar7 + -1);

        }

      }

      puVar5 = DAT_008f8990;

      pwStack_c = (wchar_t *)0x1;

      iVar2 = *(int *)(DAT_008f8990 + -4);

      if ((*(int *)(DAT_008f8990 + -0x10) == 1) && (iVar2 + 1U <= *(uint *)(DAT_008f8990 + -0xc))) {

        *(uint *)(DAT_008f8990 + -4) = iVar2 + 1U;

        *(undefined4 *)(DAT_008f8990 + -8) = 0xffffffff;

      }

      else {

        puVar1 = (undefined4 *)(DAT_008f8990 + -0x14);

        FUN_004022d0(iVar2);

        wcscpy((wchar_t *)DAT_008f8990,(wchar_t *)puVar5);

        LVar6 = InterlockedDecrement((LONG *)(puVar5 + -0x10));

        if ((LVar6 == 0) && (puVar1 != (undefined4 *)0x0)) {

          (**(code **)*puVar1)(1);

        }

      }

      wcsncpy((wchar_t *)(DAT_008f8990 + iVar2 * 2 + -2),(wchar_t *)&pwStack_c,1);

      *(undefined2 *)(DAT_008f8990 + *(int *)(DAT_008f8990 + -4) * 2 + -2) = 0;

      iVar7 = local_4;

      uVar8 = local_8;

    }

    LVar6 = InterlockedDecrement((LONG *)(iVar7 + -0x10));

    if ((LVar6 == 0) && ((undefined4 *)(iVar7 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(iVar7 + -0x14))(1);

    }

    local_8 = uVar8 + 1;

    if ((uint)param_1[2] <= local_8) {

      DAT_008f8928 = 0;

      return;

    }

  } while( true );

}





// --- FUN_006802f0 at 0x006802F0 (size: 64) ---


undefined4 * __thiscall FUN_006802f0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007ff7b8;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00680330 at 0x00680330 (size: 189) ---


void __thiscall FUN_00680330(undefined4 *param_1,int param_2)



{

  undefined4 *puVar1;

  

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      *param_1 = *puVar1;

    }

    else {

      *puVar1 = *param_1;

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      param_1[1] = *puVar1;

    }

    else {

      *puVar1 = param_1[1];

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      param_1[2] = *puVar1;

    }

    else {

      *puVar1 = param_1[2];

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      param_1[3] = *puVar1;

    }

    else {

      *puVar1 = param_1[3];

    }

  }

  FUN_004227d0(param_2);

  FUN_00430110(param_2);

  return;

}





// --- FUN_006803f0 at 0x006803F0 (size: 143) ---


undefined4 * __thiscall FUN_006803f0(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007ff7b8;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_00680480 at 0x00680480 (size: 271) ---


void __fastcall FUN_00680480(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  LONG LVar4;

  int *piVar5;

  void *pvVar6;

  undefined4 *puVar7;

  int iVar8;

  int local_8;

  

  iVar1 = *(int *)(param_1 + 0x6c);

  do {

    if (iVar1 == 0) {

      return;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar5 = *(int **)(param_1 + 100);

        pvVar6 = (void *)*piVar5;

        goto LAB_006804c1;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    piVar5 = (int *)0x0;

    pvVar6 = (void *)0x0;

LAB_006804c1:

    pvVar3 = (void *)*piVar5;

    if (pvVar3 == pvVar6) {

LAB_006804d4:

      *piVar5 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 4);

      } while (pvVar3 != pvVar6);

      if (pvVar2 == (void *)0x0) goto LAB_006804d4;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    if (pvVar6 != (void *)0x0) {

      if (((*(uint *)((int)pvVar6 + 0x20) & 0x80000000) == 0x80000000) &&

         (iVar1 = *(int *)((int)pvVar6 + 0x1c), iVar1 != 0)) {

        local_8 = *(int *)(iVar1 + -4);

        iVar8 = iVar1 + local_8 * 4;

        if (-1 < local_8 + -1) {

          do {

            piVar5 = (int *)(iVar8 + -4);

            iVar8 = iVar8 + -4;

            puVar7 = (undefined4 *)(*piVar5 + -0x14);

            LVar4 = InterlockedDecrement((LONG *)(*piVar5 + -0x10));

            if ((LVar4 == 0) && (puVar7 != (undefined4 *)0x0)) {

              (**(code **)*puVar7)(1);

            }

            local_8 = local_8 + -1;

          } while (local_8 != 0);

        }

        operator_delete__((void *)(iVar1 + -4));

      }

      puVar7 = (undefined4 *)(*(int *)((int)pvVar6 + 0x18) + -0x14);

      LVar4 = InterlockedDecrement((LONG *)(*(int *)((int)pvVar6 + 0x18) + -0x10));

      if ((LVar4 == 0) && (puVar7 != (undefined4 *)0x0)) {

        (**(code **)*puVar7)(1);

      }

      operator_delete(pvVar6);

    }

    iVar1 = *(int *)(param_1 + 0x6c);

  } while( true );

}





// --- FUN_006805a0 at 0x006805A0 (size: 58) ---


void __fastcall FUN_006805a0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007ff7bc;

  FUN_00680480();

  param_1[1] = &PTR_FUN_007ff7b8;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  return;

}





// --- FUN_006805e0 at 0x006805E0 (size: 82) ---


undefined4 * __thiscall FUN_006805e0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007ff7bc;

  FUN_00680480();

  param_1[1] = &PTR_FUN_007ff7b8;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00680640 at 0x00680640 (size: 41) ---


undefined4 * __fastcall FUN_00680640(undefined4 *param_1)



{

  FUN_00415460(DAT_008f89ac);

  *param_1 = &PTR_LAB_007ff7c0;

  param_1[0xc] = &PTR_FUN_007ff7bc;

  FUN_006803f0(0x17);

  return param_1;

}





// --- FUN_00680690 at 0x00680690 (size: 40) ---


void * __thiscall FUN_00680690(void *param_1,byte param_2)



{

  FUN_006805a0();

  FUN_004154b0();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_006806c0 at 0x006806C0 (size: 573) ---


void FUN_006806c0(undefined4 param_1,int param_2,uint param_3)



{

  int iVar1;

  undefined *puVar2;

  undefined *puVar3;

  uint uVar4;

  char cVar5;

  undefined *puVar6;

  byte *pbVar7;

  int *piVar8;

  undefined4 *puVar9;

  LONG *lpAddend;

  undefined4 *puVar10;

  uint uVar11;

  undefined4 *puVar12;

  uint local_10;

  undefined1 local_c [12];

  

  uVar4 = param_3;

  if ((~*(byte *)(param_3 + 4) & 1) != 0) {

    FUN_005c2c80();

  }

  puVar3 = PTR_DAT_00818558;

  puVar2 = PTR_DAT_00818554;

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x68);

    puVar6 = (undefined *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_3,param_3,0);

    if (puVar6 == puVar3) {

      puVar6 = puVar6 + -4;

    }

    uVar11 = (int)puVar6 - (int)puVar2 >> 2;

  }

  else {

    uVar11 = param_3 & 0xff;

  }

  FUN_0040ad10(1);

  pbVar7 = (byte *)FUN_0040acf0(1);

  if (pbVar7 != (byte *)0x0) {

    if ((*(byte *)(uVar4 + 4) & 1) == 0) {

      uVar11 = (uint)*pbVar7;

    }

    else {

      *pbVar7 = (byte)uVar11;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    if ((uVar11 & 0xff) < DAT_007956cc) {

      FUN_0042ab60(*(undefined4 *)(PTR_DAT_00818554 + (uVar11 & 0xff) * 4));

    }

    else {

      FUN_0040aa50();

    }

  }

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x6c);

  }

  FUN_00401a80(&param_3,&param_3,uVar4);

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    piVar8 = (int *)FUN_0052dcf0(local_c);

    iVar1 = *piVar8;

    puVar12 = (undefined4 *)piVar8[1];

    puVar9 = (undefined4 *)piVar8[2];

LAB_006807c4:

    puVar10 = puVar9;

    if (puVar9 != (undefined4 *)0x0) {

      do {

        FUN_0040ad10(4);

        puVar9 = (undefined4 *)FUN_0040acf0(4);

        if (puVar9 != (undefined4 *)0x0) {

          if ((*(byte *)(uVar4 + 4) & 1) == 0) {

            *puVar10 = *puVar9;

          }

          else {

            *puVar9 = *puVar10;

          }

        }

        FUN_00680330(uVar4);

        puVar10 = (undefined4 *)puVar10[1];

      } while (puVar10 != (undefined4 *)0x0);

      do {

        puVar12 = puVar12 + 1;

        puVar9 = puVar10;

        if (puVar12 == (undefined4 *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) break;

        puVar9 = (undefined4 *)*puVar12;

      } while (puVar9 == (undefined4 *)0x0);

      goto LAB_006807c4;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    uVar11 = FUN_0040a8f0();

    if (uVar11 < param_3) {

LAB_006808ee:

      FUN_0040aa50();

    }

    else {

      local_10 = 0;

      puVar12 = (undefined4 *)0x0;

      if (param_3 != 0) {

        while( true ) {

          puVar9 = (undefined4 *)FUN_005df0f5(0x28);

          if (puVar9 == (undefined4 *)0x0) {

            puVar9 = (undefined4 *)0x0;

          }

          else {

            puVar9[1] = 0;

            puVar9[2] = 0;

            puVar9[3] = 0;

            puVar9[4] = 0;

            puVar9[5] = 0;

            lpAddend = (LONG *)(PTR_DAT_00818340 + -0x10);

            puVar9[6] = PTR_DAT_00818340;

            InterlockedIncrement(lpAddend);

            puVar9[7] = 0;

            puVar9[8] = 0;

            puVar9[9] = 0;

          }

          FUN_0040ad10(4);

          puVar10 = (undefined4 *)FUN_0040acf0(4);

          if (puVar10 != (undefined4 *)0x0) {

            if ((*(byte *)(uVar4 + 4) & 1) == 0) {

              *puVar9 = *puVar10;

            }

            else {

              *puVar10 = *puVar9;

            }

          }

          FUN_00680330(uVar4);

          if ((*(uint *)(uVar4 + 4) >> 2 & 1) != 0) break;

          cVar5 = FUN_00599310(puVar9,puVar12);

          if (cVar5 == '\0') goto LAB_006808ee;

          local_10 = local_10 + 1;

          puVar12 = puVar9;

          if (param_3 <= local_10) {

            return;

          }

        }

      }

    }

  }

  return;

}





// --- FUN_00680940 at 0x00680940 (size: 62) ---


int FUN_00680940(int param_1,int param_2,int param_3)



{

  int iVar1;

  

  iVar1 = param_2 - param_1 >> 3;

  if (iVar1 < 1) {

    return param_3;

  }

  do {

    param_2 = param_2 + -8;

    param_3 = param_3 + -8;

    FUN_00429ab0(param_2);

    iVar1 = iVar1 + -1;

  } while (iVar1 != 0);

  return param_3;

}





// --- FUN_00680980 at 0x00680980 (size: 259) ---


bool FUN_00680980(undefined4 param_1,undefined4 param_2)



{

  char cVar1;

  int iVar2;

  LONG LVar3;

  char *pcVar4;

  char *local_8;

  char *local_4;

  

  local_4 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  local_8 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  cVar1 = FUN_00426910(param_1,&local_4);

  if (cVar1 != '\0') {

    cVar1 = FUN_00426910(param_2,&local_8);

    if (cVar1 != '\0') {

      iVar2 = _stricmp(local_4,local_8);

      pcVar4 = local_8 + -0x14;

      LVar3 = InterlockedDecrement((LONG *)(local_8 + -0x10));

      if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

        (*(code *)**(undefined4 **)pcVar4)(1);

      }

      pcVar4 = local_4 + -0x14;

      LVar3 = InterlockedDecrement((LONG *)(local_4 + -0x10));

      if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

        (*(code *)**(undefined4 **)pcVar4)(1);

      }

      return iVar2 < 0;

    }

  }

  pcVar4 = local_8 + -0x14;

  LVar3 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

    (*(code *)**(undefined4 **)pcVar4)(1);

  }

  pcVar4 = local_4 + -0x14;

  LVar3 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

    (*(code *)**(undefined4 **)pcVar4)(1);

  }

  return false;

}





// --- FUN_00680a90 at 0x00680A90 (size: 251) ---


bool FUN_00680a90(void)



{

  char cVar1;

  int iVar2;

  LONG LVar3;

  char *pcVar4;

  char *local_8;

  char *local_4;

  

  local_4 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  local_8 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  cVar1 = FUN_00429a20(&local_4);

  if (cVar1 != '\0') {

    cVar1 = FUN_00429a20(&local_8);

    if (cVar1 != '\0') {

      iVar2 = _stricmp(local_4,local_8);

      pcVar4 = local_8 + -0x14;

      LVar3 = InterlockedDecrement((LONG *)(local_8 + -0x10));

      if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

        (*(code *)**(undefined4 **)pcVar4)(1);

      }

      pcVar4 = local_4 + -0x14;

      LVar3 = InterlockedDecrement((LONG *)(local_4 + -0x10));

      if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

        (*(code *)**(undefined4 **)pcVar4)(1);

      }

      return iVar2 < 0;

    }

  }

  pcVar4 = local_8 + -0x14;

  LVar3 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

    (*(code *)**(undefined4 **)pcVar4)(1);

  }

  pcVar4 = local_4 + -0x14;

  LVar3 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

    (*(code *)**(undefined4 **)pcVar4)(1);

  }

  return false;

}





// --- FUN_00680b90 at 0x00680B90 (size: 130) ---


undefined4 * FUN_00680b90(undefined4 *param_1,undefined4 *param_2,undefined4 *param_3)



{

  char cVar1;

  

  cVar1 = FUN_00680980(*param_1,*param_2);

  if (cVar1 == '\0') {

    cVar1 = FUN_00680980(*param_1,*param_3);

    if (cVar1 != '\0') {

      return param_1;

    }

    cVar1 = FUN_00680980(*param_2,*param_3);

    if (cVar1 != '\0') {

      return param_3;

    }

  }

  else {

    cVar1 = FUN_00680980(*param_2,*param_3);

    if (cVar1 == '\0') {

      cVar1 = FUN_00680980(*param_1,*param_3);

      if (cVar1 == '\0') {

        return param_1;

      }

      return param_3;

    }

  }

  return param_2;

}





// --- FUN_00680c20 at 0x00680C20 (size: 121) ---


undefined4 * FUN_00680c20(undefined4 *param_1,undefined4 *param_2,undefined4 param_3)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  char cVar3;

  

  while( true ) {

    cVar3 = FUN_00680980(*param_1,param_3);

    while (cVar3 != '\0') {

      puVar1 = param_1 + 1;

      param_1 = param_1 + 1;

      cVar3 = FUN_00680980(*puVar1,param_3);

    }

    cVar3 = FUN_00680980(param_3,param_2[-1]);

    while (param_2 = param_2 + -1, cVar3 != '\0') {

      cVar3 = FUN_00680980(param_3,param_2[-1]);

    }

    if (param_2 <= param_1) break;

    uVar2 = *param_1;

    *param_1 = *param_2;

    *param_2 = uVar2;

    param_1 = param_1 + 1;

  }

  return param_1;

}





// --- FUN_00680ca0 at 0x00680CA0 (size: 65) ---


void FUN_00680ca0(undefined4 *param_1,undefined4 param_2)



{

  char cVar1;

  

  cVar1 = FUN_00680980(param_2,param_1[-1]);

  while (cVar1 != '\0') {

    *param_1 = param_1[-1];

    cVar1 = FUN_00680980(param_2,param_1[-2]);

    param_1 = param_1 + -1;

  }

  *param_1 = param_2;

  return;

}





// --- FUN_00680cf0 at 0x00680CF0 (size: 149) ---


void FUN_00680cf0(int param_1,undefined4 *param_2,undefined4 *param_3)



{

  int iVar1;

  char cVar2;

  

  param_1 = param_1 + -8;

  cVar2 = FUN_00680a90(&param_2,param_1);

  while (cVar2 != '\0') {

    FUN_00429ab0(param_1);

    param_1 = param_1 + -8;

    cVar2 = FUN_00680a90(&param_2,param_1);

  }

  FUN_00429ab0(&param_2);

  if (param_2 != (undefined4 *)0x0) {

    iVar1 = param_2[1];

    param_2[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*param_2)(1);

    }

    param_2 = (undefined4 *)0x0;

  }

  if ((param_3 != (undefined4 *)0x0) &&

     (iVar1 = param_3[1], param_3[1] = iVar1 + -1, iVar1 + -1 == 0)) {

    (**(code **)*param_3)(1);

  }

  return;

}





// --- FUN_00680d90 at 0x00680D90 (size: 98) ---


void FUN_00680d90(int param_1,int param_2,int param_3,undefined4 param_4)



{

  char cVar1;

  int iVar2;

  

  if (param_2 <= param_3) {

    *(undefined4 *)(param_1 + param_2 * 4) = param_4;

    return;

  }

  do {

    iVar2 = (param_2 + -1) / 2;

    cVar1 = FUN_00680980(*(undefined4 *)(param_1 + iVar2 * 4),param_4);

    if (cVar1 == '\0') break;

    *(undefined4 *)(param_1 + param_2 * 4) = *(undefined4 *)(param_1 + iVar2 * 4);

    param_2 = iVar2;

  } while (param_3 < iVar2);

  *(undefined4 *)(param_1 + param_2 * 4) = param_4;

  return;

}





// --- FUN_00680e00 at 0x00680E00 (size: 172) ---


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



{

  int iVar1;

  char cVar2;

  

  while (param_3 < param_2) {

    param_2 = (param_2 + -1) / 2;

    iVar1 = param_1 + param_2 * 8;

    cVar2 = FUN_00680a90(iVar1,&param_4);

    if (cVar2 == '\0') break;

    FUN_00429ab0(iVar1);

  }

  FUN_00429ab0(&param_4);

  if (param_4 != (undefined4 *)0x0) {

    iVar1 = param_4[1];

    param_4[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*param_4)(1);

    }

    param_4 = (undefined4 *)0x0;

  }

  if ((param_5 != (undefined4 *)0x0) &&

     (iVar1 = param_5[1], param_5[1] = iVar1 + -1, iVar1 + -1 == 0)) {

    (**(code **)*param_5)(1);

  }

  return;

}





// --- FUN_00680eb0 at 0x00680EB0 (size: 93) ---


void FUN_00680eb0(undefined4 param_1)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  undefined1 local_c [12];

  

  piVar2 = (int *)FUN_0052dcf0(local_c);

  iVar3 = piVar2[2];

  iVar1 = *piVar2;

  piVar2 = (int *)piVar2[1];

  do {

    if (iVar3 == 0) {

      return;

    }

    do {

      FUN_00429ce0(param_1);

      iVar3 = *(int *)(iVar3 + 4);

    } while (iVar3 != 0);

    do {

      piVar2 = piVar2 + 1;

      if (piVar2 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) {

        return;

      }

      iVar3 = *piVar2;

    } while (iVar3 == 0);

  } while( true );

}





// --- FUN_00680f10 at 0x00680F10 (size: 194) ---


uint FUN_00680f10(uint param_1,uint param_2,undefined4 *param_3,undefined4 *param_4)



{

  int iVar1;

  char cVar2;

  

  while( true ) {

    cVar2 = FUN_00680a90(param_1,&param_3);

    while (cVar2 != '\0') {

      param_1 = param_1 + 8;

      cVar2 = FUN_00680a90(param_1,&param_3);

    }

    param_2 = param_2 - 8;

    cVar2 = FUN_00680a90(&param_3,param_2);

    while (cVar2 != '\0') {

      param_2 = param_2 - 8;

      cVar2 = FUN_00680a90(&param_3,param_2);

    }

    if (param_2 <= param_1) break;

    FUN_0042b940(param_1,param_2);

    param_1 = param_1 + 8;

  }

  if (param_3 != (undefined4 *)0x0) {

    iVar1 = param_3[1];

    param_3[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*param_3)(1);

    }

    param_3 = (undefined4 *)0x0;

  }

  if ((param_4 != (undefined4 *)0x0) &&

     (iVar1 = param_4[1], param_4[1] = iVar1 + -1, iVar1 + -1 == 0)) {

    (**(code **)*param_4)(1);

  }

  return param_1;

}





// --- FUN_00680fe0 at 0x00680FE0 (size: 93) ---


void FUN_00680fe0(undefined4 *param_1,undefined4 *param_2)



{

  undefined4 uVar1;

  undefined4 *puVar2;

  char cVar3;

  

  for (; param_1 != param_2; param_1 = param_1 + 1) {

    uVar1 = *param_1;

    cVar3 = FUN_00680980(uVar1,param_1[-1]);

    puVar2 = param_1;

    while (cVar3 != '\0') {

      *puVar2 = puVar2[-1];

      cVar3 = FUN_00680980(uVar1,puVar2[-2]);

      puVar2 = puVar2 + -1;

    }

    *puVar2 = uVar1;

  }

  return;

}





// --- FUN_00681040 at 0x00681040 (size: 64) ---


void FUN_00681040(int param_1,int param_2,undefined4 param_3,undefined4 param_4)



{

  undefined4 uVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  

  for (; param_1 != param_2; param_1 = param_1 + 8) {

    uVar1 = 0;

    uVar2 = 0;

    uVar3 = param_4;

    FUN_00429ab0(param_1);

    FUN_00680cf0(param_1,uVar1,uVar2,uVar3);

  }

  return;

}





// --- FUN_00681080 at 0x00681080 (size: 113) ---


void FUN_00681080(int param_1,int param_2,int param_3,undefined4 param_4,undefined4 param_5)



{

  int iVar1;

  char cVar2;

  int iVar3;

  int iVar4;

  

  iVar4 = param_2;

  while( true ) {

    iVar1 = iVar4 * 2;

    iVar3 = iVar1 + 2;

    if (param_3 <= iVar3) break;

    cVar2 = FUN_00680980(*(undefined4 *)(param_1 + iVar3 * 4),

                         *(undefined4 *)(param_1 + -4 + iVar3 * 4));

    if (cVar2 != '\0') {

      iVar3 = iVar1 + 1;

    }

    *(undefined4 *)(param_1 + iVar4 * 4) = *(undefined4 *)(param_1 + iVar3 * 4);

    iVar4 = iVar3;

  }

  if (iVar3 == param_3) {

    *(undefined4 *)(param_1 + iVar4 * 4) = *(undefined4 *)(param_1 + -4 + iVar3 * 4);

    iVar4 = iVar1 + 1;

  }

  FUN_00680d90(param_1,iVar4,param_2,param_4,param_5);

  return;

}





// --- FUN_00681100 at 0x00681100 (size: 207) ---


void FUN_00681100(int param_1,int param_2,int param_3,undefined4 *param_4,undefined4 *param_5,

                 undefined4 param_6)



{

  int iVar1;

  char cVar2;

  int iVar3;

  int iVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  

  iVar4 = param_2;

  while( true ) {

    iVar1 = iVar4 * 2;

    iVar3 = iVar1 + 2;

    if (param_3 <= iVar3) break;

    iVar4 = param_1 + iVar3 * 8;

    cVar2 = FUN_00680a90(iVar4,iVar4 + -8);

    if (cVar2 != '\0') {

      iVar3 = iVar1 + 1;

    }

    FUN_00429ab0(param_1 + iVar3 * 8);

    iVar4 = iVar3;

  }

  if (iVar3 == param_3) {

    FUN_00429ab0(param_1 + -8 + iVar3 * 8);

    iVar4 = iVar1 + 1;

  }

  uVar5 = 0;

  uVar6 = 0;

  uVar7 = param_6;

  FUN_00429ab0(&param_4);

  FUN_00680e00(param_1,iVar4,param_2,uVar5,uVar6,uVar7);

  if (param_4 != (undefined4 *)0x0) {

    iVar4 = param_4[1];

    param_4[1] = iVar4 + -1;

    if (iVar4 + -1 == 0) {

      (**(code **)*param_4)(1);

    }

    param_4 = (undefined4 *)0x0;

  }

  if ((param_5 != (undefined4 *)0x0) &&

     (iVar4 = param_5[1], param_5[1] = iVar4 + -1, iVar4 + -1 == 0)) {

    (**(code **)*param_5)(1);

  }

  return;

}





// --- FUN_006811d0 at 0x006811D0 (size: 109) ---


void FUN_006811d0(undefined4 *param_1,undefined4 *param_2,undefined4 param_3)



{

  undefined4 uVar1;

  char cVar2;

  undefined4 *puVar3;

  size_t _Size;

  

  if ((param_1 != param_2) && (puVar3 = param_1 + 1, puVar3 != param_2)) {

    _Size = (int)puVar3 - (int)param_1;

    do {

      uVar1 = *puVar3;

      cVar2 = FUN_00680980(uVar1,*param_1);

      if (cVar2 == '\0') {

        FUN_00680ca0(puVar3,uVar1,param_3);

      }

      else {

        if (0 < (int)_Size) {

          memmove((void *)((int)puVar3 + (4 - _Size)),param_1,_Size);

        }

        *param_1 = uVar1;

      }

      puVar3 = puVar3 + 1;

      _Size = _Size + 4;

    } while (puVar3 != param_2);

  }

  return;

}





// --- FUN_00681240 at 0x00681240 (size: 181) ---


void FUN_00681240(undefined4 param_1,int param_2,undefined4 *param_3,undefined4 *param_4,

                 undefined4 param_5)



{

  int iVar1;

  char cVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  

  cVar2 = FUN_00680a90(&param_3,param_1);

  if (cVar2 == '\0') {

    uVar3 = 0;

    uVar4 = 0;

    uVar5 = param_5;

    FUN_00429ab0(&param_3);

    FUN_00680cf0(param_2,uVar3,uVar4,uVar5);

  }

  else {

    FUN_00680940(param_1,param_2,param_2 + 8,&param_3,0);

    FUN_00429ab0(&param_3);

  }

  if (param_3 != (undefined4 *)0x0) {

    iVar1 = param_3[1];

    param_3[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*param_3)(1);

    }

    param_3 = (undefined4 *)0x0;

  }

  if ((param_4 != (undefined4 *)0x0) &&

     (iVar1 = param_4[1], param_4[1] = iVar1 + -1, iVar1 + -1 == 0)) {

    (**(code **)*param_4)(1);

  }

  return;

}





// --- FUN_00681300 at 0x00681300 (size: 141) ---


void FUN_00681300(int param_1,int param_2,undefined4 param_3,undefined4 *param_4,undefined4 *param_5

                 ,undefined4 param_6)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  

  FUN_00429ab0(param_1);

  uVar2 = 0;

  uVar3 = 0;

  uVar4 = param_6;

  FUN_00429ab0(&param_4);

  FUN_00681100(param_1,0,param_2 - param_1 >> 3,uVar2,uVar3,uVar4);

  if (param_4 != (undefined4 *)0x0) {

    iVar1 = param_4[1];

    param_4[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*param_4)(1);

    }

    param_4 = (undefined4 *)0x0;

  }

  if ((param_5 != (undefined4 *)0x0) &&

     (iVar1 = param_5[1], param_5[1] = iVar1 + -1, iVar1 + -1 == 0)) {

    (**(code **)*param_5)(1);

  }

  return;

}





// --- FUN_00681390 at 0x00681390 (size: 83) ---


void FUN_00681390(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  iVar2 = param_2 - param_1 >> 2;

  if (1 < iVar2) {

    iVar3 = (iVar2 + -2) / 2;

    FUN_00681080(param_1,iVar3,iVar2,*(undefined4 *)(param_1 + iVar3 * 4),param_3);

    while (iVar3 != 0) {

      iVar1 = iVar3 * 4;

      iVar3 = iVar3 + -1;

      FUN_00681080(param_1,iVar3,iVar2,*(undefined4 *)(param_1 + -4 + iVar1),param_3);

    }

  }

  return;

}





// --- FUN_006813f0 at 0x006813F0 (size: 91) ---


void FUN_006813f0(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  int iVar2;

  int iVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  

  iVar3 = param_2 - param_1 >> 3;

  if (1 < iVar3) {

    iVar2 = (iVar3 + -2) / 2;

    iVar1 = param_1 + iVar2 * 8;

    while( true ) {

      uVar4 = 0;

      uVar5 = 0;

      uVar6 = param_3;

      FUN_00429ab0(iVar1);

      FUN_00681100(param_1,iVar2,iVar3,uVar4,uVar5,uVar6);

      if (iVar2 == 0) break;

      iVar2 = iVar2 + -1;

      iVar1 = iVar1 + -8;

    }

  }

  return;

}





// --- FUN_00681450 at 0x00681450 (size: 76) ---


void FUN_00681450(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  

  iVar1 = param_1;

  if (param_1 != param_2) {

    while (iVar1 = iVar1 + 8, iVar1 != param_2) {

      uVar2 = 0;

      uVar3 = 0;

      uVar4 = param_3;

      FUN_00429ab0(iVar1);

      FUN_00681240(param_1,iVar1,uVar2,uVar3,uVar4);

    }

  }

  return;

}





// --- FUN_006814a0 at 0x006814A0 (size: 77) ---


void FUN_006814a0(undefined4 *param_1,int param_2,undefined4 param_3)



{

  undefined4 uVar1;

  uint uVar2;

  

  uVar2 = param_2 - (int)param_1;

  while (4 < (int)(uVar2 & 0xfffffffc)) {

    uVar1 = *(undefined4 *)((int)param_1 + (uVar2 - 4));

    *(undefined4 *)((int)param_1 + (uVar2 - 4)) = *param_1;

    FUN_00681080(param_1,0,(int)(uVar2 - 4) >> 2,uVar1,param_3);

    uVar2 = uVar2 - 4;

  }

  return;

}





// --- FUN_006814f0 at 0x006814F0 (size: 95) ---


void FUN_006814f0(int param_1,int param_2,undefined4 param_3)



{

  undefined4 uVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  

  if (8 < (int)(param_2 - param_1 & 0xfffffff8U)) {

    param_2 = param_2 + -8;

    do {

      uVar4 = 0;

      uVar1 = 0;

      uVar2 = 0;

      uVar3 = param_3;

      FUN_00429ab0(param_2);

      FUN_00681300(param_1,param_2,param_2,uVar1,uVar2,uVar3,uVar4);

      param_2 = param_2 + -8;

    } while (8 < (int)((8 - param_1) + param_2 & 0xfffffff8U));

  }

  return;

}





// --- FUN_00681550 at 0x00681550 (size: 121) ---


void FUN_00681550(undefined4 *param_1,undefined4 *param_2,undefined4 *param_3,undefined4 param_4,

                 undefined4 param_5)



{

  undefined4 uVar1;

  char cVar2;

  undefined4 *puVar3;

  

  FUN_00681390(param_1,param_2,param_5,0,0);

  for (puVar3 = param_2; puVar3 < param_3; puVar3 = puVar3 + 1) {

    cVar2 = FUN_00680980(*puVar3,*param_1);

    if (cVar2 != '\0') {

      uVar1 = *puVar3;

      *puVar3 = *param_1;

      FUN_00681080(param_1,0,(int)param_2 - (int)param_1 >> 2,uVar1,param_5);

    }

  }

  FUN_006814a0(param_1,param_2,param_5);

  return;

}





// --- FUN_006815d0 at 0x006815D0 (size: 128) ---


void FUN_006815d0(undefined4 param_1,uint param_2,uint param_3,undefined4 param_4,undefined4 param_5

                 )



{

  char cVar1;

  uint uVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  

  FUN_006813f0(param_1,param_2,param_5,0,0);

  for (uVar2 = param_2; uVar2 < param_3; uVar2 = uVar2 + 8) {

    cVar1 = FUN_00680a90(uVar2,param_1);

    if (cVar1 != '\0') {

      uVar6 = 0;

      uVar3 = 0;

      uVar4 = 0;

      uVar5 = param_5;

      FUN_00429ab0(uVar2);

      FUN_00681300(param_1,param_2,uVar2,uVar3,uVar4,uVar5,uVar6);

    }

  }

  FUN_006814f0(param_1,param_2,param_5);

  return;

}





// --- FUN_00681650 at 0x00681650 (size: 140) ---


void FUN_00681650(int param_1,int param_2,undefined4 param_3,int param_4,undefined4 param_5)



{

  undefined4 *puVar1;

  int iVar2;

  

  if (0x40 < (int)(param_2 - param_1 & 0xfffffffcU)) {

    while (param_4 != 0) {

      param_4 = param_4 + -1;

      puVar1 = (undefined4 *)

               FUN_00680b90(param_1,param_1 + ((param_2 - param_1 >> 2) -

                                               (param_2 - param_1 >> 0x1f) >> 1) * 4,param_2 + -4);

      iVar2 = FUN_00680c20(param_1,param_2,*puVar1,param_5);

      FUN_00681650(iVar2,param_2,0,param_4,param_5);

      param_2 = iVar2;

      if ((int)(iVar2 - param_1 & 0xfffffffcU) < 0x41) {

        return;

      }

    }

    FUN_00681550(param_1,param_2,param_2,0,param_5);

  }

  return;

}





// --- FUN_006816e0 at 0x006816E0 (size: 254) ---


void FUN_006816e0(int param_1,int param_2,undefined4 param_3,int param_4,undefined4 param_5)



{

  int iVar1;

  char cVar2;

  int iVar3;

  int iVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  

  if (0x80 < (int)(param_2 - param_1 & 0xfffffff8U)) {

    while (param_4 != 0) {

      iVar1 = param_1 + ((param_2 - param_1 >> 3) - (param_2 - param_1 >> 0x1f) >> 1) * 8;

      param_4 = param_4 + -1;

      iVar4 = param_2 + -8;

      cVar2 = FUN_00680a90(param_1,iVar1);

      iVar3 = param_1;

      if (cVar2 == '\0') {

        cVar2 = FUN_00680a90(param_1,iVar4);

        if ((cVar2 == '\0') && (cVar2 = FUN_00680a90(iVar1,iVar4), iVar3 = iVar4, cVar2 == '\0'))

        goto LAB_00681775;

      }

      else {

        cVar2 = FUN_00680a90(iVar1,iVar4);

        if (cVar2 == '\0') {

          cVar2 = FUN_00680a90(param_1,iVar4);

          if (cVar2 != '\0') {

            iVar3 = iVar4;

          }

        }

        else {

LAB_00681775:

          iVar3 = iVar1;

        }

      }

      uVar5 = 0;

      uVar6 = 0;

      uVar7 = param_5;

      FUN_00429ab0(iVar3);

      iVar4 = FUN_00680f10(param_1,param_2,uVar5,uVar6,uVar7);

      FUN_006816e0(iVar4,param_2,0,param_4,param_5);

      param_2 = iVar4;

      if ((int)(iVar4 - param_1 & 0xfffffff8U) < 0x81) {

        return;

      }

    }

    FUN_006815d0(param_1,param_2,param_2,0,param_5);

  }

  return;

}





// --- FUN_006817e0 at 0x006817E0 (size: 199) ---


byte __thiscall FUN_006817e0(int param_1,undefined4 param_2,char param_3)



{

  int iVar1;

  uint *puVar2;

  byte bVar3;

  int *piVar4;

  uint uVar5;

  int iVar6;

  byte local_19;

  undefined1 local_c [12];

  

  local_19 = 1;

  piVar4 = (int *)FUN_0052dcf0(local_c);

  iVar6 = piVar4[2];

  iVar1 = *piVar4;

  piVar4 = (int *)piVar4[1];

  do {

    if (iVar6 == 0) {

      return local_19;

    }

    do {

      if (param_3 == '\0') {

        uVar5 = FUN_00429a00();

        for (puVar2 = *(uint **)(*(int *)(param_1 + 0x68) + (uVar5 % *(uint *)(param_1 + 0x70)) * 4)

            ; puVar2 != (uint *)0x0; puVar2 = (uint *)puVar2[1]) {

          if (*puVar2 == uVar5) {

            if ((puVar2 != (uint *)0x0) && (puVar2 != (uint *)0xfffffff8)) goto LAB_00681850;

            break;

          }

        }

      }

      else {

LAB_00681850:

        param_2 = FUN_00429a00();

        bVar3 = FUN_00429120(&param_2,iVar6 + 8);

        local_19 = local_19 & bVar3;

      }

      iVar6 = *(int *)(iVar6 + 4);

    } while (iVar6 != 0);

    do {

      piVar4 = piVar4 + 1;

      if (piVar4 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) {

        return local_19;

      }

      iVar6 = *piVar4;

    } while (iVar6 == 0);

  } while( true );

}





// --- FUN_006818b0 at 0x006818B0 (size: 316) ---


undefined4 FUN_006818b0(int *param_1,undefined4 param_2)



{

  int iVar1;

  char cVar2;

  int *piVar3;

  int iVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  uint uVar7;

  int iVar8;

  int *piVar9;

  int iVar10;

  int iVar11;

  undefined1 local_c [12];

  

  piVar3 = (int *)FUN_0052dcf0(local_c);

  iVar11 = piVar3[2];

  iVar1 = *piVar3;

  piVar3 = (int *)piVar3[1];

  while (iVar11 != 0) {

    do {

      iVar4 = FUN_00429a10();

      uVar7 = 0;

      if (param_1[2] != 0) {

        piVar9 = (int *)*param_1;

        do {

          if (*piVar9 == iVar4) {

            if (uVar7 != 0xffffffff) goto LAB_00681941;

            break;

          }

          uVar7 = uVar7 + 1;

          piVar9 = piVar9 + 1;

        } while (uVar7 < (uint)param_1[2]);

      }

      uVar5 = FUN_00429a10();

      if ((uint)param_1[2] < (param_1[1] & 0x7fffffffU)) {

LAB_00681936:

        *(undefined4 *)(*param_1 + param_1[2] * 4) = uVar5;

        param_1[2] = param_1[2] + 1;

      }

      else {

        uVar6 = FUN_00453850((param_1[1] & 0x7fffffffU) + 1);

        cVar2 = FUN_004180a0(uVar6);

        if (cVar2 != '\0') goto LAB_00681936;

      }

LAB_00681941:

      iVar11 = *(int *)(iVar11 + 4);

    } while (iVar11 != 0);

    do {

      piVar3 = piVar3 + 1;

      if (piVar3 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) goto LAB_0068196d;

      iVar11 = *piVar3;

    } while (iVar11 == 0);

  }

LAB_0068196d:

  if ((char)param_2 != '\0') {

    iVar11 = *param_1;

    iVar1 = iVar11 + param_1[2] * 4;

    if (iVar11 != iVar1) {

      iVar8 = 0;

      iVar10 = iVar1 - iVar11 >> 2;

      for (iVar4 = iVar10; iVar4 != 1; iVar4 = iVar4 >> 1) {

        iVar8 = iVar8 + 1;

      }

      FUN_00681650(iVar11,iVar1,0,iVar8 * 2,param_2);

      if (0x10 < iVar10) {

        FUN_006811d0(iVar11,iVar11 + 0x40,param_2);

        FUN_00680fe0(iVar11 + 0x40,iVar1,0,param_2);

        return 1;

      }

      FUN_006811d0(iVar11,iVar1,param_2);

    }

  }

  return 1;

}





// --- FUN_006819f0 at 0x006819F0 (size: 285) ---


undefined4 FUN_006819f0(int *param_1,int *param_2,undefined4 param_3)



{

  int iVar1;

  char cVar2;

  int *piVar3;

  int iVar4;

  undefined4 uVar5;

  int iVar6;

  int iVar7;

  int iVar8;

  undefined1 local_c [12];

  

  piVar3 = (int *)FUN_0052dcf0(local_c);

  iVar7 = piVar3[2];

  iVar1 = *piVar3;

  piVar3 = (int *)piVar3[1];

  while (iVar7 != 0) {

    do {

      iVar4 = FUN_00429a10();

      if (iVar4 == *param_1) {

        if ((param_2[1] & 0x7fffffffU) <= (uint)param_2[2]) {

          uVar5 = FUN_00453850((param_2[1] & 0x7fffffffU) + 1);

          cVar2 = FUN_004273a0(uVar5);

          if (cVar2 == '\0') goto LAB_00681a67;

        }

        FUN_00429ab0(iVar7 + 8);

        param_2[2] = param_2[2] + 1;

      }

LAB_00681a67:

      iVar7 = *(int *)(iVar7 + 4);

    } while (iVar7 != 0);

    do {

      piVar3 = piVar3 + 1;

      if (piVar3 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) goto LAB_00681a93;

      iVar7 = *piVar3;

    } while (iVar7 == 0);

  }

LAB_00681a93:

  if ((char)param_3 != '\0') {

    iVar7 = *param_2;

    iVar1 = iVar7 + param_2[2] * 8;

    if (iVar7 != iVar1) {

      iVar6 = 0;

      iVar8 = iVar1 - iVar7 >> 3;

      for (iVar4 = iVar8; iVar4 != 1; iVar4 = iVar4 >> 1) {

        iVar6 = iVar6 + 1;

      }

      FUN_006816e0(iVar7,iVar1,0,iVar6 * 2,param_3);

      if (0x10 < iVar8) {

        FUN_00681450(iVar7,iVar7 + 0x80,param_3);

        FUN_00681040(iVar7 + 0x80,iVar1,0,param_3);

        return 1;

      }

      FUN_00681450(iVar7,iVar1,param_3);

    }

  }

  return 1;

}





// --- FUN_00681b20 at 0x00681B20 (size: 8) ---


void FUN_00681b20(void)



{

  FUN_00428be0();

  return;

}





// --- FUN_00681b30 at 0x00681B30 (size: 546) ---


undefined4 FUN_00681b30(int param_1)



{

  char cVar1;

  int iVar2;

  LONG LVar3;

  uint uVar4;

  undefined4 *puVar5;

  uint uVar6;

  undefined *puVar7;

  undefined *local_20 [2];

  void *local_18;

  uint local_14;

  uint local_10;

  int local_c;

  uint local_8;

  uint local_4;

  

  if (param_1 != 0) {

    local_18 = (void *)0x0;

    local_14 = 0;

    local_10 = 0;

    cVar1 = FUN_006818b0(&local_18,1);

    if (cVar1 != '\0') {

      uVar4 = 0;

      if (local_10 != 0) {

        do {

          local_c = 0;

          local_8 = 0;

          local_4 = 0;

          cVar1 = FUN_006819f0((void *)((int)local_18 + uVar4 * 4),&local_c,1);

          if (cVar1 == '\0') goto LAB_00681cdd;

          if (local_4 != 0) {

            local_20[0] = PTR_DAT_00818344;

            InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

            cVar1 = FUN_00426910(*(undefined4 *)((int)local_18 + uVar4 * 4),local_20);

            if (cVar1 == '\0') {

LAB_00681cc7:

              puVar5 = (undefined4 *)(local_20[0] + -0x14);

              LVar3 = InterlockedDecrement((LONG *)(local_20[0] + -0x10));

              if ((LVar3 == 0) && (puVar5 != (undefined4 *)0x0)) {

                (**(code **)*puVar5)(1);

              }

LAB_00681cdd:

              if (((local_8 & 0x80000000) == 0x80000000) && (local_c != 0)) {

                FUN_00425ae0(3);

              }

              if ((local_14 & 0x80000000) != 0x80000000) {

                return 0;

              }

              operator_delete__(local_18);

              return 0;

            }

            puVar7 = local_20[0];

            InterlockedIncrement((LONG *)(local_20[0] + -0x10));

            iVar2 = FUN_00426f90(puVar7);

            if (iVar2 == 0) {

              FUN_004011b0();

              goto LAB_00681cdd;

            }

            uVar6 = 0;

            if (local_4 != 0) {

              do {

                cVar1 = FUN_00429ea0(iVar2);

                if (cVar1 == '\0') goto LAB_00681cc7;

                uVar6 = uVar6 + 1;

              } while (uVar6 < local_4);

            }

            puVar5 = (undefined4 *)(local_20[0] + -0x14);

            LVar3 = InterlockedDecrement((LONG *)(local_20[0] + -0x10));

            if ((LVar3 == 0) && (puVar5 != (undefined4 *)0x0)) {

              (**(code **)*puVar5)(1);

            }

          }

          if (((local_8 & 0x80000000) == 0x80000000) && (local_c != 0)) {

            FUN_00425ae0(3);

          }

          uVar4 = uVar4 + 1;

        } while (uVar4 < local_10);

      }

      if ((local_14 & 0x80000000) == 0x80000000) {

        operator_delete__(local_18);

      }

      return 1;

    }

    if ((local_14 & 0x80000000) == 0x80000000) {

      operator_delete__(local_18);

    }

  }

  return 0;

}





// --- FUN_00681d60 at 0x00681D60 (size: 255) ---


void FUN_00681d60(void)



{

  int iVar1;

  undefined4 *puVar2;

  char cVar3;

  int *piVar4;

  void *pvVar5;

  void *pvVar6;

  int *piVar7;

  void *pvVar8;

  void *pvVar9;

  undefined1 local_c [12];

  

  piVar4 = (int *)FUN_0052dcf0(local_c);

  iVar1 = *piVar4;

  pvVar9 = (void *)piVar4[2];

  piVar4 = (int *)piVar4[1];

joined_r0x00681d81:

  do {

    if (pvVar9 == (void *)0x0) {

      return;

    }

    do {

      cVar3 = FUN_00429960();

      if (cVar3 != '\0') {

        pvVar6 = *(void **)((int)pvVar9 + 4);

        piVar7 = piVar4;

        pvVar8 = pvVar6;

        if (pvVar6 != (void *)0x0) goto LAB_00681dbf;

        goto LAB_00681db0;

      }

      pvVar9 = *(void **)((int)pvVar9 + 4);

    } while (pvVar9 != (void *)0x0);

    do {

      piVar4 = piVar4 + 1;

      if (piVar4 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) {

        return;

      }

      pvVar9 = (void *)*piVar4;

    } while (pvVar9 == (void *)0x0);

  } while( true );

  while (pvVar8 = (void *)*piVar7, pvVar8 == (void *)0x0) {

LAB_00681db0:

    piVar7 = piVar7 + 1;

    pvVar8 = pvVar6;

    if (piVar7 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) break;

  }

LAB_00681dbf:

  pvVar6 = (void *)*piVar4;

  if (pvVar6 != pvVar9) {

    do {

      pvVar5 = pvVar6;

      pvVar6 = *(void **)((int)pvVar5 + 4);

    } while (pvVar6 != pvVar9);

    if (pvVar5 != (void *)0x0) {

      *(undefined4 *)((int)pvVar5 + 4) = *(undefined4 *)((int)pvVar6 + 4);

      goto LAB_00681ddf;

    }

  }

  *piVar4 = *(int *)((int)pvVar6 + 4);

LAB_00681ddf:

  *(int *)(iVar1 + 0x6c) = *(int *)(iVar1 + 0x6c) + -1;

  puVar2 = *(undefined4 **)((int)pvVar9 + 8);

  if (puVar2 != (undefined4 *)0x0) {

    piVar4 = puVar2 + 1;

    *piVar4 = *piVar4 + -1;

    if (*piVar4 == 0) {

      (**(code **)*puVar2)(1);

    }

    *(undefined4 *)((int)pvVar9 + 8) = 0;

  }

  puVar2 = *(undefined4 **)((int)pvVar9 + 0xc);

  if (puVar2 != (undefined4 *)0x0) {

    piVar4 = puVar2 + 1;

    *piVar4 = *piVar4 + -1;

    if (*piVar4 == 0) {

      (**(code **)*puVar2)(1);

    }

    *(undefined4 *)((int)pvVar9 + 0xc) = 0;

  }

  operator_delete(pvVar9);

  pvVar9 = pvVar8;

  piVar4 = piVar7;

  goto joined_r0x00681d81;

}





// --- FUN_00681e60 at 0x00681E60 (size: 255) ---


void FUN_00681e60(void)



{

  int iVar1;

  undefined4 *puVar2;

  char cVar3;

  int *piVar4;

  void *pvVar5;

  void *pvVar6;

  int *piVar7;

  void *pvVar8;

  void *pvVar9;

  undefined1 local_c [12];

  

  piVar4 = (int *)FUN_0052dcf0(local_c);

  iVar1 = *piVar4;

  pvVar9 = (void *)piVar4[2];

  piVar4 = (int *)piVar4[1];

joined_r0x00681e81:

  do {

    if (pvVar9 == (void *)0x0) {

      return;

    }

    do {

      cVar3 = FUN_00429980();

      if (cVar3 != '\0') {

        pvVar6 = *(void **)((int)pvVar9 + 4);

        piVar7 = piVar4;

        pvVar8 = pvVar6;

        if (pvVar6 != (void *)0x0) goto LAB_00681ebf;

        goto LAB_00681eb0;

      }

      pvVar9 = *(void **)((int)pvVar9 + 4);

    } while (pvVar9 != (void *)0x0);

    do {

      piVar4 = piVar4 + 1;

      if (piVar4 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) {

        return;

      }

      pvVar9 = (void *)*piVar4;

    } while (pvVar9 == (void *)0x0);

  } while( true );

  while (pvVar8 = (void *)*piVar7, pvVar8 == (void *)0x0) {

LAB_00681eb0:

    piVar7 = piVar7 + 1;

    pvVar8 = pvVar6;

    if (piVar7 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) break;

  }

LAB_00681ebf:

  pvVar6 = (void *)*piVar4;

  if (pvVar6 != pvVar9) {

    do {

      pvVar5 = pvVar6;

      pvVar6 = *(void **)((int)pvVar5 + 4);

    } while (pvVar6 != pvVar9);

    if (pvVar5 != (void *)0x0) {

      *(undefined4 *)((int)pvVar5 + 4) = *(undefined4 *)((int)pvVar6 + 4);

      goto LAB_00681edf;

    }

  }

  *piVar4 = *(int *)((int)pvVar6 + 4);

LAB_00681edf:

  *(int *)(iVar1 + 0x6c) = *(int *)(iVar1 + 0x6c) + -1;

  puVar2 = *(undefined4 **)((int)pvVar9 + 8);

  if (puVar2 != (undefined4 *)0x0) {

    piVar4 = puVar2 + 1;

    *piVar4 = *piVar4 + -1;

    if (*piVar4 == 0) {

      (**(code **)*puVar2)(1);

    }

    *(undefined4 *)((int)pvVar9 + 8) = 0;

  }

  puVar2 = *(undefined4 **)((int)pvVar9 + 0xc);

  if (puVar2 != (undefined4 *)0x0) {

    piVar4 = puVar2 + 1;

    *piVar4 = *piVar4 + -1;

    if (*piVar4 == 0) {

      (**(code **)*puVar2)(1);

    }

    *(undefined4 *)((int)pvVar9 + 0xc) = 0;

  }

  operator_delete(pvVar9);

  pvVar9 = pvVar8;

  piVar4 = piVar7;

  goto joined_r0x00681e81;

}





// --- FUN_00681f60 at 0x00681F60 (size: 65) ---


void __fastcall FUN_00681f60(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_0079d098;

  param_1[1] = &PTR_FUN_00798700;

  FUN_00428be0();

  param_1[2] = &PTR_FUN_007980cc;

  if ((undefined4 *)param_1[0x1a] != param_1 + 3) {

    operator_delete__((undefined4 *)param_1[0x1a]);

  }

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  return;

}





// --- FUN_00681fb0 at 0x00681FB0 (size: 1044) ---


undefined1 FUN_00681fb0(int *param_1)



{

  undefined4 *puVar1;

  bool bVar2;

  undefined *puVar3;

  char cVar4;

  int *piVar5;

  int iVar6;

  undefined4 uVar7;

  LONG LVar8;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined4 extraout_ECX_01;

  undefined4 extraout_ECX_02;

  undefined4 extraout_ECX_03;

  undefined *puVar9;

  undefined *puVar10;

  undefined1 *puVar11;

  undefined *puVar12;

  undefined1 local_32;

  undefined *apuStack_2c [2];

  undefined *puStack_24;

  undefined *local_20;

  undefined *puStack_1c;

  undefined *local_18;

  undefined1 auStack_14 [4];

  undefined4 *puStack_10;

  undefined4 *puStack_c;

  

  if (param_1 == (int *)0x0) {

    return 0;

  }

  if ((DAT_00837720 == -0x7ffffffe) || (bVar2 = false, DAT_00837720 == -0x7fffffff)) {

    bVar2 = true;

  }

  local_32 = 1;

  local_18 = (undefined *)FUN_0065ca40();

  local_20 = (undefined *)0x0;

  if (local_18 != (undefined *)0x0) {

    do {

      piVar5 = (int *)(**(code **)(*param_1 + 0xc))(local_20);

      if (piVar5 == (int *)0x0) {

        uVar7 = extraout_ECX;

        FUN_00401340("unexpected end of filenode structure (invalid group!)");

        FUN_0065d620(param_1,uVar7);

        local_32 = 0;

      }

      else {

        apuStack_2c[0] = PTR_DAT_00818344;

        InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

        FUN_00426020(apuStack_2c);

        puVar3 = apuStack_2c[0];

        puVar11 = auStack_14;

        puVar9 = apuStack_2c[0];

        InterlockedIncrement((LONG *)(apuStack_2c[0] + -0x10));

        cVar4 = FUN_0041b8f0(10,puVar9,puVar11);

        if (cVar4 == '\0') {

          uVar7 = extraout_ECX_00;

          puVar9 = puVar3;

          FUN_00401340("invalid property group \'%s\'");

          FUN_0065d620(piVar5,uVar7,puVar9);

          local_32 = 0;

        }

        else {

          puStack_1c = (undefined *)FUN_0065ca40();

          apuStack_2c[0] = (undefined *)0x0;

          if (puStack_1c != (undefined *)0x0) {

            do {

              iVar6 = (**(code **)(*piVar5 + 0xc))(apuStack_2c[0]);

              if (iVar6 != 0) {

                puStack_10 = (undefined4 *)0x0;

                puStack_c = (undefined4 *)0x0;

                cVar4 = FUN_0042a420(iVar6);

                if (cVar4 == '\0') {

                  puStack_24 = PTR_DAT_00818344;

                  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

                  FUN_00426020(&puStack_24);

                  puVar9 = puStack_24;

                  uVar7 = extraout_ECX_01;

                  puVar10 = puStack_24;

                  puVar12 = puVar3;

                  FUN_00401340("could not parse property [%s] from group [%s]");

                  FUN_0065d620(iVar6,uVar7,puVar10,puVar12);

                  puVar1 = (undefined4 *)(puVar9 + -0x14);

                  LVar8 = InterlockedDecrement((LONG *)(puVar9 + -0x10));

                  if ((LVar8 == 0) && (puVar1 != (undefined4 *)0x0)) {

                    (**(code **)*puVar1)(1);

                  }

                  if (puStack_10 != (undefined4 *)0x0) {

                    iVar6 = puStack_10[1];

                    puStack_10[1] = iVar6 + -1;

                    if (iVar6 + -1 == 0) {

                      (**(code **)*puStack_10)(1);

                    }

                    puStack_10 = (undefined4 *)0x0;

                  }

                  if (puStack_c != (undefined4 *)0x0) {

                    iVar6 = puStack_c[1];

                    puStack_c[1] = iVar6 + -1;

                    if (iVar6 + -1 == 0) {

                      (**(code **)*puStack_c)(1);

                    }

                    puStack_c = (undefined4 *)0x0;

                  }

LAB_00682271:

                  local_32 = 0;

                }

                else {

                  if ((!bVar2) || (cVar4 = FUN_004299a0(), cVar4 == '\0')) {

                    uVar7 = FUN_00429a00();

                    cVar4 = FUN_004643e0(uVar7);

                    if (cVar4 != '\0') {

                      local_20 = PTR_DAT_00818344;

                      InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

                      FUN_00426020(&local_20);

                      puVar9 = local_20;

                      uVar7 = extraout_ECX_03;

                      puVar10 = local_20;

                      FUN_00401340("Error: Property [%s] occurs twice. Will fail.");

                      FUN_0065d620(iVar6,uVar7,puVar10);

                      puVar1 = (undefined4 *)(puVar9 + -0x14);

                      LVar8 = InterlockedDecrement((LONG *)(puVar9 + -0x10));

                      if ((LVar8 == 0) && (puVar1 != (undefined4 *)0x0)) {

                        (**(code **)*puVar1)(1);

                      }

                      if (puStack_10 != (undefined4 *)0x0) {

                        iVar6 = puStack_10[1];

                        puStack_10[1] = iVar6 + -1;

                        if (iVar6 + -1 == 0) {

                          (**(code **)*puStack_10)(1);

                        }

                        puStack_10 = (undefined4 *)0x0;

                      }

                      if (puStack_c != (undefined4 *)0x0) {

                        iVar6 = puStack_c[1];

                        puStack_c[1] = iVar6 + -1;

                        if (iVar6 + -1 == 0) {

                          (**(code **)*puStack_c)(1);

                        }

                        puStack_c = (undefined4 *)0x0;

                      }

                      LVar8 = InterlockedDecrement((LONG *)(puVar3 + -0x10));

                      if (LVar8 != 0) {

                        return 0;

                      }

                      if ((undefined4 *)(puVar3 + -0x14) == (undefined4 *)0x0) {

                        return 0;

                      }

                      (*(code *)**(undefined4 **)(puVar3 + -0x14))(1);

                      return 0;

                    }

                    puStack_24 = (undefined *)FUN_00429a00();

                    cVar4 = FUN_0042c290(&puStack_24,&puStack_10);

                    if (cVar4 == '\0') {

                      puStack_24 = PTR_DAT_00818344;

                      InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

                      FUN_00426020(&puStack_24);

                      puVar9 = puStack_24;

                      uVar7 = extraout_ECX_02;

                      puVar10 = puStack_24;

                      puVar12 = puVar3;

                      FUN_00401340("failed adding property [%s] for group [%s]");

                      FUN_0065d620(iVar6,uVar7,puVar10,puVar12);

                      puVar1 = (undefined4 *)(puVar9 + -0x14);

                      LVar8 = InterlockedDecrement((LONG *)(puVar9 + -0x10));

                      if ((LVar8 == 0) && (puVar1 != (undefined4 *)0x0)) {

                        (**(code **)*puVar1)(1);

                      }

                      FUN_004234d0();

                      goto LAB_00682271;

                    }

                  }

                  FUN_004234d0();

                }

              }

              apuStack_2c[0] = apuStack_2c[0] + 1;

            } while (apuStack_2c[0] < puStack_1c);

          }

        }

        LVar8 = InterlockedDecrement((LONG *)(puVar3 + -0x10));

        if ((LVar8 == 0) && ((undefined4 *)(puVar3 + -0x14) != (undefined4 *)0x0)) {

          (*(code *)**(undefined4 **)(puVar3 + -0x14))(1);

        }

      }

      local_20 = local_20 + 1;

    } while (local_20 < local_18);

  }

  cVar4 = FUN_00413a70();

  if (cVar4 == '\0') {

    cVar4 = FUN_00413a90();

    if (cVar4 != '\0') {

      FUN_00681e60();

    }

    cVar4 = FUN_00413ab0();

    if (cVar4 != '\0') {

      FUN_00681d60();

    }

  }

  return local_32;

}





// --- FUN_006823d0 at 0x006823D0 (size: 37) ---


undefined4 * __fastcall FUN_006823d0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_0079d098;

  param_1[1] = &PTR_FUN_00798700;

  FUN_00428580(0);

  param_1[1] = &PTR_FUN_00798700;

  return param_1;

}





// --- FUN_00682400 at 0x00682400 (size: 29) ---


int __thiscall FUN_00682400(int param_1,int param_2)



{

  if (param_1 != param_2) {

    FUN_00429290(param_2 + 4);

  }

  return param_1;

}





// --- FUN_00682420 at 0x00682420 (size: 48) ---


void __thiscall FUN_00682420(int param_1,int param_2)



{

  int iVar1;

  

  iVar1 = param_2;

  if ((~*(byte *)(param_2 + 4) & 1) != 0) {

    FUN_00428be0();

  }

  FUN_00429760(&param_2,param_1 + 8,iVar1);

  return;

}





// --- FUN_00682450 at 0x00682450 (size: 42) ---


undefined4 * __fastcall FUN_00682450(undefined4 *param_1)



{

  FUN_006823d0();

  FUN_00415460(DAT_008f89bc);

  param_1[0x1e] = &PTR_LAB_007ff910;

  *param_1 = &PTR_FUN_007ff908;

  return param_1;

}





// --- FUN_00682500 at 0x00682500 (size: 52) ---


undefined4 * __thiscall FUN_00682500(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007ff908;

  param_1[0x1e] = &PTR_LAB_007ff910;

  FUN_004154b0();

  FUN_00681f60();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00682570 at 0x00682570 (size: 139) ---


undefined4 FUN_00682570(int param_1,int param_2,int param_3,int param_4)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  char cVar4;

  

  if (((param_4 == 0) || (param_2 == 0)) || (param_3 == 0)) {

    return 0;

  }

  iVar2 = 0;

  uVar3 = 0;

  if (param_3 != 1) {

    do {

      if (param_1 == 2) {

        iVar1 = iswalpha((short)*(char *)(uVar3 + param_2));

        cVar4 = iVar1 != 0;

LAB_006825d0:

        if (cVar4 != '\0') goto LAB_006825d4;

      }

      else {

        if (param_1 == 3) {

          iVar1 = iswspace((short)*(char *)(uVar3 + param_2));

          cVar4 = '\x01' - (iVar1 != 0);

          goto LAB_006825d0;

        }

LAB_006825d4:

        *(undefined1 *)(iVar2 + param_4) = *(undefined1 *)(uVar3 + param_2);

        iVar2 = iVar2 + 1;

      }

      uVar3 = uVar3 + 1;

    } while (uVar3 < param_3 - 1U);

  }

  *(undefined1 *)(iVar2 + param_4) = 0;

  return 1;

}





// --- FUN_00682600 at 0x00682600 (size: 128) ---


bool FUN_00682600(char *param_1,char *param_2)



{

  char cVar1;

  char cVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  

  if ((param_1 == (char *)0x0) || (param_2 == (char *)0x0)) {

    return false;

  }

  cVar1 = *param_2;

  cVar2 = *param_1;

  iVar6 = 0;

  iVar3 = 0;

  iVar5 = -1;

  do {

    while (iVar4 = iVar3, cVar1 == '*') {

LAB_00682624:

      cVar1 = param_2[iVar4 + 1];

      while( true ) {

        if (cVar2 == '\0') {

          return cVar1 == '\0';

        }

        iVar3 = iVar4 + 1;

        iVar5 = iVar4;

        if (cVar2 == cVar1) break;

        cVar2 = param_1[iVar6 + 1];

        iVar6 = iVar6 + 1;

      }

    }

    if (cVar1 == cVar2) {

      do {

        if (cVar2 == '\0') {

          return true;

        }

        iVar3 = iVar4 + 1;

        cVar2 = param_1[iVar6 + 1];

        iVar4 = iVar4 + 1;

        iVar6 = iVar6 + 1;

        if (param_2[iVar3] == '*') goto LAB_00682624;

      } while (param_2[iVar3] == cVar2);

    }

    if (iVar5 == -1) {

      return false;

    }

    cVar1 = param_2[iVar5];

    iVar3 = iVar5;

  } while( true );

}





// --- FUN_00682690 at 0x00682690 (size: 64) ---


undefined4 * __thiscall FUN_00682690(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007ff974;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_006826d0 at 0x006826D0 (size: 64) ---


undefined4 * __thiscall FUN_006826d0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007ff978;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00682710 at 0x00682710 (size: 297) ---


undefined4 * FUN_00682710(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  LONG LVar3;

  char *pcVar4;

  undefined1 local_4 [4];

  

  puVar1 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  uVar2 = FUN_0042c820(1,10);

  switch(uVar2) {

  case 1:

    pcVar4 = "glares menacingly.";

    goto LAB_006827e7;

  case 2:

    FUN_0048c3e0("clicks its pincers together in anticipation of destruction.");

    break;

  case 3:

    FUN_0048c3e0("screeches in a horrible fashion.");

    break;

  case 4:

    pcVar4 = "lets out a maddening series of clicks and hisses.";

    goto LAB_006827e7;

  case 5:

    FUN_0048c3e0("surveys the area as acid drips from its mandibles.");

    break;

  case 6:

    FUN_0048c3e0("hisses some kind of threat.");

    break;

  case 7:

    pcVar4 = "calls out searching for other Olthoi.";

    goto LAB_006827e7;

  case 8:

    FUN_0048c3e0("cries out to indicate to its kin that prey is near.");

    break;

  case 9:

    FUN_0048c3e0("casts about looking for victims.");

    break;

  case 10:

    pcVar4 = "prepares to hunt enemies of the queen.";

LAB_006827e7:

    FUN_0048c3e0(pcVar4);

    break;

  default:

    goto switchD_00682742_default;

  }

  FUN_004914f0(local_4);

  FUN_005abb30();

switchD_00682742_default:

  *param_1 = puVar1;

  InterlockedIncrement(puVar1 + 1);

  LVar3 = InterlockedDecrement(puVar1 + 1);

  if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return param_1;

}





// --- FUN_00682870 at 0x00682870 (size: 297) ---


undefined4 * FUN_00682870(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  LONG LVar3;

  char *pcVar4;

  undefined1 local_4 [4];

  

  puVar1 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  uVar2 = FUN_0042c820(1,10);

  switch(uVar2) {

  case 1:

    pcVar4 = "cowers in fear.";

    goto LAB_00682947;

  case 2:

    FUN_0048c3e0("calls out for help and prepares to fight you.");

    break;

  case 3:

    FUN_0048c3e0("seems startled to see Olthoi.");

    break;

  case 4:

    pcVar4 = "cries out to warn others that Olthoi are present.";

    goto LAB_00682947;

  case 5:

    FUN_0048c3e0("surveys the area with weapons at the ready.");

    break;

  case 6:

    FUN_0048c3e0("regards you warily.");

    break;

  case 7:

    pcVar4 = "lets out a battle cry as a challenge.";

    goto LAB_00682947;

  case 8:

    FUN_0048c3e0("goes into a defensive posture at the sight of you.");

    break;

  case 9:

    FUN_0048c3e0("seems to be looking for an escape route.");

    break;

  case 10:

    pcVar4 = "gestures a challenge to you.";

LAB_00682947:

    FUN_0048c3e0(pcVar4);

    break;

  default:

    goto switchD_006828a2_default;

  }

  FUN_004914f0(local_4);

  FUN_005abb30();

switchD_006828a2_default:

  *param_1 = puVar1;

  InterlockedIncrement(puVar1 + 1);

  LVar3 = InterlockedDecrement(puVar1 + 1);

  if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return param_1;

}





// --- FUN_006829d0 at 0x006829D0 (size: 143) ---


undefined4 * __thiscall FUN_006829d0(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007ff974;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_00682a60 at 0x00682A60 (size: 143) ---


undefined4 * __thiscall FUN_00682a60(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007ff978;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_00682af0 at 0x00682AF0 (size: 213) ---


undefined4 __thiscall FUN_00682af0(int param_1,int param_2)



{

  int iVar1;

  uint *puVar2;

  uint *puVar3;

  int *piVar4;

  undefined4 *puVar5;

  uint *puVar6;

  

  if (param_2 == *(int *)(param_1 + 0x68)) {

    return 0;

  }

  iVar1 = *(int *)(param_1 + 0x6c);

  puVar3 = (uint *)0x0;

  do {

    if (iVar1 == 0) {

      if (*(void **)(param_1 + 0x60) != (void *)(param_1 + 4)) {

        operator_delete__(*(void **)(param_1 + 0x60));

      }

      *(undefined4 *)(param_1 + 0x60) = 0;

      *(undefined4 *)(param_1 + 100) = 0;

      *(undefined4 *)(param_1 + 0x68) = 0;

      *(undefined4 *)(param_1 + 0x6c) = 0;

      FUN_00693b20(param_2);

      while (puVar3 != (uint *)0x0) {

        puVar2 = (uint *)puVar3[1];

        puVar6 = (uint *)(*(int *)(param_1 + 0x60) + (*puVar3 % *(uint *)(param_1 + 0x68)) * 4);

        puVar3[1] = *puVar6;

        *puVar6 = (uint)puVar3;

        if (puVar6 < *(uint **)(param_1 + 100)) {

          *(uint **)(param_1 + 100) = puVar6;

        }

        *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

        puVar3 = puVar2;

      }

      return 1;

    }

    piVar4 = *(int **)(param_1 + 100);

    while (piVar4 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        puVar5 = *(undefined4 **)(param_1 + 100);

        puVar6 = (uint *)*puVar5;

        goto LAB_00682b41;

      }

      piVar4 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar4;

    }

    puVar5 = (undefined4 *)0x0;

    puVar6 = (uint *)0x0;

LAB_00682b41:

    FUN_00428ba0(param_1,puVar5,puVar6);

    puVar6[1] = (uint)puVar3;

    iVar1 = *(int *)(param_1 + 0x6c);

    puVar3 = puVar6;

  } while( true );

}





// --- FUN_00682bd0 at 0x00682BD0 (size: 302) ---


void __thiscall FUN_00682bd0(int param_1,undefined *param_2)



{

  uint uVar1;

  uint uVar2;

  undefined4 *puVar3;

  uint *puVar4;

  uint uVar5;

  LONG LVar6;

  int iVar7;

  

  uVar1 = (uint)param_2;

  uVar2 = *(uint *)((int)param_2 + 4) & 5;

  if (uVar2 == 1) {

    FUN_0040ad10(4);

    puVar3 = (undefined4 *)FUN_0040acf0(4);

    if (puVar3 != (undefined4 *)0x0) {

      if ((*(byte *)(uVar1 + 4) & 1) == 0) {

        *(undefined4 *)(param_1 + 0xc) = *puVar3;

      }

      else {

        *puVar3 = *(undefined4 *)(param_1 + 0xc);

      }

    }

    iVar7 = *(int *)(param_1 + 4);

    if (iVar7 != 0) {

      while (FUN_00402400(uVar1), iVar7 != 0) {

        iVar7 = *(int *)(iVar7 + 4);

        if (iVar7 == 0) {

          return;

        }

      }

    }

  }

  else if (uVar2 == 0) {

    FUN_00405210();

    FUN_0040ad10(4);

    puVar4 = (uint *)FUN_0040acf0(4);

    uVar2 = (uint)param_2;

    if (puVar4 != (uint *)0x0) {

      if ((*(byte *)(uVar1 + 4) & 1) == 0) {

        uVar2 = *puVar4;

      }

      else {

        *puVar4 = (uint)param_2;

      }

    }

    if ((~(byte)(*(uint *)(uVar1 + 4) >> 2) & 1) != 0) {

      uVar5 = FUN_0040a8f0();

      if (uVar5 < uVar2) {

        FUN_0040aa50();

        return;

      }

      param_2 = PTR_DAT_00818344;

      InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

      if (uVar2 != 0) {

        uVar5 = 0;

        do {

          FUN_00402400(uVar1);

          if ((*(uint *)(uVar1 + 4) >> 2 & 1) != 0) break;

          FUN_0040b720(&param_2);

          uVar5 = uVar5 + 1;

        } while (uVar5 < uVar2);

      }

      puVar3 = (undefined4 *)(param_2 + -0x14);

      LVar6 = InterlockedDecrement((LONG *)(param_2 + -0x10));

      if ((LVar6 == 0) && (puVar3 != (undefined4 *)0x0)) {

        (**(code **)*puVar3)(1);

      }

    }

  }

  return;

}





// --- FUN_00682d00 at 0x00682D00 (size: 77) ---


undefined4 * __thiscall FUN_00682d00(undefined4 *param_1,undefined4 *param_2)



{

  int iVar1;

  

  *param_1 = &PTR_FUN_00795074;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  if (param_1 != param_2) {

    FUN_00405210();

    for (iVar1 = param_2[1]; (iVar1 != 0 && (FUN_0040b720(iVar1), iVar1 != 0));

        iVar1 = *(int *)(iVar1 + 4)) {

    }

  }

  return param_1;

}





// --- FUN_00682d50 at 0x00682D50 (size: 136) ---


void __fastcall FUN_00682d50(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  int *piVar4;

  void *pvVar5;

  

  iVar1 = *(int *)(param_1 + 0x6c);

  do {

    if (iVar1 == 0) {

      return;

    }

    piVar4 = *(int **)(param_1 + 100);

    while (piVar4 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar4 = *(int **)(param_1 + 100);

        pvVar5 = (void *)*piVar4;

        goto LAB_00682d8f;

      }

      piVar4 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar4;

    }

    piVar4 = (int *)0x0;

    pvVar5 = (void *)0x0;

LAB_00682d8f:

    pvVar3 = (void *)*piVar4;

    if (pvVar3 == pvVar5) {

LAB_00682da2:

      *piVar4 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 4);

      } while (pvVar3 != pvVar5);

      if (pvVar2 == (void *)0x0) goto LAB_00682da2;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    if (pvVar5 != (void *)0x0) {

      *(undefined ***)((int)pvVar5 + 8) = &PTR_FUN_00795074;

      FUN_00405210();

      operator_delete(pvVar5);

    }

    iVar1 = *(int *)(param_1 + 0x6c);

  } while( true );

}





// --- FUN_00682de0 at 0x00682DE0 (size: 82) ---


undefined4 * __thiscall FUN_00682de0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007ffc9c;

  FUN_00682d50();

  param_1[1] = &PTR_FUN_007ff978;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00682e40 at 0x00682E40 (size: 335) ---


int __thiscall FUN_00682e40(int param_1,int param_2)



{

  undefined *puVar1;

  int iVar2;

  undefined4 *puVar3;

  int *piVar4;

  uint uVar5;

  uint uVar6;

  uint *puVar7;

  uint *puVar8;

  uint *puVar9;

  undefined1 local_18 [4];

  undefined4 *local_14;

  int local_c;

  

  iVar2 = param_2;

  if (param_1 != param_2) {

    FUN_00682d50();

    puVar1 = PTR_DAT_00818558;

    param_2 = *(undefined4 *)(iVar2 + 0x6c);

    puVar3 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

    if (puVar3 == (undefined4 *)puVar1) {

      puVar3 = puVar3 + -1;

    }

    FUN_00682af0(*puVar3);

    puVar7 = (uint *)0x0;

    piVar4 = (int *)FUN_0052dcf0(local_18);

    local_c = *piVar4;

    puVar9 = (uint *)piVar4[2];

    local_14 = (undefined4 *)piVar4[1];

    while (puVar8 = puVar7, puVar9 != (uint *)0x0) {

      do {

        puVar7 = (uint *)FUN_005df0f5(0x18);

        if (puVar7 == (uint *)0x0) {

          puVar7 = (uint *)0x0;

        }

        else {

          *puVar7 = *puVar9;

          puVar7[1] = 0;

          FUN_00682d00(puVar9 + 2);

        }

        uVar5 = *puVar7 % *(uint *)(param_1 + 0x6c);

        if (puVar8 == (uint *)0x0) {

LAB_00682f1f:

          puVar3 = (undefined4 *)(*(int *)(param_1 + 100) + uVar5 * 4);

          *puVar3 = puVar7;

          if (puVar8 == (uint *)0x0) {

            *(undefined4 **)(param_1 + 0x68) = puVar3;

          }

LAB_00682f35:

          *(int *)(param_1 + 0x70) = *(int *)(param_1 + 0x70) + 1;

        }

        else {

          uVar6 = *puVar8 % *(uint *)(param_1 + 0x6c);

          if (uVar5 == uVar6) {

            puVar8[1] = (uint)puVar7;

            goto LAB_00682f35;

          }

          if (uVar6 < uVar5) goto LAB_00682f1f;

        }

        puVar9 = (uint *)puVar9[1];

        puVar8 = puVar7;

      } while (puVar9 != (uint *)0x0);

      do {

        local_14 = local_14 + 1;

        if (local_14 == (undefined4 *)(*(int *)(local_c + 0x60) + *(int *)(local_c + 0x68) * 4)) {

          return param_1;

        }

        puVar9 = (uint *)*local_14;

      } while (puVar9 == (uint *)0x0);

    }

  }

  return param_1;

}





// --- FUN_00682f90 at 0x00682F90 (size: 183) ---


void __fastcall FUN_00682f90(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  int *piVar4;

  void *pvVar5;

  

  iVar1 = *(int *)(param_1 + 0x6c);

  do {

    if (iVar1 == 0) {

      return;

    }

    piVar4 = *(int **)(param_1 + 100);

    while (piVar4 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar4 = *(int **)(param_1 + 100);

        pvVar5 = (void *)*piVar4;

        goto LAB_00682fcf;

      }

      piVar4 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar4;

    }

    piVar4 = (int *)0x0;

    pvVar5 = (void *)0x0;

LAB_00682fcf:

    pvVar3 = (void *)*piVar4;

    if (pvVar3 == pvVar5) {

LAB_00682fe2:

      *piVar4 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 4);

      } while (pvVar3 != pvVar5);

      if (pvVar2 == (void *)0x0) goto LAB_00682fe2;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    if (pvVar5 != (void *)0x0) {

      *(undefined ***)((int)pvVar5 + 8) = &PTR_FUN_007ffc9c;

      FUN_00682d50();

      *(undefined ***)((int)pvVar5 + 0xc) = &PTR_FUN_007ff978;

      if (*(void **)((int)pvVar5 + 0x6c) != (void *)((int)pvVar5 + 0x10)) {

        operator_delete__(*(void **)((int)pvVar5 + 0x6c));

      }

      *(undefined4 *)((int)pvVar5 + 0x6c) = 0;

      *(undefined4 *)((int)pvVar5 + 0x70) = 0;

      *(undefined4 *)((int)pvVar5 + 0x74) = 0;

      *(undefined4 *)((int)pvVar5 + 0x78) = 0;

      operator_delete(pvVar5);

    }

    iVar1 = *(int *)(param_1 + 0x6c);

  } while( true );

}





// --- FUN_00683050 at 0x00683050 (size: 709) ---


undefined4 __thiscall

FUN_00683050(int param_1,undefined4 *param_2,uint param_3,undefined4 param_4,int *param_5)



{

  uint *puVar1;

  int iVar2;

  char *_String;

  undefined4 uVar3;

  int iVar4;

  char cVar5;

  int *piVar6;

  void *pvVar7;

  LONG LVar8;

  uint uVar9;

  uint uVar10;

  int *piVar11;

  char *pcVar12;

  char *pcVar13;

  undefined4 local_a4;

  int local_9c;

  undefined **local_90;

  int *local_8c;

  int local_80;

  undefined4 *local_7c;

  undefined **local_74;

  undefined **local_70;

  undefined1 local_6c [92];

  undefined1 *local_10;

  

  local_a4 = 0;

  local_74 = &PTR_FUN_007ffc9c;

  FUN_00682a60(0x17);

  local_9c = 0;

  for (puVar1 = *(uint **)(*(int *)(param_1 + 0x94) + (param_3 % *(uint *)(param_1 + 0x9c)) * 4);

      puVar1 != (uint *)0x0; puVar1 = (uint *)puVar1[1]) {

    if (*puVar1 == param_3) {

      if (puVar1 != (uint *)0x0) {

        FUN_00682e40(puVar1 + 2);

        piVar6 = (int *)FUN_0052dcf0(&local_90);

        piVar11 = (int *)piVar6[2];

        local_80 = *piVar6;

        local_7c = (undefined4 *)piVar6[1];

        if (piVar11 != (int *)0x0) goto LAB_006830f0;

      }

      break;

    }

  }

LAB_006832c4:

  switch(local_9c) {

  case 1:

    local_a4 = 3;

    break;

  case 2:

    local_a4 = 4;

    break;

  case 3:

    local_a4 = 6;

    break;

  case 4:

    local_a4 = 5;

  }

  local_74 = &PTR_FUN_007ffc9c;

  FUN_00682d50();

  local_70 = &PTR_FUN_007ff978;

  if (local_10 != local_6c) {

    operator_delete__(local_10);

  }

  return local_a4;

LAB_006830f0:

  iVar2 = *piVar11;

  FUN_00682d00(piVar11 + 2);

  _String = (char *)*param_2;

  InterlockedIncrement((LONG *)(_String + -0x10));

  if (*(int *)(_String + -0x10) == 1) {

    _String[-0xffffffff00000008] = -1;

    _String[-0xffffffff00000007] = -1;

    _String[-0xffffffff00000006] = -1;

    _String[-0xffffffff00000005] = -1;

  }

  else {

    FUN_00401280(*(int *)(_String + -4) + -1);

    uVar10 = *(uint *)(_String + -4);

    pcVar13 = _String;

    pcVar12 = _String;

    for (uVar9 = uVar10 >> 2; uVar9 != 0; uVar9 = uVar9 - 1) {

      *(undefined4 *)pcVar13 = *(undefined4 *)pcVar12;

      pcVar13 = pcVar13 + 4;

      pcVar12 = pcVar12 + 4;

    }

    for (uVar10 = uVar10 & 3; uVar10 != 0; uVar10 = uVar10 - 1) {

      *pcVar13 = *pcVar12;

      pcVar12 = pcVar12 + 1;

      pcVar13 = pcVar13 + 1;

    }

    LVar8 = InterlockedDecrement((LONG *)(_String + -0x10));

    if ((LVar8 == 0) && (_String + -0x14 != (char *)0x0)) {

      (*(code *)**(undefined4 **)(_String + -0x14))(1);

    }

  }

  _strlwr(_String);

  uVar3 = *(undefined4 *)(_String + -4);

  pvVar7 = (void *)thunk_FUN_005df0f5(uVar3);

  cVar5 = FUN_00682570(param_4,_String,uVar3,pvVar7);

  piVar6 = local_8c;

  if (cVar5 == '\0') {

    local_a4 = 2;

  }

  else {

    for (; piVar6 != (int *)0x0; piVar6 = (int *)piVar6[1]) {

      cVar5 = FUN_00682600(pvVar7,*piVar6);

      if (cVar5 != '\0') {

        iVar4 = *param_5;

        local_9c = iVar2;

        if (iVar4 != *piVar6) {

          LVar8 = InterlockedDecrement((LONG *)(iVar4 + -0x10));

          if ((LVar8 == 0) && ((undefined4 *)(iVar4 + -0x14) != (undefined4 *)0x0)) {

            (*(code *)**(undefined4 **)(iVar4 + -0x14))(1);

          }

          iVar2 = *piVar6;

          *param_5 = iVar2;

          InterlockedIncrement((LONG *)(iVar2 + -0x10));

        }

        break;

      }

    }

  }

  operator_delete__(pvVar7);

  pcVar12 = _String + -0x14;

  if (local_9c != 0) {

    LVar8 = InterlockedDecrement((LONG *)(_String + -0x10));

    if ((LVar8 == 0) && (pcVar12 != (char *)0x0)) {

      (*(code *)**(undefined4 **)pcVar12)(1);

    }

    local_90 = &PTR_FUN_00795074;

    FUN_00405210();

    goto LAB_006832c4;

  }

  LVar8 = InterlockedDecrement((LONG *)(_String + -0x10));

  if ((LVar8 == 0) && (pcVar12 != (char *)0x0)) {

    (*(code *)**(undefined4 **)pcVar12)(1);

  }

  local_90 = &PTR_FUN_00795074;

  FUN_00405210();

  piVar11 = (int *)piVar11[1];

  if (piVar11 == (int *)0x0) {

    do {

      local_7c = local_7c + 1;

      if (local_7c == (undefined4 *)(*(int *)(local_80 + 0x60) + *(int *)(local_80 + 0x68) * 4))

      goto LAB_006832c4;

      piVar11 = (int *)*local_7c;

    } while (piVar11 == (int *)0x0);

    if (piVar11 == (int *)0x0) goto LAB_006832c4;

  }

  goto LAB_006830f0;

}





// --- FUN_00683350 at 0x00683350 (size: 249) ---


undefined4 FUN_00683350(undefined4 param_1,int param_2,undefined4 param_3,int *param_4)



{

  undefined4 uVar1;

  LONG LVar2;

  int *piVar3;

  undefined4 *puVar4;

  int iVar5;

  undefined4 uVar6;

  undefined **ppuVar7;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  ppuVar7 = &local_4;

  iVar5 = param_2;

  uVar6 = param_3;

  uVar1 = FUN_0040d810(&param_2,param_1,param_2,param_3,ppuVar7);

  param_3 = FUN_00683050(uVar1,iVar5,uVar6,ppuVar7);

  puVar4 = (undefined4 *)(param_2 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_2 + -0x10));

  if ((LVar2 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  piVar3 = (int *)FUN_0040d200(&param_2,&local_4);

  iVar5 = *param_4;

  if (iVar5 != *piVar3) {

    LVar2 = InterlockedDecrement((LONG *)(iVar5 + -0x10));

    if ((LVar2 == 0) && ((undefined4 *)(iVar5 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(iVar5 + -0x14))(1);

    }

    iVar5 = *piVar3;

    *param_4 = iVar5;

    InterlockedIncrement((LONG *)(iVar5 + -0x10));

  }

  puVar4 = (undefined4 *)(param_2 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_2 + -0x10));

  if ((LVar2 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  puVar4 = (undefined4 *)(local_4 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar2 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  return param_3;

}





// --- FUN_00683450 at 0x00683450 (size: 534) ---


void FUN_00683450(undefined4 param_1,int param_2,uint param_3)



{

  int iVar1;

  undefined *puVar2;

  undefined *puVar3;

  uint uVar4;

  char cVar5;

  undefined *puVar6;

  byte *pbVar7;

  int *piVar8;

  undefined4 *puVar9;

  undefined4 *puVar10;

  uint uVar11;

  undefined4 *puVar12;

  undefined1 local_c [12];

  

  uVar4 = param_3;

  if ((~*(byte *)(param_3 + 4) & 1) != 0) {

    FUN_005c2c80();

  }

  puVar3 = PTR_DAT_00818558;

  puVar2 = PTR_DAT_00818554;

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x68);

    puVar6 = (undefined *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_3,param_3,0);

    if (puVar6 == puVar3) {

      puVar6 = puVar6 + -4;

    }

    uVar11 = (int)puVar6 - (int)puVar2 >> 2;

  }

  else {

    uVar11 = param_3 & 0xff;

  }

  FUN_0040ad10(1);

  pbVar7 = (byte *)FUN_0040acf0(1);

  if (pbVar7 != (byte *)0x0) {

    if ((*(byte *)(uVar4 + 4) & 1) == 0) {

      uVar11 = (uint)*pbVar7;

    }

    else {

      *pbVar7 = (byte)uVar11;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    if ((uVar11 & 0xff) < DAT_007956cc) {

      FUN_0069bba0(*(undefined4 *)(PTR_DAT_00818554 + (uVar11 & 0xff) * 4));

    }

    else {

      FUN_0040aa50();

    }

  }

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x6c);

  }

  FUN_00401a80(&param_3,&param_3,uVar4);

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    piVar8 = (int *)FUN_0052dcf0(local_c);

    iVar1 = *piVar8;

    puVar12 = (undefined4 *)piVar8[1];

    puVar9 = (undefined4 *)piVar8[2];

LAB_00683554:

    puVar10 = puVar9;

    if (puVar9 != (undefined4 *)0x0) {

      do {

        FUN_0040ad10(4);

        puVar9 = (undefined4 *)FUN_0040acf0(4);

        if (puVar9 != (undefined4 *)0x0) {

          if ((*(byte *)(uVar4 + 4) & 1) == 0) {

            *puVar10 = *puVar9;

          }

          else {

            *puVar9 = *puVar10;

          }

        }

        FUN_00682bd0(uVar4);

        puVar10 = (undefined4 *)puVar10[1];

      } while (puVar10 != (undefined4 *)0x0);

      do {

        puVar12 = puVar12 + 1;

        puVar9 = puVar10;

        if (puVar12 == (undefined4 *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) break;

        puVar9 = (undefined4 *)*puVar12;

      } while (puVar9 == (undefined4 *)0x0);

      goto LAB_00683554;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    uVar11 = FUN_0040a8f0();

    if (uVar11 < param_3) {

LAB_00683657:

      FUN_0040aa50();

    }

    else {

      uVar11 = 0;

      puVar12 = (undefined4 *)0x0;

      if (param_3 != 0) {

        while( true ) {

          puVar10 = (undefined4 *)FUN_005df0f5(0x18);

          puVar9 = (undefined4 *)0x0;

          if (puVar10 != (undefined4 *)0x0) {

            puVar10[1] = 0;

            puVar10[3] = 0;

            puVar10[4] = 0;

            puVar10[5] = 0;

            puVar10[2] = &PTR_FUN_00795074;

            puVar9 = puVar10;

          }

          FUN_0040ad10(4);

          puVar10 = (undefined4 *)FUN_0040acf0(4);

          if (puVar10 != (undefined4 *)0x0) {

            if ((*(byte *)(uVar4 + 4) & 1) == 0) {

              *puVar9 = *puVar10;

            }

            else {

              *puVar10 = *puVar9;

            }

          }

          FUN_00682bd0(uVar4);

          if ((*(uint *)(uVar4 + 4) >> 2 & 1) != 0) break;

          cVar5 = FUN_00599310(puVar9,puVar12);

          if (cVar5 == '\0') goto LAB_00683657;

          uVar11 = uVar11 + 1;

          puVar12 = puVar9;

          if (param_3 <= uVar11) {

            return;

          }

        }

      }

    }

  }

  return;

}





// --- FUN_00683670 at 0x00683670 (size: 58) ---


void __fastcall FUN_00683670(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007ffc98;

  FUN_00682f90();

  param_1[1] = &PTR_FUN_007ff974;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  return;

}





// --- FUN_006836b0 at 0x006836B0 (size: 82) ---


undefined4 * __thiscall FUN_006836b0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007ffc98;

  FUN_00682f90();

  param_1[1] = &PTR_FUN_007ff974;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00683710 at 0x00683710 (size: 22) ---


void __thiscall FUN_00683710(undefined4 param_1,undefined4 param_2)



{

  FUN_00683450(&param_2,param_1,param_2);

  return;

}





// --- FUN_00683730 at 0x00683730 (size: 41) ---


undefined4 * __fastcall FUN_00683730(undefined4 *param_1)



{

  FUN_00415460(DAT_008f89cc);

  *param_1 = &PTR_LAB_007ffca0;

  param_1[0xc] = &PTR_FUN_007ffc98;

  FUN_006829d0(0x17);

  return param_1;

}





// --- FUN_00683780 at 0x00683780 (size: 40) ---


void * __thiscall FUN_00683780(void *param_1,byte param_2)



{

  FUN_00683670();

  FUN_004154b0();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_006837b0 at 0x006837B0 (size: 573) ---


void FUN_006837b0(undefined4 param_1,int param_2,uint param_3)



{

  int iVar1;

  undefined *puVar2;

  undefined *puVar3;

  uint uVar4;

  char cVar5;

  undefined *puVar6;

  byte *pbVar7;

  int *piVar8;

  undefined4 *puVar9;

  undefined4 *puVar10;

  uint uVar11;

  undefined4 *puVar12;

  undefined1 local_c [12];

  

  uVar4 = param_3;

  if ((~*(byte *)(param_3 + 4) & 1) != 0) {

    FUN_005c2c80();

  }

  puVar3 = PTR_DAT_00818558;

  puVar2 = PTR_DAT_00818554;

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x68);

    puVar6 = (undefined *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_3,param_3,0);

    if (puVar6 == puVar3) {

      puVar6 = puVar6 + -4;

    }

    uVar11 = (int)puVar6 - (int)puVar2 >> 2;

  }

  else {

    uVar11 = param_3 & 0xff;

  }

  FUN_0040ad10(1);

  pbVar7 = (byte *)FUN_0040acf0(1);

  if (pbVar7 != (byte *)0x0) {

    if ((*(byte *)(uVar4 + 4) & 1) == 0) {

      uVar11 = (uint)*pbVar7;

    }

    else {

      *pbVar7 = (byte)uVar11;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    if ((uVar11 & 0xff) < DAT_007956cc) {

      FUN_0042ab60(*(undefined4 *)(PTR_DAT_00818554 + (uVar11 & 0xff) * 4));

    }

    else {

      FUN_0040aa50();

    }

  }

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x6c);

  }

  FUN_00401a80(&param_3,&param_3,uVar4);

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    piVar8 = (int *)FUN_0052dcf0(local_c);

    iVar1 = *piVar8;

    puVar12 = (undefined4 *)piVar8[1];

    puVar9 = (undefined4 *)piVar8[2];

LAB_006838b2:

    puVar10 = puVar9;

    if (puVar9 != (undefined4 *)0x0) {

      do {

        FUN_0040ad10(4);

        puVar9 = (undefined4 *)FUN_0040acf0(4);

        if (puVar9 != (undefined4 *)0x0) {

          if ((*(byte *)(uVar4 + 4) & 1) == 0) {

            *puVar10 = *puVar9;

          }

          else {

            *puVar9 = *puVar10;

          }

        }

        if ((~*(byte *)(uVar4 + 4) & 1) != 0) {

          FUN_00682d50();

        }

        FUN_00683710(uVar4);

        puVar10 = (undefined4 *)puVar10[1];

      } while (puVar10 != (undefined4 *)0x0);

      do {

        puVar12 = puVar12 + 1;

        puVar9 = puVar10;

        if (puVar12 == (undefined4 *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) break;

        puVar9 = (undefined4 *)*puVar12;

      } while (puVar9 == (undefined4 *)0x0);

      goto LAB_006838b2;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    uVar11 = FUN_0040a8f0();

    if (uVar11 < param_3) {

LAB_006839de:

      FUN_0040aa50();

    }

    else {

      uVar11 = 0;

      puVar12 = (undefined4 *)0x0;

      if (param_3 != 0) {

        while( true ) {

          puVar9 = (undefined4 *)FUN_005df0f5(0x7c);

          if (puVar9 == (undefined4 *)0x0) {

            puVar9 = (undefined4 *)0x0;

          }

          else {

            puVar9[1] = 0;

            puVar9[2] = &PTR_FUN_007ffc9c;

            FUN_00682a60(0x17);

          }

          FUN_0040ad10(4);

          puVar10 = (undefined4 *)FUN_0040acf0(4);

          if (puVar10 != (undefined4 *)0x0) {

            if ((*(byte *)(uVar4 + 4) & 1) == 0) {

              *puVar9 = *puVar10;

            }

            else {

              *puVar10 = *puVar9;

            }

          }

          if ((~*(byte *)(uVar4 + 4) & 1) != 0) {

            FUN_00682d50();

          }

          FUN_00683710(uVar4);

          if ((*(uint *)(uVar4 + 4) >> 2 & 1) != 0) break;

          cVar5 = FUN_00599310(puVar9,puVar12);

          if (cVar5 == '\0') goto LAB_006839de;

          uVar11 = uVar11 + 1;

          puVar12 = puVar9;

          if (param_3 <= uVar11) {

            return;

          }

        }

      }

    }

  }

  return;

}





// --- FUN_00683a30 at 0x00683A30 (size: 70) ---


undefined4 FUN_00683a30(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  int *piVar1;

  undefined4 uVar2;

  

  piVar1 = (int *)FUN_00415730(0x11,2,0x14);

  if (piVar1 == (int *)0x0) {

    return 2;

  }

  uVar2 = FUN_00683350(param_1,param_2,param_3,param_4);

  (**(code **)(*piVar1 + 0x14))();

  return uVar2;

}





// --- FUN_00683a80 at 0x00683A80 (size: 29) ---


undefined4 FUN_00683a80(undefined4 param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  if (DAT_008f8a50 != 0) {

    uVar1 = FUN_00683fb0(param_1,param_2);

    return uVar1;

  }

  return 0;

}





// --- FUN_00683aa0 at 0x00683AA0 (size: 70) ---


int __thiscall FUN_00683aa0(int param_1,undefined4 param_2)



{

  LONG *pLVar1;

  

  pLVar1 = (LONG *)(PTR_DAT_00818340 + -0x10);

  *(undefined **)(param_1 + 4) = PTR_DAT_00818340;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(PTR_DAT_00818340 + -0x10);

  *(undefined **)(param_1 + 8) = PTR_DAT_00818340;

  InterlockedIncrement(pLVar1);

  FUN_00541f90(param_2);

  *(undefined4 *)(param_1 + 0xc) = 0;

  *(undefined4 *)(param_1 + 0x10) = 0;

  return param_1;

}





// --- FUN_00683af0 at 0x00683AF0 (size: 70) ---


int * __thiscall FUN_00683af0(int param_1,int *param_2,undefined2 *param_3)



{

  undefined2 *puVar1;

  int iVar2;

  

  puVar1 = *(undefined2 **)(param_1 + 0x10);

  if (puVar1 != (undefined2 *)0x0) {

    *param_3 = *puVar1;

    iVar2 = *(int *)(puVar1 + 2);

    *param_2 = iVar2;

    InterlockedIncrement((LONG *)(iVar2 + -0x10));

    return param_2;

  }

  *param_3 = 0;

  FUN_00402730(&DAT_00795320);

  return param_2;

}





// --- FUN_00683b40 at 0x00683B40 (size: 275) ---


undefined4 __thiscall FUN_00683b40(int param_1,short param_2,int *param_3)



{

  LONG *lpAddend;

  LONG *lpAddend_00;

  short *psVar1;

  int iVar2;

  undefined *puVar3;

  undefined *puVar4;

  LONG LVar5;

  undefined4 *puVar6;

  

  puVar3 = PTR_DAT_00818340;

  lpAddend = (LONG *)(PTR_DAT_00818340 + -0x10);

  InterlockedIncrement(lpAddend);

  puVar4 = PTR_DAT_00818340;

  lpAddend_00 = (LONG *)(PTR_DAT_00818340 + -0x10);

  InterlockedIncrement(lpAddend_00);

  InterlockedIncrement(lpAddend_00);

  InterlockedIncrement(lpAddend);

  puVar6 = (undefined4 *)(puVar4 + -0x14);

  LVar5 = InterlockedDecrement((LONG *)(puVar4 + -0x10));

  if ((LVar5 == 0) && (puVar6 != (undefined4 *)0x0)) {

    (**(code **)*puVar6)(1);

  }

  puVar6 = (undefined4 *)(puVar3 + -0x14);

  LVar5 = InterlockedDecrement((LONG *)(puVar3 + -0x10));

  if ((LVar5 == 0) && (puVar6 != (undefined4 *)0x0)) {

    (**(code **)*puVar6)(1);

  }

  psVar1 = *(short **)(param_1 + 0x10);

  do {

    if (psVar1 == (short *)0x0) {

LAB_00683be7:

      FUN_00407e40(&DAT_00795320);

      FUN_00541f40();

      return 0;

    }

    if (*psVar1 == param_2) {

      if (psVar1 != (short *)0x0) {

        iVar2 = *param_3;

        if (iVar2 != *(int *)(psVar1 + 2)) {

          LVar5 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

          if ((LVar5 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

            (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

          }

          iVar2 = *(int *)(psVar1 + 2);

          *param_3 = iVar2;

          InterlockedIncrement((LONG *)(iVar2 + -0x10));

        }

        FUN_00541f40();

        return 1;

      }

      goto LAB_00683be7;

    }

    psVar1 = *(short **)(psVar1 + 6);

  } while( true );

}





// --- FUN_00683c60 at 0x00683C60 (size: 119) ---


undefined4 __thiscall FUN_00683c60(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = FUN_005df0f5(0x14);

  if (iVar1 != 0) {

    iVar1 = FUN_00683aa0(param_3);

    if (iVar1 != 0) {

      if (*(int *)(param_1 + 4) == 0) {

        *(int *)(param_1 + 4) = iVar1;

        *(int *)(param_1 + 8) = iVar1;

        *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

        return 1;

      }

      *(int *)(iVar1 + 0xc) = param_2;

      *(undefined4 *)(iVar1 + 0x10) = *(undefined4 *)(param_2 + 0x10);

      if (*(int *)(param_2 + 0x10) != 0) {

        *(int *)(*(int *)(param_2 + 0x10) + 0xc) = iVar1;

        *(int *)(param_2 + 0x10) = iVar1;

        *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

        return 1;

      }

      *(int *)(param_1 + 4) = iVar1;

      *(int *)(param_2 + 0x10) = iVar1;

      *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

      return 1;

    }

  }

  return 0;

}





// --- FUN_00683ce0 at 0x00683CE0 (size: 187) ---


undefined4 __thiscall FUN_00683ce0(int param_1,ushort *param_2)



{

  int iVar1;

  ushort *puVar2;

  int iVar3;

  undefined4 uVar4;

  LONG *pLVar5;

  

  puVar2 = *(ushort **)(param_1 + 4);

  if (puVar2 != (ushort *)0x0) {

    do {

      if (*param_2 < *puVar2) {

        if (puVar2 != (ushort *)0x0) {

          uVar4 = FUN_00683c60(puVar2,param_2);

          return uVar4;

        }

        break;

      }

      puVar2 = *(ushort **)(puVar2 + 6);

    } while (puVar2 != (ushort *)0x0);

  }

  iVar3 = FUN_005df0f5(0x14);

  if (iVar3 == 0) {

    return 0;

  }

  pLVar5 = (LONG *)(PTR_DAT_00818340 + -0x10);

  *(undefined **)(iVar3 + 4) = PTR_DAT_00818340;

  InterlockedIncrement(pLVar5);

  pLVar5 = (LONG *)(PTR_DAT_00818340 + -0x10);

  *(undefined **)(iVar3 + 8) = PTR_DAT_00818340;

  InterlockedIncrement(pLVar5);

  FUN_00541f90(param_2);

  *(undefined4 *)(iVar3 + 0xc) = 0;

  *(undefined4 *)(iVar3 + 0x10) = 0;

  if (*(int *)(param_1 + 4) != 0) {

    iVar1 = *(int *)(param_1 + 8);

    *(int *)(iVar1 + 0xc) = iVar3;

    *(int *)(iVar3 + 0x10) = iVar1;

    *(int *)(param_1 + 8) = iVar3;

    *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

    return 1;

  }

  *(int *)(param_1 + 4) = iVar3;

  *(int *)(param_1 + 8) = iVar3;

  *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

  return 1;

}





// --- FUN_00683da0 at 0x00683DA0 (size: 183) ---


undefined1 __thiscall FUN_00683da0(int param_1,short param_2,int *param_3,int *param_4)



{

  short *psVar1;

  LONG LVar2;

  int iVar3;

  int iVar4;

  short local_c [2];

  int local_8;

  int local_4;

  

  iVar3 = *param_3;

  local_c[0] = param_2;

  local_8 = iVar3;

  InterlockedIncrement((LONG *)(iVar3 + -0x10));

  iVar4 = *param_4;

  local_4 = iVar4;

  InterlockedIncrement((LONG *)(iVar4 + -0x10));

  psVar1 = *(short **)(param_1 + 0x10);

  do {

    if (psVar1 == (short *)0x0) {

      param_2._0_1_ = FUN_00683ce0(local_c);

      iVar3 = local_8;

      iVar4 = local_4;

LAB_00683e0a:

      LVar2 = InterlockedDecrement((LONG *)(iVar4 + -0x10));

      if ((LVar2 == 0) && ((undefined4 *)(iVar4 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(iVar4 + -0x14))(1);

      }

      LVar2 = InterlockedDecrement((LONG *)(iVar3 + -0x10));

      if ((LVar2 == 0) && ((undefined4 *)(iVar3 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(iVar3 + -0x14))(1);

      }

      return (undefined1)param_2;

    }

    if (*psVar1 == param_2) {

      param_2._0_1_ = 0;

      goto LAB_00683e0a;

    }

    psVar1 = *(short **)(psVar1 + 6);

  } while( true );

}





// --- FUN_00683e60 at 0x00683E60 (size: 143) ---


undefined4 * __thiscall

FUN_00683e60(undefined4 *param_1,int param_2,int *param_3,undefined4 param_4,undefined4 param_5)



{

  param_1[1] = 1;

  *param_1 = &PTR_FUN_007ffd18;

  param_1[2] = 0x10100;

  param_1[3] = &PTR_FUN_007cac50;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  *(undefined1 *)(param_1 + 7) = 0;

  FUN_00683da0(param_5,param_3,param_4);

  if (param_2 == 0) {

    param_1[2] = 0x10100;

  }

  else if (param_2 == 1) {

    param_1[2] = 0x100;

  }

  else if (param_2 == 2) {

    param_1[2] = 0x10410500;

  }

  if ((*(int *)(*param_3 + -4) != 1) && (DAT_008f8a50 != 0)) {

    FUN_006840a0(param_1);

  }

  return param_1;

}





// --- FUN_00683ef0 at 0x00683EF0 (size: 39) ---


undefined4 * __thiscall FUN_00683ef0(undefined4 *param_1,byte param_2)



{

  FUN_00542290();

  *param_1 = &PTR_FUN_007952f4;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00683f30 at 0x00683F30 (size: 29) ---


undefined4 __fastcall FUN_00683f30(undefined4 param_1,undefined4 *param_2)



{

  if (DAT_008f8a50 != 0) {

    *param_2 = *(undefined4 *)(DAT_008f8a50 + 0x18);

    return 1;

  }

  *param_2 = 0;

  return 0;

}





// --- FUN_00683f50 at 0x00683F50 (size: 86) ---


undefined4 __thiscall FUN_00683f50(int param_1,undefined4 *param_2)



{

  int iVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)FUN_005df0f5(0xc);

  if (puVar2 == (undefined4 *)0x0) {

    return 0;

  }

  *puVar2 = *param_2;

  puVar2[1] = 0;

  puVar2[2] = 0;

  if (*(int *)(param_1 + 4) == 0) {

    *(undefined4 **)(param_1 + 4) = puVar2;

    *(undefined4 **)(param_1 + 8) = puVar2;

    *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

    return 1;

  }

  iVar1 = *(int *)(param_1 + 8);

  *(undefined4 **)(iVar1 + 4) = puVar2;

  puVar2[2] = iVar1;

  *(undefined4 **)(param_1 + 8) = puVar2;

  *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

  return 1;

}





// --- FUN_00683fb0 at 0x00683FB0 (size: 233) ---


int __thiscall FUN_00683fb0(int param_1,undefined4 *param_2,undefined4 param_3)



{

  int *piVar1;

  char cVar2;

  int iVar3;

  LONG LVar4;

  wchar_t *pwVar5;

  wchar_t *local_4;

  

  piVar1 = *(int **)(param_1 + 0x10);

  local_4 = (wchar_t *)PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  do {

    if (piVar1 == (int *)0x0) {

      pwVar5 = local_4 + -10;

      LVar4 = InterlockedDecrement((LONG *)(local_4 + -8));

      if ((LVar4 == 0) && (pwVar5 != (wchar_t *)0x0)) {

        (*(code *)**(undefined4 **)pwVar5)(1);

      }

      return 0;

    }

    cVar2 = (**(code **)(*(int *)*piVar1 + 8))(param_3,&local_4);

    if ((cVar2 != '\0') &&

       (pwVar5 = (wchar_t *)*param_2, *(int *)(pwVar5 + -2) == *(int *)(local_4 + -2))) {

      if (((*(int *)(pwVar5 + -4) == *(int *)(local_4 + -4)) ||

          ((*(int *)(pwVar5 + -4) == -1 || (*(int *)(local_4 + -4) == -1)))) &&

         (iVar3 = wcscmp(pwVar5,local_4), iVar3 == 0)) {

        InterlockedIncrement((LONG *)(*piVar1 + 4));

        iVar3 = *piVar1;

        pwVar5 = local_4 + -10;

        LVar4 = InterlockedDecrement((LONG *)(local_4 + -8));

        if ((LVar4 == 0) && (pwVar5 != (wchar_t *)0x0)) {

          (*(code *)**(undefined4 **)pwVar5)(1);

        }

        return iVar3;

      }

    }

    piVar1 = (int *)piVar1[1];

  } while( true );

}





// --- FUN_006840a0 at 0x006840A0 (size: 205) ---


undefined1 __thiscall FUN_006840a0(int param_1,int param_2)



{

  int iVar1;

  undefined1 uVar2;

  int iVar3;

  LONG LVar4;

  int local_8;

  undefined4 local_4;

  

  iVar1 = param_2;

  if (((*(int *)(param_1 + 8) == 0) || (*(int *)(*(int *)(param_1 + 8) + 0x14) == 0)) &&

     (*(char *)(param_1 + 0x1c) == '\0')) {

    local_4 = 0;

    FUN_00683af0(&local_8,&local_4);

    iVar3 = FUN_00683fb0(&local_8,local_4);

    if (iVar3 != 0) {

      FUN_00405f70();

      LVar4 = InterlockedDecrement((LONG *)(local_8 + -0x10));

      if ((LVar4 == 0) && ((undefined4 *)(local_8 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(local_8 + -0x14))(1);

      }

      return 0;

    }

    InterlockedIncrement((LONG *)(iVar1 + 4));

    uVar2 = FUN_00683f50(&param_2);

    LVar4 = InterlockedDecrement((LONG *)(local_8 + -0x10));

    if ((LVar4 == 0) && ((undefined4 *)(local_8 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(local_8 + -0x14))(1);

    }

    return uVar2;

  }

  return 0;

}





// --- FUN_00684170 at 0x00684170 (size: 82) ---


void __fastcall FUN_00684170(int *param_1)



{

  int iVar1;

  int iVar2;

  

  param_1[2] = 0;

  if ((param_1[1] & 0x80000000U) == 0x80000000) {

    operator_delete__((void *)*param_1);

    *param_1 = 0;

    param_1[1] = 0;

    return;

  }

  if (*param_1 != 0) {

    iVar2 = (param_1[1] & 0x7fffffffU) - 1;

    while (-1 < iVar2) {

      iVar2 = iVar2 + -1;

      iVar1 = *param_1;

      *(undefined4 *)(iVar1 + 8 + iVar2 * 8) = 0;

      *(undefined4 *)(iVar1 + 0xc + iVar2 * 8) = 0;

    }

  }

  return;

}





// --- FUN_006841d0 at 0x006841D0 (size: 116) ---


undefined4 __fastcall FUN_006841d0(int param_1)



{

  void *pvVar1;

  int *piVar2;

  int iVar3;

  undefined4 *puVar4;

  LONG LVar5;

  

  pvVar1 = *(void **)(param_1 + 8);

  if (pvVar1 != (void *)0x0) {

    FUN_006baa50();

    operator_delete(pvVar1);

    *(undefined4 *)(param_1 + 8) = 0;

  }

  while (*(int *)(param_1 + 0x10) != 0) {

    piVar2 = *(int **)(param_1 + 0x10);

    if (piVar2 != (int *)0x0) {

      iVar3 = piVar2[1];

      *(int *)(param_1 + 0x10) = iVar3;

      if (iVar3 == 0) {

        *(undefined4 *)(param_1 + 0x14) = 0;

      }

      else {

        *(undefined4 *)(iVar3 + 8) = 0;

      }

      puVar4 = (undefined4 *)*piVar2;

      operator_delete(piVar2);

      *(int *)(param_1 + 0x18) = *(int *)(param_1 + 0x18) + -1;

      LVar5 = InterlockedDecrement(puVar4 + 1);

      if ((LVar5 == 0) && (puVar4 != (undefined4 *)0x0)) {

        (**(code **)*puVar4)(1);

      }

    }

  }

  return 1;

}





// --- FUN_00684250 at 0x00684250 (size: 164) ---


undefined4 __thiscall FUN_00684250(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  if (param_2 < (uint)param_1[2]) {

    return 0;

  }

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    if (param_2 != 0) {

      iVar2 = thunk_FUN_005df0f5(param_2 * 8);

      if (iVar2 == 0) {

        return 0;

      }

      if (*param_1 != 0) {

        iVar3 = param_1[2] + -1;

        while (-1 < iVar3) {

          iVar3 = iVar3 + -1;

          iVar1 = *param_1;

          *(undefined4 *)(iVar2 + 8 + iVar3 * 8) = *(undefined4 *)(iVar1 + 8 + iVar3 * 8);

          *(undefined4 *)(iVar2 + 0xc + iVar3 * 8) = *(undefined4 *)(iVar1 + 0xc + iVar3 * 8);

        }

        if ((param_1[1] & 0x80000000U) == 0x80000000) {

          operator_delete__((void *)*param_1);

        }

      }

      *param_1 = iVar2;

      param_1[1] = param_2 | 0x80000000;

      return 1;

    }

    FUN_00684170();

  }

  return 1;

}





// --- FUN_00684300 at 0x00684300 (size: 53) ---


void __fastcall FUN_00684300(int param_1)



{

  void *pvVar1;

  int iVar2;

  

  while (pvVar1 = *(void **)(param_1 + 4), pvVar1 != (void *)0x0) {

    iVar2 = *(int *)((int)pvVar1 + 4);

    *(int *)(param_1 + 4) = iVar2;

    if (iVar2 == 0) {

      *(undefined4 *)(param_1 + 8) = 0;

    }

    else {

      *(undefined4 *)(iVar2 + 8) = 0;

    }

    if (pvVar1 != (void *)0x0) {

      operator_delete(pvVar1);

    }

    *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + -1;

  }

  return;

}





// --- FUN_00684340 at 0x00684340 (size: 36) ---


undefined4 * __thiscall FUN_00684340(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007ffd48;

  FUN_00684300();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00684370 at 0x00684370 (size: 171) ---


int __thiscall FUN_00684370(int param_1,int *param_2)



{

  int *piVar1;

  undefined4 uVar2;

  int iVar3;

  char cVar4;

  int iVar5;

  uint uVar6;

  uint uVar7;

  

  piVar1 = *(int **)(param_1 + 0x10);

  iVar5 = 0;

  do {

    if (piVar1 == (int *)0x0) {

      return iVar5;

    }

    uVar2 = *(undefined4 *)(*piVar1 + 8);

    if ((uint)param_2[2] < (param_2[1] & 0x7fffffffU)) {

LAB_006843f7:

      *(undefined4 *)(*param_2 + param_2[2] * 4) = uVar2;

      param_2[2] = param_2[2] + 1;

    }

    else {

      uVar6 = (param_2[1] & 0x7fffffffU) + 1;

      if (uVar6 < 9) {

        uVar6 = 8;

      }

      else if (uVar6 < 0x4001) {

        iVar3 = 0x1f;

        if (uVar6 != 0) {

          for (; uVar6 >> iVar3 == 0; iVar3 = iVar3 + -1) {

          }

        }

        uVar7 = 1 << ((byte)iVar3 & 0x1f);

        if (uVar7 < uVar6) {

          uVar6 = uVar7 * 2;

        }

      }

      else if ((uVar6 & 0x3fff) != 0) {

        uVar6 = uVar6 + (0x4000 - (uVar6 & 0x3fff));

      }

      cVar4 = FUN_004180a0(uVar6);

      if (cVar4 != '\0') goto LAB_006843f7;

    }

    piVar1 = (int *)piVar1[1];

    iVar5 = iVar5 + 1;

  } while( true );

}





// --- FUN_00684420 at 0x00684420 (size: 193) ---


int __thiscall FUN_00684420(int param_1,int *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  int iVar3;

  char cVar4;

  int iVar5;

  uint uVar6;

  uint uVar7;

  undefined8 uVar8;

  

  puVar1 = *(undefined4 **)(param_1 + 0x10);

  iVar5 = 0;

  do {

    if (puVar1 == (undefined4 *)0x0) {

      return iVar5;

    }

    uVar8 = (**(code **)(*(int *)*puVar1 + 4))();

    if ((uint)param_2[2] < (param_2[1] & 0x7fffffffU)) {

LAB_006844af:

      iVar2 = param_2[2];

      iVar3 = *param_2;

      *(int *)(iVar3 + iVar2 * 8) = (int)uVar8;

      *(int *)(iVar3 + 4 + iVar2 * 8) = (int)((ulonglong)uVar8 >> 0x20);

      param_2[2] = param_2[2] + 1;

    }

    else {

      uVar6 = (param_2[1] & 0x7fffffffU) + 1;

      if (uVar6 < 9) {

        uVar6 = 8;

      }

      else if (uVar6 < 0x4001) {

        iVar2 = 0x1f;

        if (uVar6 != 0) {

          for (; uVar6 >> iVar2 == 0; iVar2 = iVar2 + -1) {

          }

        }

        uVar7 = 1 << ((byte)iVar2 & 0x1f);

        if (uVar7 < uVar6) {

          uVar6 = uVar7 * 2;

        }

      }

      else if ((uVar6 & 0x3fff) != 0) {

        uVar6 = uVar6 + (0x4000 - (uVar6 & 0x3fff));

      }

      cVar4 = FUN_00684250(uVar6);

      if (cVar4 != '\0') goto LAB_006844af;

    }

    puVar1 = (undefined4 *)puVar1[1];

    iVar5 = iVar5 + 1;

  } while( true );

}





// --- FUN_006844f0 at 0x006844F0 (size: 198) ---


undefined4 __fastcall FUN_006844f0(undefined4 param_1,uint param_2,undefined4 *param_3)



{

  char cVar1;

  uint uVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *local_c;

  uint local_8;

  undefined4 local_4;

  

  puVar4 = param_3;

  for (uVar2 = param_2 & 0x3fffffff; uVar2 != 0; uVar2 = uVar2 - 1) {

    *puVar4 = 0;

    puVar4 = puVar4 + 1;

  }

  for (iVar3 = 0; iVar3 != 0; iVar3 = iVar3 + -1) {

    *(undefined1 *)puVar4 = 0;

    puVar4 = (undefined4 *)((int)puVar4 + 1);

  }

  if (DAT_008f8a50 != 0) {

    local_c = (undefined4 *)0x0;

    local_8 = 0;

    local_4 = 0;

    cVar1 = FUN_004180a0(*(undefined4 *)(DAT_008f8a50 + 0x18));

    if (cVar1 != '\0') {

      FUN_00684370(&local_c);

      puVar4 = local_c;

      for (param_2 = param_2 & 0x3fffffff; param_2 != 0; param_2 = param_2 - 1) {

        *param_3 = *puVar4;

        puVar4 = puVar4 + 1;

        param_3 = param_3 + 1;

      }

      for (iVar3 = 0; iVar3 != 0; iVar3 = iVar3 + -1) {

        *(undefined1 *)param_3 = *(undefined1 *)puVar4;

        puVar4 = (undefined4 *)((int)puVar4 + 1);

        param_3 = (undefined4 *)((int)param_3 + 1);

      }

      if ((local_8 & 0x80000000) == 0x80000000) {

        operator_delete__(local_c);

      }

      return 1;

    }

    if ((local_8 & 0x80000000) == 0x80000000) {

      operator_delete__(local_c);

    }

  }

  return 0;

}





// --- FUN_006845c0 at 0x006845C0 (size: 198) ---


undefined4 __fastcall FUN_006845c0(undefined4 param_1,int param_2,undefined4 *param_3)



{

  char cVar1;

  uint uVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *local_c;

  uint local_8;

  undefined4 local_4;

  

  puVar4 = param_3;

  for (uVar2 = (uint)(param_2 * 8) >> 2; uVar2 != 0; uVar2 = uVar2 - 1) {

    *puVar4 = 0;

    puVar4 = puVar4 + 1;

  }

  for (iVar3 = 0; iVar3 != 0; iVar3 = iVar3 + -1) {

    *(undefined1 *)puVar4 = 0;

    puVar4 = (undefined4 *)((int)puVar4 + 1);

  }

  if (DAT_008f8a50 != 0) {

    local_c = (undefined4 *)0x0;

    local_8 = 0;

    local_4 = 0;

    cVar1 = FUN_00684250(*(undefined4 *)(DAT_008f8a50 + 0x18));

    if (cVar1 != '\0') {

      FUN_00684420(&local_c);

      puVar4 = local_c;

      for (uVar2 = (uint)(param_2 * 8) >> 2; uVar2 != 0; uVar2 = uVar2 - 1) {

        *param_3 = *puVar4;

        puVar4 = puVar4 + 1;

        param_3 = param_3 + 1;

      }

      for (iVar3 = 0; iVar3 != 0; iVar3 = iVar3 + -1) {

        *(undefined1 *)param_3 = *(undefined1 *)puVar4;

        puVar4 = (undefined4 *)((int)puVar4 + 1);

        param_3 = (undefined4 *)((int)param_3 + 1);

      }

      if ((local_8 & 0x80000000) == 0x80000000) {

        operator_delete__(local_c);

      }

      return 1;

    }

    if ((local_8 & 0x80000000) == 0x80000000) {

      operator_delete__(local_c);

    }

  }

  return 0;

}





// --- FUN_00684690 at 0x00684690 (size: 67) ---


undefined4 * __thiscall FUN_00684690(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007ffd4c;

  FUN_006841d0();

  DAT_008f8a50 = 0;

  param_1[3] = &PTR_FUN_007ffd48;

  FUN_00684300();

  FUN_0040e420();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_006846e0 at 0x006846E0 (size: 324) ---


void FUN_006846e0(PRPC_MESSAGE param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  undefined4 *puVar3;

  int iVar4;

  _MIDL_STUB_MESSAGE local_104;

  undefined4 *local_28;

  RPC_STATUS local_24;

  undefined4 local_20;

  undefined1 *local_1c;

  void *local_14;

  undefined *puStack_10;

  undefined *puStack_c;

  undefined4 local_8;

  

  local_8 = 0xffffffff;

  puStack_c = &DAT_007ffe38;

  puStack_10 = &DAT_005df82c;

  local_14 = ExceptionList;

  local_1c = &stack0xfffffef0;

  ExceptionList = &local_14;

  NdrServerInitializeNew(param_1,&local_104,(PMIDL_STUB_DESC)&PTR_DAT_007ffde8);

  local_8 = 1;

  if ((param_1->DataRepresentation & 0xffff) != 0x10) {

    NdrConvert(&local_104,"N\x0fP\x01\x02");

  }

  puVar1 = (undefined4 *)((uint)(local_104.Buffer + 3) & 0xfffffffc);

  local_104.Buffer = (uchar *)(puVar1 + 1);

  local_28 = puVar1;

  if (local_104.BufferEnd < local_104.Buffer) {

                    /* WARNING: Subroutine does not return */

    RpcRaiseException(0x6f7);

  }

  local_8 = 0;

  uVar2 = FUN_00683f30();

  local_104.BufferLength = 0x24;

  param_1->BufferLength = 0x24;

  local_20 = uVar2;

  local_24 = I_RpcGetBuffer(param_1);

  if (local_24 != 0) {

                    /* WARNING: Subroutine does not return */

    RpcRaiseException(local_24);

  }

  puVar3 = (undefined4 *)((int)param_1->Buffer + 3U & 0xfffffffc);

  *puVar3 = *puVar1;

  puVar3[1] = uVar2;

  local_104.Buffer = (uchar *)(puVar3 + 2);

  local_8 = 0xffffffff;

  iVar4 = FUN_00684867();

  param_1->BufferLength = iVar4 - (int)param_1->Buffer;

  ExceptionList = local_14;

  return;

}





// --- FUN_00684867 at 0x00684867 (size: 1) ---


void FUN_00684867(void)



{

  return;

}





// --- FUN_00684870 at 0x00684870 (size: 398) ---


void FUN_00684870(PRPC_MESSAGE param_1)



{

  ULONG_PTR UVar1;

  ULONG_PTR *pUVar2;

  uchar *pMemory;

  _MIDL_STUB_MESSAGE local_10c;

  RPC_STATUS local_30;

  ULONG_PTR local_2c;

  RPC_BINDING_HANDLE local_28;

  undefined4 local_24;

  uchar *local_20;

  undefined1 *local_1c;

  void *local_14;

  undefined *puStack_10;

  undefined *puStack_c;

  undefined4 local_8;

  

  local_8 = 0xffffffff;

  puStack_c = &DAT_007ffe50;

  puStack_10 = &DAT_005df82c;

  local_14 = ExceptionList;

  local_1c = &stack0xfffffee8;

  ExceptionList = &local_14;

  NdrServerInitializeNew(param_1,&local_10c,(PMIDL_STUB_DESC)&PTR_DAT_007ffde8);

  local_28 = param_1->Handle;

  local_20 = (uchar *)0x0;

  local_8 = 1;

  if ((param_1->DataRepresentation & 0xffff) != 0x10) {

    NdrConvert(&local_10c,"N\x0fN\bQ\x01\x06");

  }

  pUVar2 = (ULONG_PTR *)((uint)(local_10c.Buffer + 3) & 0xfffffffc);

  local_10c.Buffer = (uchar *)(pUVar2 + 1);

  if (local_10c.BufferEnd < local_10c.Buffer) {

    local_10c.Buffer = (uchar *)pUVar2;

                    /* WARNING: Subroutine does not return */

    RpcRaiseException(0x6f7);

  }

  UVar1 = *pUVar2;

  local_2c = UVar1;

  if (local_10c.BufferEnd < local_10c.Buffer) {

                    /* WARNING: Subroutine does not return */

    RpcRaiseException(0x6f7);

  }

  local_8 = 0;

  pMemory = NdrAllocate(&local_10c,UVar1 * 4);

  local_20 = pMemory;

  local_24 = FUN_006844f0(pMemory);

  local_10c.BufferLength = 8;

  local_10c.MaxCount = UVar1;

  NdrConformantArrayBufferSize(&local_10c,pMemory,"\x1b\x03\x04");

  param_1->BufferLength = local_10c.BufferLength;

  local_30 = I_RpcGetBuffer(param_1);

  if (local_30 != 0) {

                    /* WARNING: Subroutine does not return */

    RpcRaiseException(local_30);

  }

  local_10c.Buffer = param_1->Buffer;

  local_10c.MaxCount = UVar1;

  NdrConformantArrayMarshall(&local_10c,pMemory,"\x1b\x03\x04");

  *(undefined4 *)((uint)(local_10c.Buffer + 3) & 0xfffffffc) = local_24;

  local_10c.Buffer = (uchar *)((undefined4 *)((uint)(local_10c.Buffer + 3) & 0xfffffffc) + 1);

  local_8 = 0xffffffff;

  FUN_00684a3e();

  param_1->BufferLength = (int)local_10c.Buffer - (int)param_1->Buffer;

  ExceptionList = local_14;

  return;

}





// --- FUN_00684a3e at 0x00684A3E (size: 12) ---


void FUN_00684a3e(void)



{

  int unaff_EBP;

  int unaff_EDI;

  

  if (unaff_EDI != 0) {

    (**(code **)(unaff_EBP + -0xbc))();

  }

  return;

}





// --- FUN_00684a50 at 0x00684A50 (size: 398) ---


void FUN_00684a50(PRPC_MESSAGE param_1)



{

  ULONG_PTR UVar1;

  ULONG_PTR *pUVar2;

  uchar *pMemory;

  _MIDL_STUB_MESSAGE local_10c;

  RPC_STATUS local_30;

  ULONG_PTR local_2c;

  RPC_BINDING_HANDLE local_28;

  undefined4 local_24;

  uchar *local_20;

  undefined1 *local_1c;

  void *local_14;

  undefined *puStack_10;

  undefined *puStack_c;

  undefined4 local_8;

  

  local_8 = 0xffffffff;

  puStack_c = &DAT_007ffe68;

  puStack_10 = &DAT_005df82c;

  local_14 = ExceptionList;

  local_1c = &stack0xfffffee8;

  ExceptionList = &local_14;

  NdrServerInitializeNew(param_1,&local_10c,(PMIDL_STUB_DESC)&PTR_DAT_007ffde8);

  local_28 = param_1->Handle;

  local_20 = (uchar *)0x0;

  local_8 = 1;

  if ((param_1->DataRepresentation & 0xffff) != 0x10) {

    NdrConvert(&local_10c,"N\x0fN\bQ\x01\x10");

  }

  pUVar2 = (ULONG_PTR *)((uint)(local_10c.Buffer + 3) & 0xfffffffc);

  local_10c.Buffer = (uchar *)(pUVar2 + 1);

  if (local_10c.BufferEnd < local_10c.Buffer) {

    local_10c.Buffer = (uchar *)pUVar2;

                    /* WARNING: Subroutine does not return */

    RpcRaiseException(0x6f7);

  }

  UVar1 = *pUVar2;

  local_2c = UVar1;

  if (local_10c.BufferEnd < local_10c.Buffer) {

                    /* WARNING: Subroutine does not return */

    RpcRaiseException(0x6f7);

  }

  local_8 = 0;

  pMemory = NdrAllocate(&local_10c,UVar1 * 8);

  local_20 = pMemory;

  local_24 = FUN_006845c0(pMemory);

  local_10c.BufferLength = 8;

  local_10c.MaxCount = UVar1;

  NdrConformantArrayBufferSize(&local_10c,pMemory,"\x1b\a\b");

  param_1->BufferLength = local_10c.BufferLength;

  local_30 = I_RpcGetBuffer(param_1);

  if (local_30 != 0) {

                    /* WARNING: Subroutine does not return */

    RpcRaiseException(local_30);

  }

  local_10c.Buffer = param_1->Buffer;

  local_10c.MaxCount = UVar1;

  NdrConformantArrayMarshall(&local_10c,pMemory,"\x1b\a\b");

  *(undefined4 *)((uint)(local_10c.Buffer + 3) & 0xfffffffc) = local_24;

  local_10c.Buffer = (uchar *)((undefined4 *)((uint)(local_10c.Buffer + 3) & 0xfffffffc) + 1);

  local_8 = 0xffffffff;

  FUN_00684c1e();

  param_1->BufferLength = (int)local_10c.Buffer - (int)param_1->Buffer;

  ExceptionList = local_14;

  return;

}





// --- FUN_00684c1e at 0x00684C1E (size: 12) ---


void FUN_00684c1e(void)



{

  int unaff_EBP;

  int unaff_EDI;

  

  if (unaff_EDI != 0) {

    (**(code **)(unaff_EBP + -0xbc))();

  }

  return;

}





// --- FUN_00684c70 at 0x00684C70 (size: 10) ---


int __fastcall FUN_00684c70(int param_1)



{

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

}





// --- FUN_00684c80 at 0x00684C80 (size: 147) ---


undefined4 __fastcall FUN_00684c80(int param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  undefined4 *puVar3;

  LONG LVar4;

  LONG *lpAddend;

  

  puVar1 = (undefined4 *)**(int **)(param_1 + 0xc);

  InterlockedIncrement(puVar1 + 1);

  piVar2 = *(int **)(param_1 + 0xc);

  puVar3 = (undefined4 *)*piVar2;

  if (puVar3 != DAT_008ef11c) {

    LVar4 = InterlockedDecrement(puVar3 + 1);

    if ((LVar4 == 0) && (puVar3 != (undefined4 *)0x0)) {

      (**(code **)*puVar3)(1);

    }

    lpAddend = DAT_008ef11c + 1;

    *piVar2 = (int)DAT_008ef11c;

    InterlockedIncrement(lpAddend);

  }

  if (*(int *)(param_1 + 4) != 0) {

    FUN_004910c0(puVar1 + 5,*(int *)(param_1 + 4));

  }

  if (*(uint *)(param_1 + 4) < *(uint *)(param_1 + 8)) {

    *(uint *)(param_1 + 8) = *(uint *)(param_1 + 4);

  }

  LVar4 = InterlockedDecrement(puVar1 + 1);

  if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return 1;

}





// --- FUN_00684fb0 at 0x00684FB0 (size: 238) ---


undefined4 FUN_00684fb0(undefined4 *param_1,int *param_2)



{

  int iVar1;

  undefined4 *puVar2;

  char cVar3;

  int iVar4;

  char *pcVar5;

  LONG LVar6;

  

  iVar4 = (*(code *)PTR_FUN_007ffec4)();

  do {

    if (iVar4 == 0) goto LAB_0068500f;

    iVar4 = iVar4 + -1;

    cVar3 = (*(code *)PTR_LAB_007ffed4)(iVar4);

  } while (cVar3 != '.');

  FUN_00684c80();

LAB_0068500f:

  iVar4 = *param_2;

  iVar1 = *(int *)(iVar4 + 8);

  if (iVar1 != 1) {

    pcVar5 = (char *)(iVar1 + 0x13 + iVar4);

    if (iVar1 != 0) {

      pcVar5 = (char *)(iVar4 + 0x14);

    }

    if (*pcVar5 != '.') {

      FUN_0048c3e0(&DAT_00795530);

      if ((param_1[2] != 1) && (param_1 != DAT_008ef11c)) {

        FUN_004910c0(param_1 + 5,param_1[2] + -1);

      }

      LVar6 = InterlockedDecrement(param_1 + 1);

      if (LVar6 == 0) {

        (**(code **)*param_1)(1);

      }

    }

  }

  puVar2 = (undefined4 *)*param_2;

  if ((puVar2[2] != 1) && (puVar2 != DAT_008ef11c)) {

    FUN_004910c0(puVar2 + 5,puVar2[2] + -1);

  }

  return 1;

}





// --- FUN_006850a0 at 0x006850A0 (size: 108) ---


undefined4 FUN_006850a0(int *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  undefined4 *local_4;

  

  FUN_00546290(&local_4,0);

  puVar1 = (undefined4 *)*param_1;

  if (puVar1 != local_4) {

    LVar2 = InterlockedDecrement(puVar1 + 1);

    if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    *param_1 = (int)local_4;

    InterlockedIncrement(local_4 + 1);

  }

  LVar2 = InterlockedDecrement(local_4 + 1);

  if ((LVar2 == 0) && (local_4 != (undefined4 *)0x0)) {

    (**(code **)*local_4)(1);

  }

  return 1;

}





// --- FUN_00685110 at 0x00685110 (size: 92) ---


undefined4 * FUN_00685110(undefined4 *param_1,undefined4 param_2)



{

  LONG *lpAddend;

  undefined4 *puVar1;

  LONG LVar2;

  undefined4 *local_4;

  

  local_4 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_006850a0(&local_4,param_2);

  puVar1 = local_4;

  lpAddend = local_4 + 1;

  *param_1 = local_4;

  InterlockedIncrement(lpAddend);

  LVar2 = InterlockedDecrement(lpAddend);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return param_1;

}





// --- FUN_00685170 at 0x00685170 (size: 594) ---


undefined4 FUN_00685170(uint param_1,int param_2)



{

  ulonglong uVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  int iVar7;

  undefined4 uVar8;

  int iVar9;

  undefined4 uVar10;

  undefined *puVar11;

  char *pcVar12;

  

  uVar2 = param_1 / 0x1e13380;

  iVar3 = (int)(((ulonglong)param_1 % 0x1e13380) / 0x278d00);

  uVar1 = ((ulonglong)param_1 % 0x1e13380) % 0x278d00;

  iVar4 = (int)(uVar1 / 0x93a80);

  uVar1 = uVar1 % 0x93a80;

  iVar5 = (int)(uVar1 / 0x15180);

  uVar1 = uVar1 % 0x15180;

  iVar6 = (int)(uVar1 / 0xe10);

  uVar1 = uVar1 % 0xe10;

  iVar7 = (int)(uVar1 / 0x3c);

  iVar9 = (int)(uVar1 % 0x3c);

  FUN_0042c980(2);

  uVar8 = FUN_004016b0("ID_DurationFormat");

  *(undefined4 *)(param_2 + 4) = uVar8;

  if (uVar2 == 0) {

    uVar10 = 0x7fff00;

    uVar8 = FUN_004016b0(0x7fff00);

    FUN_00401340(&DAT_007938af);

    FUN_0042e9f0(uVar8,uVar10);

  }

  else {

    uVar10 = 0;

    uVar8 = FUN_004016b0(0x7fff00,uVar2,0);

    FUN_0042e040(uVar8,uVar2,uVar10);

  }

  if (iVar3 == 0) {

    pcVar12 = "MONTHS";

    uVar8 = FUN_004016b0("MONTHS");

    FUN_00401340(&DAT_007938af);

    FUN_0042e9f0(uVar8,pcVar12);

  }

  else {

    uVar10 = 0;

    uVar8 = FUN_004016b0("MONTHS",iVar3,0);

    FUN_0042e040(uVar8,iVar3,uVar10);

  }

  if (iVar4 == 0) {

    pcVar12 = "WEEKS";

    uVar8 = FUN_004016b0("WEEKS");

    FUN_00401340(&DAT_007938af);

    FUN_0042e9f0(uVar8,pcVar12);

  }

  else {

    uVar10 = 0;

    uVar8 = FUN_004016b0("WEEKS",iVar4,0);

    FUN_0042e040(uVar8,iVar4,uVar10);

  }

  if (iVar5 == 0) {

    puVar11 = &DAT_007ffee8;

    uVar8 = FUN_004016b0(&DAT_007ffee8);

    FUN_00401340(&DAT_007938af);

    FUN_0042e9f0(uVar8,puVar11);

  }

  else {

    uVar10 = 0;

    uVar8 = FUN_004016b0(&DAT_007ffee8,iVar5,0);

    FUN_0042e040(uVar8,iVar5,uVar10);

  }

  if (iVar6 == 0) {

    pcVar12 = "HOURS";

    uVar8 = FUN_004016b0("HOURS");

    FUN_00401340(&DAT_007938af);

    FUN_0042e9f0(uVar8,pcVar12);

  }

  else {

    uVar10 = 0;

    uVar8 = FUN_004016b0("HOURS",iVar6,0);

    FUN_0042e040(uVar8,iVar6,uVar10);

  }

  if (iVar7 == 0) {

    pcVar12 = "MINUTES";

    uVar8 = FUN_004016b0("MINUTES");

    FUN_00401340(&DAT_007938af);

    FUN_0042e9f0(uVar8,pcVar12);

  }

  else {

    uVar10 = 0;

    uVar8 = FUN_004016b0("MINUTES",iVar7,0);

    FUN_0042e040(uVar8,iVar7,uVar10);

  }

  if (iVar9 != 0) {

    uVar10 = 0;

    uVar8 = FUN_004016b0("SECONDS",iVar9,0);

    FUN_0042e040(uVar8,iVar9,uVar10);

    return 1;

  }

  pcVar12 = "SECONDS";

  uVar8 = FUN_004016b0("SECONDS");

  FUN_00401340(&DAT_007938af);

  FUN_0042e9f0(uVar8,pcVar12);

  return 1;

}





// --- FUN_006853d0 at 0x006853D0 (size: 37) ---


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



float10 FUN_006853d0(double param_1,double param_2)



{

  int iVar1;

  

  iVar1 = rand();

  return ((float10)param_2 - (float10)param_1) * (float10)iVar1 * (float10)_DAT_007ce670 +

         (float10)param_1;

}





// --- FUN_00685400 at 0x00685400 (size: 24) ---


int FUN_00685400(int param_1)



{

  int iVar1;

  

  iVar1 = rand();

  return (int)(iVar1 * param_1 + (iVar1 * param_1 >> 0x1f & 0x7fffU)) >> 0xf;

}





// --- FUN_00685420 at 0x00685420 (size: 57) ---


int FUN_00685420(int param_1,int param_2)



{

  int iVar1;

  

  if (1 < param_1) {

    do {

      iVar1 = rand();

      iVar1 = (int)(iVar1 * param_1 + (iVar1 * param_1 >> 0x1f & 0x7fffU)) >> 0xf;

    } while (iVar1 == param_2);

    return iVar1;

  }

  return 0;

}





// --- FUN_00685460 at 0x00685460 (size: 31) ---


int FUN_00685460(uint param_1)



{

  int iVar1;

  

  iVar1 = 0;

  do {

    if ((param_1 & 1 << ((byte)iVar1 & 0x1f)) != 0) {

      return iVar1;

    }

    iVar1 = iVar1 + 1;

  } while (iVar1 < 0x20);

  return -1;

}





// --- FUN_00685480 at 0x00685480 (size: 108) ---


undefined4 FUN_00685480(int param_1,int param_2,int *param_3,uint param_4)



{

  int iVar1;

  uint uVar2;

  

  if (param_2 == 0) {

    param_2 = param_1;

  }

  uVar2 = param_2 - param_1;

  if (uVar2 < 0x4000) {

    if (1 < param_4) {

      *(short *)*param_3 = (short)uVar2;

      *param_3 = *param_3 + 2;

    }

    return 2;

  }

  if (uVar2 < 0x40000000) {

    if (3 < param_4) {

      *(ushort *)*param_3 = (ushort)(uVar2 >> 0x10) | 0x8000;

      iVar1 = *param_3;

      *param_3 = iVar1 + 2;

      *(short *)(iVar1 + 2) = (short)uVar2;

      *param_3 = *param_3 + 2;

    }

    return 4;

  }

  return 0;

}





// --- FUN_006854f0 at 0x006854F0 (size: 72) ---


undefined4 FUN_006854f0(int param_1,int *param_2,undefined4 *param_3)



{

  ushort uVar1;

  ushort uVar2;

  ushort *puVar3;

  

  puVar3 = (ushort *)*param_3;

  uVar1 = *puVar3;

  *param_3 = puVar3 + 1;

  if ((short)uVar1 < 0) {

    uVar2 = puVar3[1];

    *param_3 = puVar3 + 2;

    param_1 = ((uVar1 & 0x3fff) << 0x10 | (uint)uVar2) + param_1;

    *param_2 = param_1;

    return CONCAT31((int3)((uint)param_1 >> 8),1);

  }

  param_1 = (uint)uVar1 + param_1;

  *param_2 = param_1;

  return CONCAT31((int3)((uint)param_1 >> 8),1);

}





// --- FUN_00685540 at 0x00685540 (size: 85) ---


undefined4 FUN_00685540(uint param_1,int *param_2,uint param_3)



{

  int iVar1;

  

  if (param_1 < 0x8000) {

    if (1 < param_3) {

      *(short *)*param_2 = (short)param_1;

      *param_2 = *param_2 + 2;

    }

    return 2;

  }

  if (3 < param_3) {

    *(ushort *)*param_2 = (ushort)(param_1 >> 0x10) | 0x8000;

    iVar1 = *param_2;

    *param_2 = iVar1 + 2;

    *(short *)(iVar1 + 2) = (short)param_1;

    *param_2 = *param_2 + 2;

  }

  return 4;

}





// --- FUN_006855a0 at 0x006855A0 (size: 62) ---


undefined4 FUN_006855a0(uint *param_1,undefined4 *param_2)



{

  ushort uVar1;

  ushort uVar2;

  ushort *puVar3;

  uint uVar4;

  

  puVar3 = (ushort *)*param_2;

  uVar1 = *puVar3;

  *param_2 = puVar3 + 1;

  if ((short)uVar1 < 0) {

    uVar2 = puVar3[1];

    *param_2 = puVar3 + 2;

    uVar4 = (uVar1 & 0x7fff) << 0x10 | (uint)uVar2;

    *param_1 = uVar4;

    return CONCAT31((int3)(uVar4 >> 8),1);

  }

  *param_1 = (uint)uVar1;

  return CONCAT31((uint3)(byte)(uVar1 >> 8),1);

}





// --- FUN_006855e0 at 0x006855E0 (size: 134) ---


void __thiscall FUN_006855e0(undefined4 *param_1,int param_2)



{

  undefined4 *puVar1;

  

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      *param_1 = *puVar1;

    }

    else {

      *puVar1 = *param_1;

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      param_1[1] = *puVar1;

    }

    else {

      *puVar1 = param_1[1];

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) != 0) {

      *puVar1 = param_1[2];

      return;

    }

    param_1[2] = *puVar1;

  }

  return;

}





// --- FUN_00685670 at 0x00685670 (size: 134) ---


undefined4 __thiscall

FUN_00685670(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  char cVar1;

  

  FUN_0042dc80();

  FUN_0042ca10(*(undefined4 *)(param_1 + 8),param_2);

  cVar1 = FUN_0042e6b0(param_3,0);

  if (cVar1 == '\0') {

    FUN_0042e590();

    return 0;

  }

  if (*(int *)(param_1 + 0xc) != 0) {

    FUN_0042e6b0(param_4,0);

  }

  FUN_0042e590();

  return 1;

}





// --- FUN_00685700 at 0x00685700 (size: 64) ---


undefined4 * __thiscall FUN_00685700(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007fff2c;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00685740 at 0x00685740 (size: 64) ---


undefined4 * __thiscall FUN_00685740(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007fff30;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00685780 at 0x00685780 (size: 114) ---


void FUN_00685780(int param_1,int param_2)



{

  uint uVar1;

  int *piVar2;

  

  uVar1 = *(uint *)(param_2 + 4) & 5;

  if (uVar1 == 1) {

    FUN_0040ad10(4);

    piVar2 = (int *)FUN_0040acf0(4);

    if ((piVar2 != (int *)0x0) && ((*(byte *)(param_2 + 4) & 1) != 0)) {

      *piVar2 = param_1;

    }

  }

  else if (uVar1 == 0) {

    FUN_0040ad10(4);

    piVar2 = (int *)FUN_0040acf0(4);

    if (piVar2 != (int *)0x0) {

      if ((*(byte *)(param_2 + 4) & 1) == 0) {

        param_2 = *piVar2;

      }

      else {

        *piVar2 = param_2;

      }

    }

    if (param_2 != param_1) {

      FUN_0040aa50();

      return;

    }

  }

  return;

}





// --- FUN_00685800 at 0x00685800 (size: 143) ---


bool FUN_00685800(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  undefined *puVar1;

  char cVar2;

  LONG LVar3;

  undefined4 extraout_ECX;

  undefined *puVar4;

  undefined4 uVar5;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  FUN_00426020(&local_4);

  puVar1 = local_4;

  puVar4 = local_4;

  InterlockedIncrement((LONG *)(local_4 + -0x10));

  cVar2 = FUN_0041b8f0(param_2,puVar4,param_3);

  if (cVar2 == '\0') {

    uVar5 = extraout_ECX;

    puVar4 = puVar1;

    FUN_00401340("invalid emp value \'%s\'");

    FUN_0065d620(param_1,uVar5,puVar4);

  }

  LVar3 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

  if ((LVar3 == 0) && ((undefined4 *)(puVar1 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(puVar1 + -0x14))(1);

  }

  return cVar2 != '\0';

}





// --- FUN_00685890 at 0x00685890 (size: 88) ---


undefined4 __thiscall FUN_00685890(int param_1,uint *param_2,uint *param_3)



{

  uint *puVar1;

  uint uVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  while( true ) {

    if (puVar1 == (uint *)0x0) {

      return 0;

    }

    if (*puVar1 == *param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  *param_3 = puVar1[4];

  param_3[1] = puVar1[5];

  param_3[2] = puVar1[6];

  uVar2 = puVar1[7];

  param_3[3] = uVar2;

  return CONCAT31((int3)(uVar2 >> 8),1);

}





// --- FUN_006858f0 at 0x006858F0 (size: 316) ---


void __thiscall FUN_006858f0(int param_1,uint param_2)



{

  uint uVar1;

  uint uVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  uint *puVar5;

  uint uVar6;

  

  uVar1 = param_2;

  uVar2 = *(uint *)(param_2 + 4) & 5;

  if (uVar2 == 1) {

    FUN_0040ad10(4);

    puVar3 = (undefined4 *)FUN_0040acf0(4);

    if (puVar3 != (undefined4 *)0x0) {

      if ((*(byte *)(uVar1 + 4) & 1) == 0) {

        *(undefined4 *)(param_1 + 0xc) = *puVar3;

      }

      else {

        *puVar3 = *(undefined4 *)(param_1 + 0xc);

      }

    }

    puVar3 = *(undefined4 **)(param_1 + 4);

    if (puVar3 != (undefined4 *)0x0) {

      while( true ) {

        FUN_0040ad10(4);

        puVar4 = (undefined4 *)FUN_0040acf0(4);

        if (puVar4 != (undefined4 *)0x0) {

          if ((*(byte *)(uVar1 + 4) & 1) == 0) {

            *puVar3 = *puVar4;

          }

          else {

            *puVar4 = *puVar3;

          }

        }

        if (puVar3 == (undefined4 *)0x0) break;

        puVar3 = (undefined4 *)puVar3[1];

        if (puVar3 == (undefined4 *)0x0) {

          return;

        }

      }

    }

  }

  else if (uVar2 == 0) {

    FUN_0049f850();

    FUN_0040ad10(4);

    puVar5 = (uint *)FUN_0040acf0(4);

    uVar2 = param_2;

    if (puVar5 != (uint *)0x0) {

      if ((*(byte *)(uVar1 + 4) & 1) == 0) {

        uVar2 = *puVar5;

      }

      else {

        *puVar5 = param_2;

      }

    }

    if ((~(byte)(*(uint *)(uVar1 + 4) >> 2) & 1) != 0) {

      uVar6 = FUN_0040a8f0();

      if (uVar6 < uVar2) {

        FUN_0040aa50();

        return;

      }

      uVar6 = 0;

      if (uVar2 != 0) {

        do {

          FUN_0040ad10(4);

          puVar5 = (uint *)FUN_0040acf0(4);

          if (puVar5 != (uint *)0x0) {

            if ((*(byte *)(uVar1 + 4) & 1) == 0) {

              param_2 = *puVar5;

            }

            else {

              *puVar5 = param_2;

            }

          }

          if ((*(uint *)(uVar1 + 4) >> 2 & 1) != 0) {

            return;

          }

          FUN_006bbc10(&param_2);

          uVar6 = uVar6 + 1;

        } while (uVar6 < uVar2);

      }

    }

  }

  return;

}





// --- FUN_00685a30 at 0x00685A30 (size: 73) ---


void __fastcall FUN_00685a30(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

  local_4 = *(undefined4 *)(param_1 + 0x68);

  puVar2 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&local_4,local_4,0);

  if ((puVar2 != (undefined4 *)puVar1) || (puVar2 = puVar2 + -1, puVar2 != (undefined4 *)puVar1)) {

    puVar2 = puVar2 + 1;

  }

  FUN_00685c70(*puVar2);

  return;

}





// --- FUN_00685a80 at 0x00685A80 (size: 193) ---


void __thiscall FUN_00685a80(undefined4 *param_1,int param_2)



{

  char *pcVar1;

  undefined4 *puVar2;

  char cVar3;

  

  FUN_00685780(0,param_2);

  cVar3 = '\0';

  FUN_0040ad10(1);

  pcVar1 = (char *)FUN_0040acf0(1);

  if (pcVar1 != (char *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      cVar3 = *pcVar1;

    }

    else {

      *pcVar1 = '\0';

    }

  }

  if ((((*(byte *)(param_2 + 4) & 5) == 0) && (cVar3 != '\0')) && (cVar3 != '\x01')) {

    FUN_0040aa50();

  }

  FUN_0040ad10(4);

  puVar2 = (undefined4 *)FUN_0040acf0(4);

  if (puVar2 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      *param_1 = *puVar2;

    }

    else {

      *puVar2 = *param_1;

    }

  }

  FUN_006858f0(param_2);

  FUN_006855e0(param_2);

  FUN_0049f850();

  return;

}





// --- FUN_00685b50 at 0x00685B50 (size: 143) ---


undefined4 * __thiscall FUN_00685b50(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007fff30;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_00685be0 at 0x00685BE0 (size: 143) ---


undefined4 * __thiscall FUN_00685be0(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007fff2c;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_00685c70 at 0x00685C70 (size: 289) ---


undefined4 __thiscall FUN_00685c70(int param_1,int param_2)



{

  uint *puVar1;

  int iVar2;

  uint *puVar3;

  int *piVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  uint *puVar7;

  

  if (param_2 == *(int *)(param_1 + 0x68)) {

    return 0;

  }

  iVar2 = *(int *)(param_1 + 0x6c);

  puVar3 = (uint *)0x0;

  do {

    if (iVar2 == 0) {

      if (*(void **)(param_1 + 0x60) != (void *)(param_1 + 4)) {

        operator_delete__(*(void **)(param_1 + 0x60));

      }

      *(undefined4 *)(param_1 + 0x60) = 0;

      *(undefined4 *)(param_1 + 100) = 0;

      *(undefined4 *)(param_1 + 0x68) = 0;

      *(undefined4 *)(param_1 + 0x6c) = 0;

      FUN_00693b20(param_2);

      puVar6 = (undefined4 *)PTR_DAT_00818558;

      while (puVar3 != (uint *)0x0) {

        param_2 = *(int *)(param_1 + 0x68);

        puVar7 = (uint *)puVar3[1];

        PTR_DAT_00818558 = (undefined *)puVar6;

        if (param_2 * 2 < *(int *)(param_1 + 0x6c) + 1) {

          puVar5 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,puVar6,&param_2,param_2,0);

          if ((puVar5 != puVar6) || (puVar5 = puVar5 + -1, puVar5 != puVar6)) {

            puVar5 = puVar5 + 1;

          }

          FUN_00685c70(*puVar5);

        }

        puVar1 = (uint *)(*(int *)(param_1 + 0x60) + (*puVar3 % *(uint *)(param_1 + 0x68)) * 4);

        puVar3[1] = *puVar1;

        *puVar1 = (uint)puVar3;

        if (puVar1 < *(uint **)(param_1 + 100)) {

          *(uint **)(param_1 + 100) = puVar1;

        }

        *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

        puVar6 = (undefined4 *)PTR_DAT_00818558;

        puVar3 = puVar7;

      }

      PTR_DAT_00818558 = (undefined *)puVar6;

      return 1;

    }

    piVar4 = *(int **)(param_1 + 100);

    while (piVar4 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        puVar6 = *(undefined4 **)(param_1 + 100);

        puVar7 = (uint *)*puVar6;

        goto LAB_00685cc1;

      }

      piVar4 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar4;

    }

    puVar6 = (undefined4 *)0x0;

    puVar7 = (uint *)0x0;

LAB_00685cc1:

    FUN_00428ba0(param_1,puVar6,puVar7);

    puVar7[1] = (uint)puVar3;

    iVar2 = *(int *)(param_1 + 0x6c);

    puVar3 = puVar7;

  } while( true );

}





// --- FUN_00685da0 at 0x00685DA0 (size: 80) ---


undefined4 __thiscall FUN_00685da0(int param_1,uint *param_2,uint *param_3)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 100) + (*param_2 % *(uint *)(param_1 + 0x6c)) * 4);

  while( true ) {

    if (puVar1 == (uint *)0x0) {

      return 0;

    }

    if (*puVar1 == *param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  *param_3 = puVar1[2];

  FUN_004db900(puVar1 + 3);

  return 1;

}





// --- FUN_00685df0 at 0x00685DF0 (size: 177) ---


void __fastcall FUN_00685df0(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  int *piVar4;

  void *pvVar5;

  

  iVar1 = *(int *)(param_1 + 0x6c);

  do {

    if (iVar1 == 0) {

      return;

    }

    piVar4 = *(int **)(param_1 + 100);

    while (piVar4 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar4 = *(int **)(param_1 + 100);

        pvVar5 = (void *)*piVar4;

        goto LAB_00685e2e;

      }

      piVar4 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar4;

    }

    piVar4 = (int *)0x0;

    pvVar5 = (void *)0x0;

LAB_00685e2e:

    pvVar3 = (void *)*piVar4;

    if (pvVar3 == pvVar5) {

LAB_00685e41:

      *piVar4 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 4);

      } while (pvVar3 != pvVar5);

      if (pvVar2 == (void *)0x0) goto LAB_00685e41;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    if (pvVar5 != (void *)0x0) {

      *(undefined ***)((int)pvVar5 + 0xc) = &PTR_FUN_007a3c34;

      while (pvVar3 = *(void **)((int)pvVar5 + 0x10), pvVar3 != (void *)0x0) {

        iVar1 = *(int *)((int)pvVar3 + 4);

        *(int *)((int)pvVar5 + 0x10) = iVar1;

        if (iVar1 == 0) {

          *(undefined4 *)((int)pvVar5 + 0x14) = 0;

        }

        else {

          *(undefined4 *)(iVar1 + 8) = 0;

        }

        if (pvVar3 != (void *)0x0) {

          operator_delete(pvVar3);

        }

        *(int *)((int)pvVar5 + 0x18) = *(int *)((int)pvVar5 + 0x18) + -1;

      }

      operator_delete(pvVar5);

    }

    iVar1 = *(int *)(param_1 + 0x6c);

  } while( true );

}





// --- FUN_00685eb0 at 0x00685EB0 (size: 120) ---


uint __thiscall FUN_00685eb0(int param_1,uint *param_2)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_00685edb:

      if ((int)(*(uint *)(param_1 + 0x68) * 2) < *(int *)(param_1 + 0x6c) + 1) {

        FUN_00685a30();

      }

      uVar3 = *param_2 % *(uint *)(param_1 + 0x68);

      iVar2 = *(int *)(param_1 + 0x60);

      param_2[1] = *(uint *)(iVar2 + uVar3 * 4);

      *(uint **)(iVar2 + uVar3 * 4) = param_2;

      uVar3 = iVar2 + uVar3 * 4;

      if (uVar3 < *(uint *)(param_1 + 100)) {

        *(uint *)(param_1 + 100) = uVar3;

      }

      iVar2 = *(int *)(param_1 + 0x6c) + 1;

      *(int *)(param_1 + 0x6c) = iVar2;

      return CONCAT31((int3)((uint)iVar2 >> 8),1);

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return (uint)puVar1 & 0xffffff00;

      }

      goto LAB_00685edb;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00685f30 at 0x00685F30 (size: 164) ---


undefined4 __thiscall FUN_00685f30(int param_1,uint param_2)



{

  uint *puVar1;

  undefined4 local_14;

  undefined **local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x110) + (param_2 % *(uint *)(param_1 + 0x118)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_00685f5e:

      FUN_0049f850();

      FUN_006bbc10(&param_2);

      return 1;

    }

    if (*puVar1 == param_2) {

      if (puVar1 != (uint *)0x0) {

        local_14 = 0;

        local_c = 0;

        local_8 = 0;

        local_4 = 0;

        local_10 = &PTR_FUN_007a3c34;

        FUN_00685da0(&param_2,&local_14);

        FUN_004db900(&local_10);

        local_10 = &PTR_FUN_007a3c34;

        FUN_0049f850();

        return 1;

      }

      goto LAB_00685f5e;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00685fe0 at 0x00685FE0 (size: 85) ---


undefined4 __thiscall FUN_00685fe0(int param_1,uint *param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0068600b:

      FUN_00685eb0(param_2);

      FUN_00410820(param_2 + 2,*(undefined4 *)(param_1 + 0x74));

      return 1;

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return 0;

      }

      goto LAB_0068600b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00686040 at 0x00686040 (size: 110) ---


void FUN_00686040(undefined4 param_1,undefined4 *param_2,int param_3)



{

  undefined4 *puVar1;

  

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_3 + 4) & 1) == 0) {

      *param_2 = *puVar1;

    }

    else {

      *puVar1 = *param_2;

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_3 + 4) & 1) != 0) {

      *puVar1 = param_2[2];

      FUN_006858f0(param_3);

      return;

    }

    param_2[2] = *puVar1;

  }

  FUN_006858f0(param_3);

  return;

}





// --- FUN_006860b0 at 0x006860B0 (size: 82) ---


undefined4 * __thiscall FUN_006860b0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007fff34;

  FUN_00685df0();

  param_1[1] = &PTR_FUN_007fff30;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00686110 at 0x00686110 (size: 81) ---


void __fastcall FUN_00686110(int param_1)



{

  int *piVar1;

  int iVar2;

  undefined4 *puVar3;

  

  do {

    piVar1 = *(int **)(param_1 + 0x70);

    if (piVar1 == (int *)0x0) break;

    if ((int *)piVar1[1] == (int *)0x0) {

      iVar2 = *piVar1;

      *(int *)(param_1 + 0x70) = iVar2;

      if (iVar2 != 0) {

        *(undefined4 *)(iVar2 + 4) = 0;

      }

    }

    else {

      *(int *)piVar1[1] = *piVar1;

    }

    if (*piVar1 == 0) {

      puVar3 = *(undefined4 **)(*(int *)(param_1 + 0x74) + 4);

      *(undefined4 **)(param_1 + 0x74) = puVar3;

      if (puVar3 != (undefined4 *)0x0) {

        *puVar3 = 0;

      }

    }

    else {

      *(int *)(*piVar1 + 4) = piVar1[1];

    }

    *piVar1 = 0;

    piVar1[1] = 0;

  } while (piVar1 != (int *)0x0);

  FUN_005c2c80();

  return;

}





// --- FUN_00686170 at 0x00686170 (size: 475) ---


void FUN_00686170(undefined4 param_1,int param_2,uint param_3)



{

  undefined *puVar1;

  int iVar2;

  byte bVar3;

  uint uVar4;

  undefined4 *puVar5;

  uint uVar6;

  undefined4 *puVar7;

  int local_4;

  

  iVar2 = param_3;

  if ((~(byte)(*(uint *)(param_3 + 4) >> 2) & 1) != 0) {

    if ((~*(byte *)(param_3 + 4) & 1) != 0) {

      FUN_00686110();

    }

    local_4 = *(int *)(param_2 + 0x68);

    FUN_00401a80(&param_3,&local_4,iVar2);

    param_3 = *(uint *)(param_2 + 0x6c);

    FUN_00401a80(&param_3,&param_3,iVar2);

    uVar6 = param_3;

    if (((*(uint *)(iVar2 + 4) >> 2 & 1) == 0) &&

       ((local_4 * 2 < (int)param_3 ||

        (((*(uint *)(iVar2 + 4) & 5) == 0 && (uVar4 = FUN_0040a8f0(), uVar4 < uVar6)))))) {

      FUN_0040aa50();

    }

    if (((byte)*(uint *)(iVar2 + 4) & 5) == 1) {

      puVar7 = (undefined4 *)0x0;

      if (*(int *)(param_2 + 0x6c) != 0) {

        if (*(int *)(param_2 + 0x70) == 0) {

          puVar7 = (undefined4 *)0x0;

        }

        else {

          puVar7 = (undefined4 *)(*(int *)(param_2 + 0x70) + -8);

        }

      }

      bVar3 = (byte)(*(uint *)(iVar2 + 4) >> 2);

      while (((~bVar3 & 1) != 0 && (puVar7 != (undefined4 *)0x0))) {

        FUN_0040ad10(4);

        puVar5 = (undefined4 *)FUN_0040acf0(4);

        if (puVar5 != (undefined4 *)0x0) {

          if ((*(byte *)(iVar2 + 4) & 1) == 0) {

            *puVar7 = *puVar5;

          }

          else {

            *puVar5 = *puVar7;

          }

        }

        FUN_00685a80(iVar2);

        if (puVar7[2] == 0) {

          puVar7 = (undefined4 *)0x0;

        }

        else {

          puVar7 = (undefined4 *)(puVar7[2] + -8);

        }

        bVar3 = (byte)(*(uint *)(iVar2 + 4) >> 2);

      }

    }

    puVar1 = PTR_DAT_00818558;

    if ((*(byte *)(iVar2 + 4) & 5) == 0) {

      puVar7 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&local_4,param_3,0);

      if (puVar7 == (undefined4 *)puVar1) {

        puVar7 = puVar7 + -1;

      }

      FUN_004dbc00(*puVar7);

      uVar6 = 0;

      if (param_3 != 0) {

        do {

          puVar7 = (undefined4 *)FUN_005df0f5(0x20);

          if (puVar7 == (undefined4 *)0x0) {

            puVar7 = (undefined4 *)0x0;

          }

          else {

            puVar7[1] = 0;

            puVar7[2] = 0;

            puVar7[3] = 0;

            puVar7[4] = 0;

            puVar7[5] = 0;

            puVar7[6] = 0;

            puVar7[7] = 0;

          }

          FUN_0040ad10(4);

          puVar5 = (undefined4 *)FUN_0040acf0(4);

          if (puVar5 != (undefined4 *)0x0) {

            if ((*(byte *)(iVar2 + 4) & 1) == 0) {

              *puVar7 = *puVar5;

            }

            else {

              *puVar5 = *puVar7;

            }

          }

          FUN_00685a80(iVar2);

          if ((*(uint *)(iVar2 + 4) >> 2 & 1) != 0) {

            return;

          }

          FUN_004dc350(puVar7);

          uVar6 = uVar6 + 1;

        } while (uVar6 < param_3);

      }

    }

  }

  return;

}





// --- FUN_00686350 at 0x00686350 (size: 72) ---


undefined4 __thiscall FUN_00686350(int param_1,uint *param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  while( true ) {

    if (puVar1 == (uint *)0x0) {

      return 0;

    }

    if (*puVar1 == *param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  FUN_004dd970(puVar1 + 4);

  return 1;

}





// --- FUN_006863a0 at 0x006863A0 (size: 202) ---


undefined4 FUN_006863a0(void)



{

  char cVar1;

  undefined4 local_88 [4];

  undefined **local_78;

  undefined1 local_74 [92];

  undefined1 *local_18;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_004dba50(0);

  local_8 = 0;

  local_4 = 0;

  cVar1 = FUN_00686350(&stack0x00000008,&local_78);

  if (cVar1 != '\0') {

    local_88[0] = 0;

    cVar1 = FUN_00685890(&stack0x00000004,local_88);

    if (cVar1 != '\0') {

      FUN_00676850();

      local_78 = &PTR_FUN_007bf7dc;

      if (local_18 != local_74) {

        operator_delete__(local_18);

      }

      return local_88[0];

    }

  }

  FUN_00676850();

  local_78 = &PTR_FUN_007bf7dc;

  if (local_18 != local_74) {

    operator_delete__(local_18);

  }

  return 0;

}





// --- FUN_00686470 at 0x00686470 (size: 192) ---


undefined1 FUN_00686470(int param_1)



{

  char cVar1;

  undefined1 uVar2;

  undefined **local_78;

  undefined1 local_74 [92];

  undefined1 *local_18;

  undefined4 local_8;

  undefined4 local_4;

  

  uVar2 = 1;

  if (param_1 != 1) {

    FUN_004dba50(0);

    local_8 = 0;

    local_4 = 0;

    cVar1 = FUN_00686350(&stack0x00000008,&local_78);

    if (cVar1 != '\0') {

      uVar2 = FUN_00448860(&param_1);

      FUN_00676850();

      local_78 = &PTR_FUN_007bf7dc;

      if (local_18 != local_74) {

        operator_delete__(local_18);

      }

      return uVar2;

    }

    FUN_00676850();

    local_78 = &PTR_FUN_007bf7dc;

    if (local_18 != local_74) {

      operator_delete__(local_18);

    }

    uVar2 = 0;

  }

  return uVar2;

}





// --- FUN_00686530 at 0x00686530 (size: 211) ---


undefined4 FUN_00686530(void)



{

  char cVar1;

  undefined4 uVar2;

  undefined1 local_88 [4];

  int local_84;

  int local_80;

  undefined **local_78;

  undefined1 local_74 [92];

  undefined1 *local_18;

  undefined4 local_8;

  undefined4 local_4;

  

  uVar2 = 0;

  FUN_004dba50(0);

  local_8 = 0;

  local_4 = 0;

  cVar1 = FUN_00686350(&stack0x00000008,&local_78);

  if (cVar1 != '\0') {

    local_84 = 0;

    local_80 = 0;

    cVar1 = FUN_00685890(&stack0x00000004,local_88);

    if (cVar1 != '\0') {

      if ((local_84 != 0) && (local_80 != 0)) {

        uVar2 = 1;

      }

      FUN_00676850();

      local_78 = &PTR_FUN_007bf7dc;

      if (local_18 != local_74) {

        operator_delete__(local_18);

      }

      return uVar2;

    }

  }

  FUN_00676850();

  local_78 = &PTR_FUN_007bf7dc;

  if (local_18 != local_74) {

    operator_delete__(local_18);

  }

  return 0;

}





// --- FUN_00686610 at 0x00686610 (size: 202) ---


undefined4 FUN_00686610(void)



{

  char cVar1;

  undefined1 local_88 [4];

  undefined4 local_84;

  undefined **local_78;

  undefined1 local_74 [92];

  undefined1 *local_18;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_004dba50(0);

  local_8 = 0;

  local_4 = 0;

  cVar1 = FUN_00686350(&stack0x00000008,&local_78);

  if (cVar1 != '\0') {

    local_84 = 0;

    cVar1 = FUN_00685890(&stack0x00000004,local_88);

    if (cVar1 != '\0') {

      FUN_00676850();

      local_78 = &PTR_FUN_007bf7dc;

      if (local_18 != local_74) {

        operator_delete__(local_18);

      }

      return local_84;

    }

  }

  FUN_00676850();

  local_78 = &PTR_FUN_007bf7dc;

  if (local_18 != local_74) {

    operator_delete__(local_18);

  }

  return 0;

}





// --- FUN_006866e0 at 0x006866E0 (size: 245) ---


undefined1 __thiscall

FUN_006866e0(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            )



{

  char cVar1;

  undefined1 uVar2;

  undefined4 local_88;

  undefined4 local_84;

  undefined4 local_80;

  undefined4 local_7c;

  undefined **local_78;

  undefined1 local_74 [92];

  undefined1 *local_18;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_004dba50(0);

  local_8 = 0;

  local_4 = 0;

  cVar1 = FUN_00686350(&param_3,&local_78);

  if (cVar1 != '\0') {

    local_88 = 0;

    local_84 = 0;

    local_80 = 0;

    local_7c = 0;

    cVar1 = FUN_00685890(&param_2,&local_88);

    if (cVar1 != '\0') {

      uVar2 = FUN_00685670(*(undefined4 *)(param_1 + 0xa8),param_4,param_5);

      FUN_00676850();

      local_78 = &PTR_FUN_007bf7dc;

      if (local_18 != local_74) {

        operator_delete__(local_18);

      }

      return uVar2;

    }

  }

  FUN_00676850();

  local_78 = &PTR_FUN_007bf7dc;

  if (local_18 != local_74) {

    operator_delete__(local_18);

  }

  return 0;

}





// --- FUN_00686890 at 0x00686890 (size: 465) ---


void FUN_00686890(undefined4 param_1,int param_2,uint param_3)



{

  undefined *puVar1;

  undefined *puVar2;

  uint uVar3;

  char cVar4;

  undefined *puVar5;

  byte *pbVar6;

  int *piVar7;

  int iVar8;

  uint uVar9;

  int iVar10;

  int *piVar11;

  int iVar12;

  undefined1 local_c [12];

  

  uVar3 = param_3;

  if ((~*(byte *)(param_3 + 4) & 1) != 0) {

    FUN_005c2c80();

  }

  puVar2 = PTR_DAT_00818558;

  puVar1 = PTR_DAT_00818554;

  if (((byte)*(undefined4 *)(uVar3 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x68);

    puVar5 = (undefined *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_3,param_3,0);

    if (puVar5 == puVar2) {

      puVar5 = puVar5 + -4;

    }

    uVar9 = (int)puVar5 - (int)puVar1 >> 2;

  }

  else {

    uVar9 = param_3 & 0xff;

  }

  FUN_0040ad10(1);

  pbVar6 = (byte *)FUN_0040acf0(1);

  if (pbVar6 != (byte *)0x0) {

    if ((*(byte *)(uVar3 + 4) & 1) == 0) {

      uVar9 = (uint)*pbVar6;

    }

    else {

      *pbVar6 = (byte)uVar9;

    }

  }

  if ((*(byte *)(uVar3 + 4) & 5) == 0) {

    if ((uVar9 & 0xff) < DAT_007956cc) {

      FUN_0042ab60(*(undefined4 *)(PTR_DAT_00818554 + (uVar9 & 0xff) * 4));

    }

    else {

      FUN_0040aa50();

    }

  }

  if (((byte)*(undefined4 *)(uVar3 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x6c);

  }

  FUN_00401a80(&param_3,&param_3,uVar3);

  if (((byte)*(undefined4 *)(uVar3 + 4) & 5) == 1) {

    piVar7 = (int *)FUN_0052dcf0(local_c);

    iVar10 = *piVar7;

    piVar11 = (int *)piVar7[1];

    iVar12 = piVar7[2];

LAB_00686994:

    iVar8 = iVar12;

    if (iVar12 != 0) {

      do {

        FUN_00686040(&param_3,iVar8,uVar3);

        iVar8 = *(int *)(iVar8 + 4);

      } while (iVar8 != 0);

      do {

        piVar11 = piVar11 + 1;

        iVar12 = iVar8;

        if (piVar11 == (int *)(*(int *)(iVar10 + 0x60) + *(int *)(iVar10 + 0x68) * 4)) break;

        iVar12 = *piVar11;

      } while (iVar12 == 0);

      goto LAB_00686994;

    }

  }

  if ((*(byte *)(uVar3 + 4) & 5) == 0) {

    uVar9 = FUN_0040a8f0();

    if (uVar9 < param_3) {

LAB_00686a52:

      FUN_0040aa50();

    }

    else {

      uVar9 = 0;

      iVar10 = 0;

      if (param_3 != 0) {

        while( true ) {

          iVar8 = FUN_005df0f5(0x1c);

          iVar12 = 0;

          if (iVar8 != 0) {

            *(undefined4 *)(iVar8 + 4) = 0;

            *(undefined4 *)(iVar8 + 8) = 0;

            *(undefined4 *)(iVar8 + 0x10) = 0;

            *(undefined4 *)(iVar8 + 0x14) = 0;

            *(undefined4 *)(iVar8 + 0x18) = 0;

            *(undefined ***)(iVar8 + 0xc) = &PTR_FUN_007a3c34;

            iVar12 = iVar8;

          }

          FUN_00686040(&param_3,iVar12,uVar3);

          if ((*(uint *)(uVar3 + 4) >> 2 & 1) != 0) break;

          cVar4 = FUN_00599310(iVar12,iVar10);

          if (cVar4 == '\0') goto LAB_00686a52;

          uVar9 = uVar9 + 1;

          iVar10 = iVar12;

          if (param_3 <= uVar9) {

            return;

          }

        }

      }

    }

  }

  return;

}





// --- FUN_00686a70 at 0x00686A70 (size: 241) ---


void __fastcall FUN_00686a70(int param_1)



{

  int *piVar1;

  int iVar2;

  undefined4 *puVar3;

  uint *puVar4;

  uint *puVar5;

  uint *puVar6;

  uint uVar7;

  uint *puVar8;

  

  do {

    puVar8 = (uint *)0x0;

    if (*(int *)(param_1 + 0x6c) == 0) {

      return;

    }

    piVar1 = *(int **)(param_1 + 0x70);

    if (piVar1 != (int *)0x0) {

      if ((int *)piVar1[1] == (int *)0x0) {

        iVar2 = *piVar1;

        *(int *)(param_1 + 0x70) = iVar2;

        if (iVar2 != 0) {

          *(undefined4 *)(iVar2 + 4) = 0;

        }

      }

      else {

        *(int *)piVar1[1] = *piVar1;

      }

      if (*piVar1 == 0) {

        puVar3 = *(undefined4 **)(*(int *)(param_1 + 0x74) + 4);

        *(undefined4 **)(param_1 + 0x74) = puVar3;

        if (puVar3 != (undefined4 *)0x0) {

          *puVar3 = 0;

        }

      }

      else {

        *(int *)(*piVar1 + 4) = piVar1[1];

      }

      *piVar1 = 0;

      piVar1[1] = 0;

      if (piVar1 != (int *)0x0) {

        puVar8 = (uint *)(piVar1 + -2);

      }

    }

    uVar7 = *puVar8 % *(uint *)(param_1 + 0x68);

    puVar6 = *(uint **)(*(int *)(param_1 + 0x60) + uVar7 * 4);

    for (puVar4 = puVar6; puVar4 != (uint *)0x0; puVar4 = (uint *)puVar4[1]) {

      if (*puVar4 == *puVar8) {

        if (puVar4 != (uint *)0x0) {

          if (puVar6 == puVar4) goto LAB_00686b0d;

          do {

            puVar5 = puVar6;

            puVar6 = (uint *)puVar5[1];

          } while (puVar6 != puVar4);

          if (puVar5 == (uint *)0x0) {

LAB_00686b0d:

            *(uint *)(*(int *)(param_1 + 0x60) + uVar7 * 4) = puVar6[1];

          }

          else {

            puVar5[1] = puVar6[1];

          }

          *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

        }

        break;

      }

    }

    FUN_00676850();

    puVar8[4] = (uint)&PTR_FUN_007bf7dc;

    if ((uint *)puVar8[0x1c] != puVar8 + 5) {

      operator_delete__((uint *)puVar8[0x1c]);

    }

    puVar8[0x1c] = 0;

    puVar8[0x1d] = 0;

    puVar8[0x1e] = 0;

    puVar8[0x1f] = 0;

    operator_delete(puVar8);

  } while( true );

}





// --- FUN_00686b70 at 0x00686B70 (size: 257) ---


void __fastcall FUN_00686b70(int param_1)



{

  int iVar1;

  undefined4 *puVar2;

  void *pvVar3;

  void *pvVar4;

  int *piVar5;

  void *pvVar6;

  

  do {

    piVar5 = *(int **)(param_1 + 0x70);

    if (piVar5 == (int *)0x0) break;

    if ((int *)piVar5[1] == (int *)0x0) {

      iVar1 = *piVar5;

      *(int *)(param_1 + 0x70) = iVar1;

      if (iVar1 != 0) {

        *(undefined4 *)(iVar1 + 4) = 0;

      }

    }

    else {

      *(int *)piVar5[1] = *piVar5;

    }

    if (*piVar5 == 0) {

      puVar2 = *(undefined4 **)(*(int *)(param_1 + 0x74) + 4);

      *(undefined4 **)(param_1 + 0x74) = puVar2;

      if (puVar2 != (undefined4 *)0x0) {

        *puVar2 = 0;

      }

    }

    else {

      *(int *)(*piVar5 + 4) = piVar5[1];

    }

    *piVar5 = 0;

    piVar5[1] = 0;

  } while (piVar5 != (int *)0x0);

  iVar1 = *(int *)(param_1 + 0x6c);

  do {

    if (iVar1 == 0) {

      return;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar5 = *(int **)(param_1 + 100);

        pvVar6 = (void *)*piVar5;

        goto LAB_0068681f;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    piVar5 = (int *)0x0;

    pvVar6 = (void *)0x0;

LAB_0068681f:

    pvVar4 = (void *)*piVar5;

    if (pvVar4 == pvVar6) {

LAB_00686832:

      *piVar5 = *(int *)((int)pvVar4 + 4);

    }

    else {

      do {

        pvVar3 = pvVar4;

        pvVar4 = *(void **)((int)pvVar3 + 4);

      } while (pvVar4 != pvVar6);

      if (pvVar3 == (void *)0x0) goto LAB_00686832;

      *(undefined4 *)((int)pvVar3 + 4) = *(undefined4 *)((int)pvVar4 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    if (pvVar6 != (void *)0x0) {

      FUN_00676850();

      *(undefined ***)((int)pvVar6 + 0x10) = &PTR_FUN_007bf7dc;

      if (*(void **)((int)pvVar6 + 0x70) != (void *)((int)pvVar6 + 0x14)) {

        operator_delete__(*(void **)((int)pvVar6 + 0x70));

      }

      *(undefined4 *)((int)pvVar6 + 0x70) = 0;

      *(undefined4 *)((int)pvVar6 + 0x74) = 0;

      *(undefined4 *)((int)pvVar6 + 0x78) = 0;

      *(undefined4 *)((int)pvVar6 + 0x7c) = 0;

      operator_delete(pvVar6);

    }

    iVar1 = *(int *)(param_1 + 0x6c);

  } while( true );

}





// --- FUN_00686bf0 at 0x00686BF0 (size: 87) ---


undefined4 * __fastcall FUN_00686bf0(undefined4 *param_1)



{

  FUN_00415460(DAT_008f8b88);

  *param_1 = &PTR_LAB_007fff38;

  FUN_00685be0(0);

  param_1[0x28] = 0;

  param_1[0x29] = 0;

  param_1[0x2a] = DAT_008f8b88;

  param_1[0x2b] = &PTR_FUN_007fff34;

  FUN_00685b50(0x17);

  return param_1;

}





// --- FUN_00686c60 at 0x00686C60 (size: 130) ---


void __fastcall FUN_00686c60(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007fff38;

  param_1[0x2b] = &PTR_FUN_007fff34;

  FUN_00685df0();

  param_1[0x2c] = &PTR_FUN_007fff30;

  if ((undefined4 *)param_1[0x44] != param_1 + 0x2d) {

    operator_delete__((undefined4 *)param_1[0x44]);

  }

  param_1[0x44] = 0;

  param_1[0x45] = 0;

  param_1[0x46] = 0;

  param_1[0x47] = 0;

  FUN_00686b70();

  param_1[0xc] = &PTR_FUN_007fff2c;

  if ((undefined4 *)param_1[0x24] != param_1 + 0xd) {

    operator_delete__((undefined4 *)param_1[0x24]);

  }

  param_1[0x24] = 0;

  param_1[0x25] = 0;

  param_1[0x26] = 0;

  param_1[0x27] = 0;

  FUN_004154b0();

  return;

}





// --- FUN_00686d00 at 0x00686D00 (size: 30) ---


void * __thiscall FUN_00686d00(void *param_1,byte param_2)



{

  FUN_00686c60();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00686d20 at 0x00686D20 (size: 85) ---


void FUN_00686d20(undefined4 *param_1,int param_2)



{

  int iVar1;

  undefined4 *puVar2;

  

  iVar1 = param_2;

  FUN_0040ad10(4);

  puVar2 = (undefined4 *)FUN_0040acf0(4);

  if (puVar2 != (undefined4 *)0x0) {

    if ((*(byte *)(iVar1 + 4) & 1) != 0) {

      *puVar2 = *param_1;

      FUN_00686170(&param_1,param_1 + 4,iVar1);

      return;

    }

    *param_1 = *puVar2;

  }

  FUN_00686170(&param_1,param_1 + 4,iVar1);

  return;

}





// --- FUN_00686d80 at 0x00686D80 (size: 467) ---


void FUN_00686d80(undefined4 param_1,int param_2,uint param_3)



{

  undefined *puVar1;

  int iVar2;

  uint uVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  byte bVar6;

  uint uVar7;

  int iVar8;

  int local_4;

  

  iVar2 = param_3;

  if ((~(byte)(*(uint *)(param_3 + 4) >> 2) & 1) != 0) {

    if ((~*(byte *)(param_3 + 4) & 1) != 0) {

      FUN_00686110();

    }

    local_4 = *(int *)(param_2 + 0x68);

    FUN_00401a80(&param_3,&local_4,iVar2);

    param_3 = *(uint *)(param_2 + 0x6c);

    FUN_00401a80(&param_3,&param_3,iVar2);

    uVar7 = param_3;

    if (((*(uint *)(iVar2 + 4) >> 2 & 1) == 0) &&

       ((local_4 * 2 < (int)param_3 ||

        (((*(uint *)(iVar2 + 4) & 5) == 0 && (uVar3 = FUN_0040a8f0(), uVar3 < uVar7)))))) {

      FUN_0040aa50();

    }

    if (((byte)*(uint *)(iVar2 + 4) & 5) == 1) {

      iVar8 = 0;

      if (*(int *)(param_2 + 0x6c) != 0) {

        if (*(int *)(param_2 + 0x70) == 0) {

          iVar8 = 0;

        }

        else {

          iVar8 = *(int *)(param_2 + 0x70) + -8;

        }

      }

      bVar6 = (byte)(*(uint *)(iVar2 + 4) >> 2);

      while (((~bVar6 & 1) != 0 && (iVar8 != 0))) {

        FUN_00686d20(iVar8,iVar2);

        if (*(int *)(iVar8 + 8) == 0) {

          iVar8 = 0;

        }

        else {

          iVar8 = *(int *)(iVar8 + 8) + -8;

        }

        bVar6 = (byte)(*(uint *)(iVar2 + 4) >> 2);

      }

    }

    puVar1 = PTR_DAT_00818558;

    if ((*(byte *)(iVar2 + 4) & 5) == 0) {

      puVar4 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&local_4,param_3,0);

      if (puVar4 == (undefined4 *)puVar1) {

        puVar4 = puVar4 + -1;

      }

      FUN_00685c70(*puVar4);

      uVar7 = 0;

      if (param_3 != 0) {

        do {

          puVar4 = (undefined4 *)FUN_005df0f5(0x88);

          if (puVar4 == (undefined4 *)0x0) {

            puVar4 = (undefined4 *)0x0;

          }

          else {

            puVar4[1] = 0;

            puVar4[2] = 0;

            puVar4[3] = 0;

            FUN_004dba50(0);

            puVar4[0x20] = 0;

            puVar4[0x21] = 0;

          }

          FUN_0040ad10(4);

          puVar5 = (undefined4 *)FUN_0040acf0(4);

          if (puVar5 != (undefined4 *)0x0) {

            if ((*(byte *)(iVar2 + 4) & 1) == 0) {

              *puVar4 = *puVar5;

            }

            else {

              *puVar5 = *puVar4;

            }

          }

          FUN_00686170(&param_3,puVar4 + 4,iVar2);

          if ((*(uint *)(iVar2 + 4) >> 2 & 1) != 0) {

            return;

          }

          FUN_00685fe0(puVar4);

          uVar7 = uVar7 + 1;

        } while (uVar7 < param_3);

      }

    }

  }

  return;

}





// --- FUN_00686f60 at 0x00686F60 (size: 125) ---


void __thiscall FUN_00686f60(int param_1,int param_2)



{

  int iVar1;

  undefined4 *puVar2;

  

  iVar1 = param_2;

  FUN_00415590(param_2);

  FUN_00686d80(&param_2,param_1 + 0x30,iVar1);

  FUN_0040ad10(4);

  puVar2 = (undefined4 *)FUN_0040acf0(4);

  if (puVar2 != (undefined4 *)0x0) {

    if ((*(byte *)(iVar1 + 4) & 1) == 0) {

      *(undefined4 *)(param_1 + 0xa8) = *puVar2;

    }

    else {

      *puVar2 = *(undefined4 *)(param_1 + 0xa8);

    }

  }

  if ((~*(byte *)(iVar1 + 4) & 1) != 0) {

    FUN_00685df0();

  }

  FUN_00686890(&param_2,param_1 + 0xb0,iVar1);

  return;

}





// --- FUN_00686fe0 at 0x00686FE0 (size: 13) ---


uint __thiscall FUN_00686fe0(uint *param_1,uint param_2)



{

  return *param_1 % param_2;

}





// --- FUN_00686ff0 at 0x00686FF0 (size: 98) ---


void __fastcall FUN_00686ff0(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = DAT_00800060;

  param_1[2] = DAT_00800064;

  param_1[3] = DAT_00800068;

  param_1[4] = DAT_0080006c;

  param_1[5] = DAT_00800060;

  param_1[6] = DAT_00800064;

  param_1[7] = DAT_00800068;

  param_1[8] = DAT_0080006c;

  param_1[9] = 0xffffffff;

  param_1[10] = 0;

  *(undefined1 *)(param_1 + 0xb) = 0;

  return;

}





// --- FUN_00687060 at 0x00687060 (size: 27) ---


undefined4 __fastcall FUN_00687060(int *param_1)



{

  (**(code **)(*param_1 + 0x24))();

  if ((int *)param_1[0x23] != (int *)0x0) {

    (**(code **)(*(int *)param_1[0x23] + 0x54))();

  }

  return 1;

}





// --- FUN_00687080 at 0x00687080 (size: 120) ---


undefined4 FUN_00687080(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  iVar1 = *(int *)(param_1 + 0x28);

  if (iVar1 == 0x12) {

    local_14 = 2;

  }

  else if (iVar1 == 0x13) {

    local_14 = 1;

  }

  else if (iVar1 == 0x1c) {

    local_14 = 4;

  }

  else {

    local_14 = 3;

  }

  local_10 = *(undefined4 *)(param_1 + 4);

  local_c = *(undefined4 *)(param_1 + 8);

  local_8 = *(undefined4 *)(param_1 + 0xc);

  local_4 = *(undefined4 *)(param_1 + 0x10);

  uVar2 = FUN_0068e0a0(&local_14);

  *(undefined4 *)(param_1 + 0x24) = uVar2;

  return 1;

}





// --- FUN_00687130 at 0x00687130 (size: 101) ---


undefined4 FUN_00687130(int *param_1,char param_2)



{

  int iVar1;

  bool bVar2;

  

  if (param_1 == (int *)0x0) {

    return 0;

  }

  do {

    iVar1 = (**(code **)(*param_1 + 100))(param_1);

    if (-1 < iVar1) {

      return 1;

    }

    if (iVar1 < -0x7ff8ffea) {

      if (iVar1 == -0x7ff8ffeb) {

        return 0;

      }

      if (iVar1 == -0x7ffbfdf9) {

        return 0;

      }

      if (iVar1 == -0x7ffbfdf7) {

        return 0;

      }

      bVar2 = iVar1 == -0x7ff8fff4;

    }

    else {

      bVar2 = iVar1 == -0x7ff8ffe2;

    }

    if (((!bVar2) || (param_2 == '\0')) ||

       (iVar1 = (**(code **)(*param_1 + 0x1c))(param_1), iVar1 < 0)) {

      return 0;

    }

    param_2 = '\0';

  } while( true );

}





// --- FUN_006871a0 at 0x006871A0 (size: 50) ---


void __thiscall FUN_006871a0(int param_1,undefined4 param_2)



{

  if (((*(char *)(param_1 + 0x3f6) == '\0') && (*(char *)(param_1 + 0x1a) != '\0')) &&

     (*(char *)(param_1 + 0x3ed) != '\0')) {

    FUN_00431350(param_2);

  }

  *(undefined1 *)(param_1 + 0x3f6) = 0;

  return;

}





// --- FUN_006871e0 at 0x006871E0 (size: 62) ---


undefined4 FUN_006871e0(undefined1 param_1)



{

  switch(param_1) {

  case 1:

    return 2;

  case 2:

    return 3;

  default:

    return 0;

  case 4:

  case 8:

    return 1;

  case 0x10:

    return 4;

  }

}





// --- FUN_00687250 at 0x00687250 (size: 184) ---


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



undefined4 FUN_00687250(undefined4 param_1,int param_2,float *param_3)



{

  float fVar1;

  

  switch(param_1) {

  case 1:

    if (param_2 != 0x80) {

      *param_3 = 0.0;

      return 2;

    }

    *param_3 = 1.0;

    return 1;

  case 2:

    *param_3 = (float)param_2;

    return 0x80;

  case 3:

    *param_3 = (float)param_2 * _DAT_007edf00;

    return 0x80;

  case 4:

    break;

  default:

    return 0;

  }

  if ((param_2 != -1) && (param_2 != 1)) {

    fVar1 = (float)param_2;

    if (param_2 < 0) {

      fVar1 = fVar1 + _DAT_0079920c;

    }

    *param_3 = fVar1 * _DAT_007e7e90;

    return 0x80;

  }

  *param_3 = -1.0;

  return 0x80;

}





// --- FUN_00687320 at 0x00687320 (size: 131) ---


byte FUN_00687320(int param_1,uint param_2)



{

  if (1 < param_1) {

    if (param_1 < 4) {

      if (0 < (int)param_2) {

        return 1;

      }

      return (-1 < (int)param_2) - 1U & 2;

    }

    if (((param_1 == 4) && (param_2 != 0xffffffff)) && (param_2 != 1)) {

      if (param_2 < 0x1c2) {

        return 3;

      }

      if (param_2 < 0x546) {

        return 4;

      }

      if (param_2 < 0x8ca) {

        return 5;

      }

      return (-(param_2 < 0xc4e) & 3U) + 3;

    }

  }

  return 0;

}





// --- FUN_006873b0 at 0x006873B0 (size: 59) ---


void __fastcall FUN_006873b0(int param_1)



{

  BOOL BVar1;

  tagPOINT local_8;

  

  local_8.x = *(int *)(param_1 + 4);

  local_8.y = *(int *)(param_1 + 8);

  BVar1 = ClientToScreen(*(HWND *)(param_1 + 0x10c),&local_8);

  if (BVar1 != 0) {

    SetCursorPos(local_8.x,local_8.y);

  }

  return;

}





// --- FUN_00687460 at 0x00687460 (size: 43) ---


void __thiscall FUN_00687460(int param_1,undefined4 param_2)



{

  if (*(char *)(param_1 + 0x3f4) != '\0') {

    *(undefined1 *)(param_1 + 0x3f5) = 1;

  }

  FUN_00431440(param_2);

  *(undefined1 *)(param_1 + 0x3f5) = 0;

  return;

}





// --- FUN_00687490 at 0x00687490 (size: 126) ---


void __fastcall FUN_00687490(int *param_1)



{

  undefined4 *puVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  uint local_34;

  

  param_1[2] = 0;

  if ((param_1[1] & 0x80000000U) != 0x80000000) {

    if (*param_1 != 0) {

      local_34 = param_1[1] & 0x7fffffff;

      if (-1 < (int)(local_34 - 1)) {

        iVar3 = (local_34 - 1) * 0x30;

        do {

          puVar1 = (undefined4 *)FUN_00686ff0();

          puVar4 = (undefined4 *)(*param_1 + iVar3);

          iVar3 = iVar3 + -0x30;

          local_34 = local_34 - 1;

          for (iVar2 = 0xc; iVar2 != 0; iVar2 = iVar2 + -1) {

            *puVar4 = *puVar1;

            puVar1 = puVar1 + 1;

            puVar4 = puVar4 + 1;

          }

        } while (local_34 != 0);

      }

    }

    return;

  }

  operator_delete__((void *)*param_1);

  *param_1 = 0;

  param_1[1] = 0;

  return;

}





// --- FUN_00687550 at 0x00687550 (size: 107) ---


void __fastcall FUN_00687550(int param_1)



{

  int *piVar1;

  uint uVar2;

  int iVar3;

  

  uVar2 = 0;

  if (*(int *)(param_1 + 0x118) != 0) {

    iVar3 = 0;

    do {

      piVar1 = *(int **)(*(int *)(param_1 + 0x110) + iVar3);

      if (piVar1 != (int *)0x0) {

        (**(code **)(*piVar1 + 0x1c))(piVar1);

        piVar1 = *(int **)(iVar3 + *(int *)(param_1 + 0x110));

        (**(code **)(*piVar1 + 0x28))(piVar1,0x14,0,&stack0xfffffff8,0);

      }

      *(undefined1 *)(iVar3 + 0x2c + *(int *)(param_1 + 0x110)) = 1;

      uVar2 = uVar2 + 1;

      iVar3 = iVar3 + 0x30;

    } while (uVar2 < *(uint *)(param_1 + 0x118));

  }

  return;

}





// --- FUN_006875c0 at 0x006875C0 (size: 67) ---


void __fastcall FUN_006875c0(int param_1)



{

  int *piVar1;

  uint uVar2;

  int iVar3;

  

  uVar2 = 0;

  if (*(int *)(param_1 + 0x118) != 0) {

    iVar3 = 0;

    do {

      piVar1 = *(int **)(iVar3 + *(int *)(param_1 + 0x110));

      if (piVar1 != (int *)0x0) {

        (**(code **)(*piVar1 + 0x20))(piVar1);

        *(undefined1 *)(iVar3 + 0x2c + *(int *)(param_1 + 0x110)) = 0;

      }

      uVar2 = uVar2 + 1;

      iVar3 = iVar3 + 0x30;

    } while (uVar2 < *(uint *)(param_1 + 0x118));

  }

  return;

}





// --- FUN_00687610 at 0x00687610 (size: 73) ---


void __fastcall FUN_00687610(int param_1)



{

  int *piVar1;

  uint uVar2;

  int iVar3;

  

  FUN_006875c0();

  uVar2 = 0;

  if (*(int *)(param_1 + 0x118) != 0) {

    iVar3 = 0;

    do {

      piVar1 = *(int **)(iVar3 + *(int *)(param_1 + 0x110));

      if (piVar1 != (int *)0x0) {

        (**(code **)(*piVar1 + 8))(piVar1);

      }

      uVar2 = uVar2 + 1;

      iVar3 = iVar3 + 0x30;

    } while (uVar2 < *(uint *)(param_1 + 0x118));

  }

  *(undefined4 *)(param_1 + 0x118) = 0;

  return;

}





// --- FUN_00687660 at 0x00687660 (size: 97) ---


bool __thiscall FUN_00687660(int param_1,undefined2 param_2)



{

  uint uVar1;

  undefined4 local_4;

  

  local_4 = CONCAT22(param_2,(ushort)*(byte *)(*(int *)(param_1 + 0x11c) * 0x30 + 0x24 +

                                              *(int *)(param_1 + 0x110)));

  uVar1 = FUN_0068e7a0(local_4);

  if (uVar1 != 0) {

    return (*(uint *)(param_1 + 0x358) & uVar1) != 0;

  }

  return false;

}





// --- FUN_00687720 at 0x00687720 (size: 64) ---


undefined4 * __thiscall FUN_00687720(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_00800070;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00687760 at 0x00687760 (size: 64) ---


undefined4 * __thiscall FUN_00687760(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_00800074;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_006877a0 at 0x006877A0 (size: 64) ---


undefined4 * __thiscall FUN_006877a0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_00800078;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_006877e0 at 0x006877E0 (size: 192) ---


undefined4 __thiscall FUN_006877e0(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  

  if (param_2 < (uint)param_1[2]) {

    return 0;

  }

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    if (param_2 == 0) {

      FUN_00687490();

      return 1;

    }

    iVar1 = thunk_FUN_005df0f5(param_2 * 0x30);

    if (iVar1 == 0) {

      return 0;

    }

    FUN_00401000(iVar1,0x30,param_2,FUN_00686ff0);

    if (*param_1 != 0) {

      iVar4 = param_1[2];

      if (-1 < iVar4 + -1) {

        iVar2 = (iVar4 + -1) * 0x30;

        do {

          puVar5 = (undefined4 *)(*param_1 + iVar2);

          puVar6 = (undefined4 *)(iVar2 + iVar1);

          iVar2 = iVar2 + -0x30;

          iVar4 = iVar4 + -1;

          for (iVar3 = 0xc; iVar3 != 0; iVar3 = iVar3 + -1) {

            *puVar6 = *puVar5;

            puVar5 = puVar5 + 1;

            puVar6 = puVar6 + 1;

          }

        } while (iVar4 != 0);

      }

      if ((param_1[1] & 0x80000000U) == 0x80000000) {

        operator_delete__((void *)*param_1);

      }

    }

    *param_1 = iVar1;

    param_1[1] = param_2 | 0x80000000;

  }

  return 1;

}





// --- FUN_006878a0 at 0x006878A0 (size: 95) ---


void __fastcall FUN_006878a0(int *param_1)



{

  uint uVar1;

  undefined4 *puVar2;

  int iVar3;

  

  param_1[2] = 0;

  if ((param_1[1] & 0x80000000U) == 0x80000000) {

    operator_delete__((void *)*param_1);

    *param_1 = 0;

    param_1[1] = 0;

    return;

  }

  if (*param_1 != 0) {

    uVar1 = param_1[1] & 0x7fffffff;

    if (-1 < (int)(uVar1 - 1)) {

      iVar3 = (uVar1 - 1) * 0x10;

      do {

        puVar2 = (undefined4 *)(*param_1 + iVar3);

        iVar3 = iVar3 + -0x10;

        uVar1 = uVar1 - 1;

        *puVar2 = 0xffffffff;

        puVar2[1] = 0;

        puVar2[2] = 0;

        puVar2[3] = 0;

      } while (uVar1 != 0);

    }

  }

  return;

}





// --- FUN_00687970 at 0x00687970 (size: 215) ---


undefined4 __thiscall FUN_00687970(int *param_1,uint param_2)



{

  int iVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  int iVar4;

  

  if (param_2 < (uint)param_1[2]) {

    return 0;

  }

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    if (param_2 == 0) {

      FUN_006878a0();

      return 1;

    }

    iVar1 = thunk_FUN_005df0f5(param_2 << 4);

    if (iVar1 == 0) {

      return 0;

    }

    FUN_00401000(iVar1,0x10,param_2,&LAB_00487460);

    if (*param_1 != 0) {

      iVar4 = param_1[2];

      if (-1 < iVar4 + -1) {

        puVar3 = (undefined4 *)((iVar4 + -1) * 0x10 + 8 + iVar1);

        do {

          puVar2 = (undefined4 *)((int)puVar3 + *param_1 + (-8 - iVar1));

          puVar3[-2] = *puVar2;

          puVar3[-1] = puVar2[1];

          *puVar3 = puVar2[2];

          puVar3[1] = puVar2[3];

          puVar3 = puVar3 + -4;

          iVar4 = iVar4 + -1;

        } while (iVar4 != 0);

      }

      if ((param_1[1] & 0x80000000U) == 0x80000000) {

        operator_delete__((void *)*param_1);

      }

    }

    *param_1 = iVar1;

    param_1[1] = param_2 | 0x80000000;

  }

  return 1;

}





// --- FUN_00687a50 at 0x00687A50 (size: 130) ---


void __thiscall FUN_00687a50(int param_1,int *param_2,uint *param_3)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  int *piVar4;

  uint *puVar5;

  

  uVar1 = *param_3;

  uVar3 = uVar1 % *(uint *)(param_1 + 0x68);

  iVar2 = *(int *)(param_1 + 0x60);

  piVar4 = (int *)(iVar2 + uVar3 * 4);

  for (puVar5 = *(uint **)(iVar2 + uVar3 * 4); (puVar5 != (uint *)0x0 && (*puVar5 != uVar1));

      puVar5 = (uint *)puVar5[1]) {

  }

  if (puVar5 != (uint *)0x0) {

    while (puVar5 != param_3) {

      if (*puVar5 != uVar1) {

        *param_2 = param_1;

        param_2[1] = 0;

        param_2[2] = 0;

        return;

      }

      puVar5 = (uint *)puVar5[1];

      if (puVar5 == (uint *)0x0) {

        do {

          piVar4 = piVar4 + 1;

          if (piVar4 == (int *)(iVar2 + *(uint *)(param_1 + 0x68) * 4)) goto LAB_00687aaa;

        } while (*piVar4 == 0);

        puVar5 = (uint *)*piVar4;

        if (puVar5 == (uint *)0x0) break;

      }

    }

  }

LAB_00687aaa:

  param_2[2] = (int)puVar5;

  *param_2 = param_1;

  param_2[1] = (int)piVar4;

  return;

}





// --- FUN_00687d60 at 0x00687D60 (size: 84) ---


undefined4 __thiscall FUN_00687d60(int *param_1,undefined4 *param_2)



{

  undefined4 uVar1;

  int iVar2;

  undefined4 *puVar3;

  

  if ((param_1[1] & 0x7fffffffU) <= (uint)param_1[2]) {

    uVar1 = FUN_00453850((param_1[1] & 0x7fffffffU) + 1);

    uVar1 = FUN_006877e0(uVar1);

    if ((char)uVar1 == '\0') {

      return uVar1;

    }

  }

  puVar3 = (undefined4 *)(param_1[2] * 0x30 + *param_1);

  for (iVar2 = 0xc; iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar3 = *param_2;

    param_2 = param_2 + 1;

    puVar3 = puVar3 + 1;

  }

  iVar2 = param_1[2];

  param_1[2] = iVar2 + 1;

  return CONCAT31((int3)((uint)(iVar2 + 1) >> 8),1);

}





// --- FUN_00687dc0 at 0x00687DC0 (size: 115) ---


undefined1 __thiscall FUN_00687dc0(int *param_1,uint param_2,char param_3)



{

  char cVar1;

  uint uVar2;

  undefined4 *puVar3;

  int iVar4;

  

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    uVar2 = param_2;

    if (param_3 == '\0') {

      uVar2 = FUN_00453850(param_2);

    }

    cVar1 = FUN_00687970(uVar2);

    if (cVar1 == '\0') {

      return 0;

    }

  }

  else if (param_2 < (uint)param_1[2]) {

    iVar4 = param_2 << 4;

    uVar2 = param_2;

    do {

      puVar3 = (undefined4 *)(*param_1 + iVar4);

      *puVar3 = 0xffffffff;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0;

      uVar2 = uVar2 + 1;

      iVar4 = iVar4 + 0x10;

    } while (uVar2 < (uint)param_1[2]);

  }

  param_1[2] = param_2;

  return 1;

}





// --- FUN_00687e40 at 0x00687E40 (size: 133) ---


void __thiscall FUN_00687e40(int param_1,uint param_2,int param_3)



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  uint uVar4;

  int iVar5;

  uint uVar6;

  

  while (param_2 != 0) {

    uVar6 = param_2 - 1 >> 1;

    iVar1 = *(int *)(param_1 + 0x70);

    uVar2 = *(uint *)(*(int *)(iVar1 + uVar6 * 4) + 8);

    uVar3 = *(uint *)(param_3 + 8);

    if (uVar3 == uVar2) break;

    uVar4 = uVar3 - uVar2;

    iVar5 = 1;

    if (uVar3 < uVar2) {

      uVar4 = uVar2 - uVar3;

      iVar5 = -1;

    }

    if (0x7fffffff < uVar4) {

      iVar5 = -iVar5;

    }

    if (-1 < iVar5) break;

    *(undefined4 *)(iVar1 + param_2 * 4) = *(undefined4 *)(iVar1 + uVar6 * 4);

    *(uint *)(*(int *)(*(int *)(param_1 + 0x70) + param_2 * 4) + 0x14) = param_2;

    param_2 = uVar6;

  }

  *(int *)(*(int *)(param_1 + 0x70) + param_2 * 4) = param_3;

  *(uint *)(param_3 + 0x14) = param_2;

  return;

}





// --- FUN_00687ed0 at 0x00687ED0 (size: 302) ---


void __thiscall FUN_00687ed0(int param_1,uint param_2,int param_3)



{

  uint uVar1;

  uint uVar2;

  int iVar3;

  uint uVar4;

  int iVar5;

  int iVar6;

  uint uVar7;

  uint uVar8;

  

  do {

    while( true ) {

      uVar1 = param_2 * 2 + 2;

      uVar2 = param_2 * 2 + 1;

      if (*(uint *)(param_1 + 0x6c) <= uVar1) break;

      iVar3 = *(int *)(param_1 + 0x70);

      iVar5 = *(int *)(iVar3 + uVar1 * 4);

      uVar4 = *(uint *)(*(int *)(iVar3 + uVar2 * 4) + 8);

      uVar8 = *(uint *)(iVar5 + 8);

      if (uVar8 == uVar4) break;

      uVar7 = uVar8 - uVar4;

      iVar6 = 1;

      if (uVar8 < uVar4) {

        uVar7 = uVar4 - uVar8;

        iVar6 = -1;

      }

      if (0x7fffffff < uVar7) {

        iVar6 = -iVar6;

      }

      if (-1 < iVar6) break;

      uVar2 = *(uint *)(param_3 + 8);

      uVar4 = *(uint *)(iVar5 + 8);

      if (uVar4 == uVar2) goto LAB_00687fe7;

      uVar8 = uVar4 - uVar2;

      iVar6 = 1;

      if (uVar4 < uVar2) {

        uVar8 = uVar2 - uVar4;

        iVar6 = -1;

      }

      if (0x7fffffff < uVar8) {

        iVar6 = -iVar6;

      }

      if (-1 < iVar6) goto LAB_00687fe7;

      *(int *)(iVar3 + param_2 * 4) = iVar5;

      *(uint *)(*(int *)(*(int *)(param_1 + 0x70) + param_2 * 4) + 0x14) = param_2;

      param_2 = uVar1;

    }

    if (*(uint *)(param_1 + 0x6c) <= uVar2) {

LAB_00687fe7:

      *(int *)(*(int *)(param_1 + 0x70) + param_2 * 4) = param_3;

      *(uint *)(param_3 + 0x14) = param_2;

      return;

    }

    uVar1 = *(uint *)(param_3 + 8);

    iVar3 = *(int *)(*(int *)(param_1 + 0x70) + uVar2 * 4);

    uVar4 = *(uint *)(iVar3 + 8);

    if (uVar4 == uVar1) goto LAB_00687fe7;

    uVar8 = uVar4 - uVar1;

    iVar5 = 1;

    if (uVar4 < uVar1) {

      uVar8 = uVar1 - uVar4;

      iVar5 = -1;

    }

    if (0x7fffffff < uVar8) {

      iVar5 = -iVar5;

    }

    if (-1 < iVar5) goto LAB_00687fe7;

    *(int *)(*(int *)(param_1 + 0x70) + param_2 * 4) = iVar3;

    *(uint *)(*(int *)(*(int *)(param_1 + 0x70) + param_2 * 4) + 0x14) = param_2;

    param_2 = uVar2;

  } while( true );

}





// --- FUN_00688000 at 0x00688000 (size: 99) ---


void __thiscall FUN_00688000(int param_1,int param_2,int param_3)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

  if (param_2 != 0) {

    uVar1 = *(uint *)(param_3 + 8);

    uVar2 = *(uint *)(*(int *)(*(int *)(param_1 + 0x70) + (param_2 - 1U >> 1) * 4) + 8);

    if (uVar1 != uVar2) {

      uVar3 = uVar1 - uVar2;

      iVar4 = 1;

      if (uVar1 < uVar2) {

        uVar3 = uVar2 - uVar1;

        iVar4 = -1;

      }

      if (0x7fffffff < uVar3) {

        iVar4 = -iVar4;

      }

      if (iVar4 < 0) {

        FUN_00687e40(param_2,param_3);

        return;

      }

    }

  }

  FUN_00687ed0(param_2,param_3);

  return;

}





// --- FUN_00688070 at 0x00688070 (size: 134) ---


void FUN_00688070(byte param_1,undefined4 *param_2,undefined4 *param_3,undefined4 param_4)



{

  undefined4 local_30;

  undefined4 local_2c;

  undefined4 local_28;

  undefined4 local_24;

  undefined4 local_20;

  undefined4 local_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  uint local_8;

  undefined1 local_4;

  

  FUN_00686ff0();

  local_2c = *param_2;

  local_30 = param_4;

  local_28 = param_2[1];

  local_24 = param_2[2];

  local_20 = param_2[3];

  local_1c = *param_3;

  local_18 = param_3[1];

  local_14 = param_3[2];

  local_10 = param_3[3];

  local_8 = (uint)param_1;

  local_4 = 1;

  FUN_00687080(&local_30);

  FUN_00687d60(&local_30);

  return;

}





// --- FUN_00688100 at 0x00688100 (size: 75) ---


undefined4 __thiscall FUN_00688100(int param_1,uint *param_2,uint *param_3)



{

  uint *puVar1;

  int iVar2;

  uint *puVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 100) + (*param_2 % *(uint *)(param_1 + 0x6c)) * 4);

  while( true ) {

    if (puVar1 == (uint *)0x0) {

      return 0;

    }

    if (*puVar1 == *param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  puVar3 = puVar1 + 2;

  for (iVar2 = 6; iVar2 != 0; iVar2 = iVar2 + -1) {

    *param_3 = *puVar3;

    puVar3 = puVar3 + 1;

    param_3 = param_3 + 1;

  }

  return CONCAT31((int3)((uint)puVar1 >> 8),1);

}





// --- FUN_00688150 at 0x00688150 (size: 77) ---


undefined4 * __thiscall FUN_00688150(undefined4 *param_1,undefined4 *param_2)



{

  int iVar1;

  

  *param_1 = &PTR_FUN_0079931c;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  if (param_1 != param_2) {

    FUN_00431730();

    for (iVar1 = param_2[1]; (iVar1 != 0 && (FUN_00431250(iVar1), iVar1 != 0));

        iVar1 = *(int *)(iVar1 + 0xc)) {

    }

  }

  return param_1;

}





// --- FUN_006881a0 at 0x006881A0 (size: 72) ---


undefined4 __thiscall FUN_006881a0(int param_1,uint param_2,uint *param_3)



{

  uint *puVar1;

  uint uVar2;

  uint uVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (param_2 % *(uint *)(param_1 + 0x68)) * 4);

  while( true ) {

    if (puVar1 == (uint *)0x0) {

      return 0;

    }

    if (*puVar1 == param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  uVar2 = puVar1[2];

  uVar3 = puVar1[4];

  param_3[1] = puVar1[3];

  param_3[2] = uVar3;

  *param_3 = uVar2;

  return CONCAT31((int3)(uVar3 >> 8),1);

}





// --- FUN_006881f0 at 0x006881F0 (size: 73) ---


void __fastcall FUN_006881f0(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

  local_4 = *(undefined4 *)(param_1 + 0x68);

  puVar2 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&local_4,local_4,0);

  if ((puVar2 != (undefined4 *)puVar1) || (puVar2 = puVar2 + -1, puVar2 != (undefined4 *)puVar1)) {

    puVar2 = puVar2 + 1;

  }

  FUN_00688690(*puVar2);

  return;

}





// --- FUN_00688240 at 0x00688240 (size: 500) ---


int __thiscall FUN_00688240(int param_1,undefined4 param_2,int ***param_3)



{

  int *piVar1;

  int iVar2;

  uint uVar3;

  int *piVar4;

  int *unaff_EDI;

  int ***pppiVar5;

  bool bVar6;

  int *piStack_6c;

  uint **ppuStack_68;

  uint **ppuStack_64;

  int ***pppiStack_60;

  int *piStack_5c;

  int *piStack_58;

  undefined4 uStack_54;

  int *piStack_50;

  uint **ppuStack_4c;

  int **ppiStack_48;

  undefined4 uStack_44;

  int *local_30;

  undefined4 uStack_2c;

  undefined4 uStack_14;

  undefined4 uStack_10;

  

  uVar3 = 0;

  if (*(int *)(param_1 + 0x118) != 0) {

    piVar1 = (int *)(*(int *)(param_1 + 0x110) + 4);

    do {

      iVar2 = 4;

      bVar6 = true;

      piVar4 = piVar1;

      pppiVar5 = param_3;

      do {

        if (iVar2 == 0) break;

        iVar2 = iVar2 + -1;

        bVar6 = (int **)*piVar4 == *pppiVar5;

        piVar4 = piVar4 + 1;

        pppiVar5 = pppiVar5 + 1;

      } while (bVar6);

      if (bVar6) goto LAB_00688428;

      uVar3 = uVar3 + 1;

      piVar1 = piVar1 + 0xc;

    } while (uVar3 < *(uint *)(param_1 + 0x118));

  }

  piStack_50 = *(int **)(param_1 + 0x108);

  uStack_44 = 0;

  ppiStack_48 = &local_30;

  ppuStack_4c = (uint **)param_3;

  local_30 = (int *)0x0;

  uStack_54 = 0x6882a0;

  iVar2 = (**(code **)(*piStack_50 + 0xc))();

  if (-1 < iVar2) {

    piStack_58 = *(int **)(param_1 + 0x10c);

    uStack_54 = 0x16;

    pppiStack_60 = (int ***)0x6882bb;

    piStack_5c = unaff_EDI;

    iVar2 = (**(code **)(*unaff_EDI + 0x34))();

    if (iVar2 < 0) goto LAB_006883a0;

    pppiStack_60 = &ppiStack_48;

    ppuStack_64 = (uint **)0x1;

    ppiStack_48 = (int **)0x14;

    uStack_44 = 0x10;

    ppuStack_68 = ppuStack_4c;

    piStack_6c = (int *)0x6882f7;

    iVar2 = (*(code *)(*ppuStack_4c)[6])();

    if (iVar2 < 0) {

      piStack_6c = piStack_58;

      (**(code **)(*piStack_58 + 8))();

      return iVar2;

    }

    piStack_6c = (int *)&stack0xffffffc0;

    local_30 = (int *)0xfffffff0;

    uStack_2c = 0x10;

    (**(code **)(*piStack_58 + 0x18))(piStack_58);

    piVar1 = local_30;

    if (((uint)local_30 & 0xff) == 0x12) {

      piStack_50 = (int *)0x1;

      iVar2 = (**(code **)((int)*ppuStack_64 + 0x18))(ppuStack_64,2,&pppiStack_60);

      if (iVar2 < 0) {

LAB_006883a0:

        ppuStack_64 = (uint **)0x6883a6;

        pppiStack_60 = (int ***)ppuStack_4c;

        (*(code *)(*ppuStack_4c)[2])();

        return iVar2;

      }

      pppiStack_60 = (int ***)&DAT_00807acc;

      ppuStack_64 = ppuStack_4c;

      ppuStack_68 = (uint **)0x6883ff;

      iVar2 = (*(code *)(*ppuStack_4c)[0xb])();

      if (iVar2 < 0) goto LAB_006883a0;

      *(undefined4 *)(param_1 + 0x120) = *(undefined4 *)(param_1 + 0x118);

    }

    else if (((uint)local_30 & 0xff) == 0x13) {

      iVar2 = (**(code **)((int)*ppuStack_64 + 0x2c))(ppuStack_64,&DAT_00807ae4);

      if (iVar2 < 0) goto LAB_006883a0;

      *(undefined4 *)(param_1 + 0x11c) = *(undefined4 *)(param_1 + 0x118);

    }

    else {

      piStack_50 = (int *)0x0;

      (**(code **)((int)*ppuStack_64 + 0x18))(ppuStack_64,2,&pppiStack_60);

      piStack_5c = (int *)0x5dc;

      iVar2 = (**(code **)(iRam00000004 + 0x18))(4,5,&piStack_6c);

      if (iVar2 < 0) goto LAB_006883a0;

      pppiStack_60 = (int ***)&DAT_00807afc;

      ppuStack_64 = ppuStack_4c;

      ppuStack_68 = (uint **)0x688396;

      iVar2 = (*(code *)(*ppuStack_4c)[0xb])();

      if (iVar2 < 0) goto LAB_006883a0;

    }

    pppiStack_60 = (int ***)ppuStack_4c;

    ppuStack_64 = (uint **)uStack_10;

    ppuStack_68 = (uint **)uStack_14;

    piStack_6c = piVar1;

    FUN_00688070();

LAB_00688428:

    iVar2 = 0;

  }

  return iVar2;

}





// --- FUN_00688470 at 0x00688470 (size: 110) ---


undefined4 __thiscall FUN_00688470(int param_1,undefined4 param_2,int param_3,undefined4 *param_4)



{

  undefined4 *puVar1;

  char cVar2;

  

  puVar1 = param_4;

  cVar2 = FUN_00688100(&param_2,param_4);

  if (cVar2 != '\0') {

    return 1;

  }

  puVar1[1] = param_3;

  puVar1[2] = *(undefined4 *)(param_1 + 0x358);

  if (param_3 == 4) {

    *puVar1 = 0xffffffff;

    puVar1[3] = 0x80;

    return 0;

  }

  puVar1[3] = (-(uint)(param_3 != 1) & 0x7e) + 2;

  *puVar1 = 0;

  return 0;

}





// --- FUN_006884e0 at 0x006884E0 (size: 143) ---


undefined4 * __thiscall FUN_006884e0(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_00800070;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_00688570 at 0x00688570 (size: 143) ---


undefined4 * __thiscall FUN_00688570(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_00800074;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_00688600 at 0x00688600 (size: 143) ---


undefined4 * __thiscall FUN_00688600(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_00800078;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_00688690 at 0x00688690 (size: 310) ---


undefined4 __thiscall FUN_00688690(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  uint *puVar3;

  undefined4 *puVar4;

  int *piVar5;

  uint *puVar6;

  uint *puVar7;

  undefined4 *puVar8;

  uint *puVar9;

  uint uVar10;

  uint *puVar11;

  

  iVar2 = param_2;

  if (param_2 == *(int *)(param_1 + 0x68)) {

    return 0;

  }

  iVar1 = *(int *)(param_1 + 0x6c);

  puVar3 = (uint *)0x0;

  do {

    if (iVar1 == 0) {

      if (*(void **)(param_1 + 0x60) != (void *)(param_1 + 4)) {

        operator_delete__(*(void **)(param_1 + 0x60));

      }

      *(undefined4 *)(param_1 + 0x60) = 0;

      *(undefined4 *)(param_1 + 100) = 0;

      *(undefined4 *)(param_1 + 0x68) = 0;

      *(undefined4 *)(param_1 + 0x6c) = 0;

      FUN_00693b20(iVar2);

      puVar4 = (undefined4 *)PTR_DAT_00818558;

      while (puVar3 != (uint *)0x0) {

        param_2 = *(int *)(param_1 + 0x68);

        puVar11 = (uint *)puVar3[1];

        PTR_DAT_00818558 = (undefined *)puVar4;

        if (param_2 * 2 < *(int *)(param_1 + 0x6c) + 1) {

          puVar8 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,puVar4,&param_2,param_2,0);

          if ((puVar8 != puVar4) || (puVar8 = puVar8 + -1, puVar8 != puVar4)) {

            puVar8 = puVar8 + 1;

          }

          FUN_00688690(*puVar8);

        }

        uVar10 = *puVar3 % *(uint *)(param_1 + 0x68);

        iVar2 = *(int *)(param_1 + 0x60);

        puVar3[1] = *(uint *)(iVar2 + uVar10 * 4);

        *(uint **)(iVar2 + uVar10 * 4) = puVar3;

        uVar10 = iVar2 + uVar10 * 4;

        if (uVar10 < *(uint *)(param_1 + 100)) {

          *(uint *)(param_1 + 100) = uVar10;

        }

        *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

        puVar4 = (undefined4 *)PTR_DAT_00818558;

        puVar3 = puVar11;

      }

      PTR_DAT_00818558 = (undefined *)puVar4;

      return 1;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        puVar11 = *(uint **)(param_1 + 100);

        puVar9 = (uint *)*puVar11;

        goto LAB_006886df;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    puVar11 = (uint *)0x0;

    puVar9 = (uint *)0x0;

LAB_006886df:

    puVar7 = (uint *)*puVar11;

    if (puVar7 == puVar9) {

LAB_006886f2:

      *puVar11 = puVar7[1];

    }

    else {

      do {

        puVar6 = puVar7;

        puVar7 = (uint *)puVar6[1];

      } while (puVar7 != puVar9);

      if (puVar6 == (uint *)0x0) goto LAB_006886f2;

      puVar6[1] = puVar7[1];

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    puVar9[1] = (uint)puVar3;

    iVar1 = *(int *)(param_1 + 0x6c);

    puVar3 = puVar9;

  } while( true );

}





// --- FUN_006887d0 at 0x006887D0 (size: 63) ---


uint __thiscall FUN_006887d0(int param_1,uint param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x128) + (param_2 % *(uint *)(param_1 + 0x130)) * 4);

  while( true ) {

    if (puVar1 == (uint *)0x0) {

      return 0;

    }

    if (*puVar1 == param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  return puVar1[4];

}





// --- FUN_00688810 at 0x00688810 (size: 121) ---


bool __fastcall FUN_00688810(int param_1)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x108) == 0) {

    return false;

  }

  FUN_00688240(0x13,&DAT_007fe800,&DAT_007fe800);

  FUN_00688240(0x12,&DAT_007fe810,&DAT_007fe810);

  *(undefined4 *)(param_1 + 0x124) = *(undefined4 *)(param_1 + 0x118);

  FUN_00688070(0x1c,&DAT_007fffe8,&DAT_007fffe8,0);

  iVar1 = (**(code **)(**(int **)(param_1 + 0x108) + 0x10))

                    (*(int **)(param_1 + 0x108),0,&LAB_00688440,param_1,0);

  return -1 < iVar1;

}





// --- FUN_00688890 at 0x00688890 (size: 840) ---


undefined4 * __thiscall

FUN_00688890(int param_1,undefined4 *param_2,uint param_3,undefined4 param_4)



{

  int *piVar1;

  uint uVar2;

  undefined *puVar3;

  int iVar4;

  char cVar5;

  int iVar6;

  LONG LVar7;

  uint *puVar8;

  uint uVar9;

  undefined4 *puVar10;

  char *pcVar11;

  undefined *puVar12;

  uint local_304;

  int local_300;

  int local_2fc [73];

  undefined1 local_1d8 [144];

  undefined4 local_148 [8];

  char acStack_128 [292];

  

  puVar3 = PTR_DAT_00818344;

  local_304 = param_3 >> 0x10;

  uVar2 = *(uint *)(param_1 + 0x118);

  uVar9 = 0;

  if (uVar2 != 0) {

    puVar8 = (uint *)(*(int *)(param_1 + 0x110) + 0x24);

    do {

      if (*puVar8 == (param_3 & 0xff)) break;

      uVar9 = uVar9 + 1;

      puVar8 = puVar8 + 0xc;

    } while (uVar9 < uVar2);

  }

  if (uVar2 <= uVar9) {

    FUN_00401340(&DAT_007938af);

    return param_2;

  }

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  FUN_0068bcb0(local_2fc);

  iVar4 = local_2fc[0];

  iVar6 = *(int *)(local_2fc[0] + -8);

  if (iVar6 == -1) {

    iVar6 = FUN_004016b0(local_2fc[0]);

    *(int *)(iVar4 + -8) = iVar6;

  }

  FUN_0042dc80();

  FUN_0042c9c0(iVar6,param_4);

  cVar5 = FUN_0042ce00(1);

  if (cVar5 == '\0') {

    piVar1 = (int *)(uVar9 * 0x30 + *(int *)(param_1 + 0x110));

    if (*piVar1 == 0) {

      if (((param_3 & 0xff) !=

           *(uint *)(*(int *)(param_1 + 0x124) * 0x30 + 0x24 + *(int *)(param_1 + 0x110))) ||

         ((param_3 & 0xffff0000) != 0x10000)) goto LAB_00688a4e;

      pcVar11 = "Mouse-Look";

    }

    else {

      puVar10 = local_148;

      for (iVar6 = 0x4f; iVar6 != 0; iVar6 = iVar6 + -1) {

        *puVar10 = 0;

        puVar10 = puVar10 + 1;

      }

      local_148[0] = 0x13c;

      piVar1 = (int *)*piVar1;

      iVar6 = (**(code **)(*piVar1 + 0x38))(piVar1,local_148,local_304,1);

      if (iVar6 < 0) goto LAB_00688a4e;

      pcVar11 = acStack_128;

    }

    FUN_00405000(pcVar11);

  }

  else {

    FUN_0042e980(&local_304,0);

    FUN_00408fd0(&local_300,0);

    FUN_00402070(&local_300);

    puVar10 = (undefined4 *)(local_300 + -0x14);

    LVar7 = InterlockedDecrement((LONG *)(local_300 + -0x10));

    if ((LVar7 == 0) && (puVar10 != (undefined4 *)0x0)) {

      (**(code **)*puVar10)(1);

    }

    puVar10 = (undefined4 *)(local_304 - 0x14);

    LVar7 = InterlockedDecrement((LONG *)(local_304 - 0x10));

    if ((LVar7 == 0) && (puVar10 != (undefined4 *)0x0)) {

      (**(code **)*puVar10)(1);

    }

  }

LAB_00688a4e:

  FUN_0042dc80();

  cVar5 = FUN_0068b0b0(param_3 >> 8 & 0xff,local_1d8);

  if (cVar5 != '\0') {

    FUN_0042dc80();

    FUN_0042c9c0(DAT_008f8c5c,3);

    puVar12 = puVar3;

    InterlockedIncrement((LONG *)(puVar3 + -0x10));

    FUN_0042e9f0(DAT_008f8c60,puVar12);

    FUN_0042e660(DAT_008f8c64,local_1d8);

    cVar5 = FUN_0042ce00(1);

    if (cVar5 != '\0') {

      FUN_0042e980(&local_304,0);

      FUN_00408fd0(&local_300,0);

      FUN_00402070(&local_300);

      LVar7 = InterlockedDecrement((LONG *)(local_300 + -0x10));

      if ((LVar7 == 0) && ((undefined4 *)(local_300 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(local_300 + -0x14))(1);

      }

      puVar10 = (undefined4 *)(local_304 - 0x14);

      LVar7 = InterlockedDecrement((LONG *)(local_304 - 0x10));

      if ((LVar7 == 0) && (puVar10 != (undefined4 *)0x0)) {

        (**(code **)*puVar10)(1);

      }

    }

    FUN_0042e590();

  }

  *param_2 = puVar3;

  InterlockedIncrement((LONG *)(puVar3 + -0x10));

  FUN_0042e590();

  FUN_0042e590();

  LVar7 = InterlockedDecrement((LONG *)(local_2fc[0] + -0x10));

  if ((LVar7 == 0) && ((undefined4 *)(local_2fc[0] + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_2fc[0] + -0x14))(1);

  }

  LVar7 = InterlockedDecrement((LONG *)(puVar3 + -0x10));

  if ((LVar7 == 0) && ((undefined4 *)(puVar3 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(puVar3 + -0x14))(1);

  }

  return param_2;

}





// --- FUN_00688be0 at 0x00688BE0 (size: 96) ---


undefined4 __thiscall

FUN_00688be0(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,uint param_5)



{

  uint *puVar1;

  undefined4 uVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x338) + (param_5 % *(uint *)(param_1 + 0x340)) * 4);

  while( true ) {

    if (puVar1 == (uint *)0x0) {

      return 0;

    }

    if (*puVar1 == param_5) break;

    puVar1 = (uint *)puVar1[1];

  }

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  if (puVar1[4] == 0) {

    return 0;

  }

  uVar2 = FUN_0068f6b0(param_2,param_3,param_4);

  return uVar2;

}





// --- FUN_00688d20 at 0x00688D20 (size: 120) ---


uint __thiscall FUN_00688d20(int param_1,uint *param_2)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_00688d4b:

      if ((int)(*(uint *)(param_1 + 0x68) * 2) < *(int *)(param_1 + 0x6c) + 1) {

        FUN_006881f0();

      }

      uVar3 = *param_2 % *(uint *)(param_1 + 0x68);

      iVar2 = *(int *)(param_1 + 0x60);

      param_2[1] = *(uint *)(iVar2 + uVar3 * 4);

      *(uint **)(iVar2 + uVar3 * 4) = param_2;

      uVar3 = iVar2 + uVar3 * 4;

      if (uVar3 < *(uint *)(param_1 + 100)) {

        *(uint *)(param_1 + 100) = uVar3;

      }

      iVar2 = *(int *)(param_1 + 0x6c) + 1;

      *(int *)(param_1 + 0x6c) = iVar2;

      return CONCAT31((int3)((uint)iVar2 >> 8),1);

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return (uint)puVar1 & 0xffffff00;

      }

      goto LAB_00688d4b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_006891f0 at 0x006891F0 (size: 88) ---


undefined4 FUN_006891f0(undefined4 *param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)FUN_005df0f5(0xc);

  if (puVar2 == (undefined4 *)0x0) {

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = *param_1;

    puVar2[1] = 0;

    puVar2[2] = *param_2;

  }

  cVar1 = FUN_0042bd40(puVar2);

  if (cVar1 == '\0') {

    if (puVar2 != (undefined4 *)0x0) {

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_00689250 at 0x00689250 (size: 142) ---


undefined4 __thiscall FUN_00689250(int param_1,uint *param_2,uint *param_3)



{

  uint *puVar1;

  int iVar2;

  uint *puVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 100) + (*param_2 % *(uint *)(param_1 + 0x6c)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0068927b:

      puVar1 = (uint *)FUN_005df0f5(0x20);

      if (puVar1 == (uint *)0x0) {

        FUN_0042bd40(0);

        return 1;

      }

      *puVar1 = *param_2;

      puVar1[1] = 0;

      puVar3 = puVar1 + 2;

      for (iVar2 = 6; iVar2 != 0; iVar2 = iVar2 + -1) {

        *puVar3 = *param_3;

        param_3 = param_3 + 1;

        puVar3 = puVar3 + 1;

      }

      FUN_0042bd40(puVar1);

      return 1;

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        puVar1 = puVar1 + 2;

        for (iVar2 = 6; iVar2 != 0; iVar2 = iVar2 + -1) {

          *puVar1 = *param_3;

          param_3 = param_3 + 1;

          puVar1 = puVar1 + 1;

        }

        return 1;

      }

      goto LAB_0068927b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_006892e0 at 0x006892E0 (size: 99) ---


undefined1 __thiscall FUN_006892e0(int param_1,int param_2)



{

  undefined4 uVar1;

  char cVar2;

  uint uVar3;

  undefined4 uVar4;

  

  cVar2 = FUN_00688d20(param_2);

  if (cVar2 == '\0') {

    return 0;

  }

  uVar1 = *(undefined4 *)(param_1 + 0x78);

  *(undefined4 *)(param_2 + 0x14) = uVar1;

  uVar3 = *(uint *)(param_1 + 0x74) & 0x7fffffff;

  if (uVar3 <= *(uint *)(param_1 + 0x78)) {

    uVar4 = FUN_00453850(uVar3 + 1);

    cVar2 = FUN_004180a0(uVar4);

    if (cVar2 == '\0') goto LAB_00689331;

  }

  *(int *)(*(int *)(param_1 + 0x70) + *(int *)(param_1 + 0x78) * 4) = param_2;

  *(int *)(param_1 + 0x78) = *(int *)(param_1 + 0x78) + 1;

LAB_00689331:

  FUN_00687e40(uVar1,param_2);

  return 1;

}





// --- FUN_00689350 at 0x00689350 (size: 87) ---


int __fastcall FUN_00689350(int param_1)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  

  iVar2 = FUN_004171e0(&stack0x00000004);

  if (iVar2 != 0) {

    uVar1 = *(uint *)(iVar2 + 0x14);

    if (uVar1 < *(uint *)(param_1 + 0x78)) {

      uVar3 = *(uint *)(param_1 + 0x78) - 1;

      *(uint *)(param_1 + 0x78) = uVar3;

      if (uVar1 != uVar3) {

        *(undefined4 *)(*(int *)(param_1 + 0x70) + uVar1 * 4) =

             *(undefined4 *)(*(int *)(param_1 + 0x70) + uVar3 * 4);

        *(undefined4 *)(*(int *)(param_1 + 0x70) + *(int *)(param_1 + 0x78) * 4) = 0;

      }

    }

    if (uVar1 < *(uint *)(param_1 + 0x6c)) {

      FUN_00688000(uVar1,*(undefined4 *)(*(int *)(param_1 + 0x70) + uVar1 * 4));

    }

  }

  return iVar2;

}





// --- FUN_006893b0 at 0x006893B0 (size: 68) ---


void __fastcall FUN_006893b0(int param_1)



{

  int *piVar1;

  

  FUN_00431730();

  FUN_005870f0();

  FUN_005870f0();

  FUN_00687610();

  piVar1 = *(int **)(param_1 + 0x108);

  if (piVar1 != (int *)0x0) {

    (**(code **)(*piVar1 + 8))(piVar1);

    *(undefined4 *)(param_1 + 0x108) = 0;

  }

  return;

}





// --- FUN_00689400 at 0x00689400 (size: 82) ---


undefined4 * __thiscall FUN_00689400(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_00800088;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_00800070;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00689460 at 0x00689460 (size: 82) ---


undefined4 * __thiscall FUN_00689460(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_0080008c;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_00800074;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_006894c0 at 0x006894C0 (size: 87) ---


void __fastcall FUN_006894c0(undefined4 *param_1)



{

  FUN_005870f0();

  FUN_0044dcb0();

  if ((param_1[0x1d] & 0x80000000) == 0x80000000) {

    operator_delete__((void *)param_1[0x1c]);

  }

  *param_1 = &PTR_FUN_00800078;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  return;

}





// --- FUN_00689520 at 0x00689520 (size: 161) ---


void __thiscall FUN_00689520(int param_1,uint param_2,uint param_3,uint param_4,uint param_5)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0068954b:

      puVar1 = (uint *)FUN_005df0f5(0x18);

      if (puVar1 != (uint *)0x0) {

        *puVar1 = param_2;

        puVar1[1] = 0;

        puVar1[2] = param_3;

        puVar1[4] = param_5;

        puVar1[3] = param_4;

        puVar1[5] = 0;

        FUN_006892e0(puVar1);

        return;

      }

      FUN_006892e0(0);

      return;

    }

    if (*puVar1 == param_2) {

      if (puVar1 != (uint *)0x0) {

        puVar1[2] = param_3;

        puVar1[4] = param_5;

        puVar1[3] = param_4;

        FUN_00688000(puVar1[5],puVar1);

        return;

      }

      goto LAB_0068954b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_006895d0 at 0x006895D0 (size: 234) ---


undefined4 * __fastcall FUN_006895d0(undefined4 *param_1)



{

  FUN_00432430();

  *param_1 = &PTR_FUN_008000c8;

  param_1[0x40] = 0;

  param_1[0x41] = 0;

  param_1[0x42] = 0;

  param_1[0x43] = 0;

  param_1[0x44] = 0;

  param_1[0x45] = 0;

  param_1[0x46] = 0;

  param_1[0x47] = 0xffffffff;

  param_1[0x48] = 0xffffffff;

  param_1[0x49] = 0xffffffff;

  param_1[0x4a] = &PTR_FUN_00800088;

  FUN_006884e0(0x17);

  param_1[0x67] = &PTR_FUN_0080008c;

  FUN_00688570(0x17);

  FUN_0068f710();

  param_1[0xd6] = 0;

  FUN_00688600(0x17);

  param_1[0xf3] = 0;

  param_1[0xf4] = 0;

  param_1[0xf5] = 0;

  param_1[0xf8] = 1;

  *(undefined1 *)((int)param_1 + 0x3ed) = 1;

  param_1[0xfc] = 0;

  *(undefined1 *)(param_1 + 0xfd) = 0;

  *(undefined1 *)((int)param_1 + 0x3f5) = 0;

  *(undefined1 *)((int)param_1 + 0x3f6) = 0;

  param_1[0xf9] = 0;

  param_1[0xfa] = 0;

  CoInitialize((LPVOID)0x0);

  return param_1;

}





// --- FUN_00689770 at 0x00689770 (size: 288) ---


void __fastcall FUN_00689770(undefined4 *param_1)



{

  int *piVar1;

  

  *param_1 = &PTR_FUN_008000c8;

  FUN_00431730();

  FUN_005870f0();

  FUN_005870f0();

  FUN_00687610();

  piVar1 = (int *)param_1[0x42];

  if (piVar1 != (int *)0x0) {

    (**(code **)(*piVar1 + 8))(piVar1);

    param_1[0x42] = 0;

  }

  if ((HMODULE)param_1[0x41] != (HMODULE)0x0) {

    FreeLibrary((HMODULE)param_1[0x41]);

    param_1[0x41] = 0;

    CoUninitialize();

  }

  FUN_006894c0();

  FUN_00690070();

  param_1[0x67] = &PTR_FUN_0080008c;

  FUN_005870f0();

  param_1[0x68] = &PTR_FUN_00800074;

  if ((undefined4 *)param_1[0x80] != param_1 + 0x69) {

    operator_delete__((undefined4 *)param_1[0x80]);

  }

  param_1[0x80] = 0;

  param_1[0x81] = 0;

  param_1[0x82] = 0;

  param_1[0x83] = 0;

  param_1[0x4a] = &PTR_FUN_00800088;

  FUN_005870f0();

  param_1[0x4b] = &PTR_FUN_00800070;

  if ((undefined4 *)param_1[99] != param_1 + 0x4c) {

    operator_delete__((undefined4 *)param_1[99]);

  }

  param_1[99] = 0;

  param_1[100] = 0;

  param_1[0x65] = 0;

  param_1[0x66] = 0;

  if ((param_1[0x45] & 0x80000000) == 0x80000000) {

    operator_delete__((void *)param_1[0x44]);

  }

  FUN_00431be0();

  return;

}





// --- FUN_00689890 at 0x00689890 (size: 1972) ---


undefined4 __thiscall FUN_00689890(int param_1,uint param_2,int param_3,int param_4,int param_5)



{

  uint *puVar1;

  uint uVar2;

  bool bVar3;

  bool bVar4;

  bool bVar5;

  undefined4 uVar6;

  LONG LVar7;

  char cVar8;

  uint uVar9;

  void *pvVar10;

  int iVar11;

  BOOL BVar12;

  undefined3 uVar13;

  undefined3 extraout_var;

  uint uVar14;

  uint *local_c8;

  uint local_c4;

  float local_c0;

  uint local_bc;

  undefined **local_b8;

  uint *local_b4;

  uint *local_b0;

  undefined **local_ac;

  uint *local_a8;

  uint local_a4;

  uint local_a0;

  uint local_9c;

  undefined **local_98;

  tagRECT local_94;

  uint local_84;

  tagPOINT local_80;

  uint local_78;

  undefined **local_74;

  uint *local_70;

  int local_6c;

  int local_68;

  undefined **local_64;

  uint *local_60;

  uint local_5c;

  uint local_58;

  uint local_54;

  undefined **local_50;

  uint *local_4c;

  uint local_48;

  uint local_44;

  uint local_40;

  undefined **local_3c;

  uint *local_38;

  float local_34;

  int local_30;

  undefined **local_10;

  uint *local_c;

  uint local_8;

  

  iVar11 = param_3;

  uVar14 = param_2;

  uVar6 = DAT_008379ac;

  *(undefined4 *)(param_1 + 0x10) = DAT_008379a8;

  *(undefined4 *)(param_1 + 0x14) = uVar6;

  local_b0 = (uint *)0x0;

  cVar8 = FUN_00688470(param_2,param_3,&local_6c);

  if (cVar8 != '\0') {

    for (local_b0 = *(uint **)(*(int *)(param_1 + 0xf0) + (local_5c % *(uint *)(param_1 + 0xf8)) * 4

                              ); (local_b0 != (uint *)0x0 && (*local_b0 != local_5c));

        local_b0 = (uint *)local_b0[1]) {

    }

  }

  local_c0 = 0.0;

  uVar9 = FUN_00687250(iVar11,param_4,&local_c0);

  local_ac = *(undefined ***)(param_1 + 4);

  local_a8 = *(uint **)(param_1 + 8);

  local_98 = *(undefined ***)(param_1 + 0x358);

  local_c8 = (uint *)(uVar9 | 0x80000000);

  bVar4 = false;

  if (iVar11 == 1) {

    if ((uVar9 & 2) == 0) {

      bVar4 = true;

      local_bc = 0;

      cVar8 = FUN_006881a0(uVar14,&local_bc);

      if (((cVar8 != '\0') && (((uint)local_60 & 0x10) == 0)) &&

         (param_5 - local_bc <= DAT_008f8c68)) {

        local_ac = local_b8;

        local_94.right = (LONG)local_b8;

        local_94.left = (LONG)local_b8;

        local_a8 = local_b4;

        local_94.bottom = (LONG)local_b4;

        local_94.top = (LONG)local_b4;

        local_c8 = (uint *)(uVar9 | 0x80000008);

        InflateRect(&local_94,DAT_008f8c70,DAT_008f8c74);

        BVar12 = PtInRect(&local_94,*(POINT *)(param_1 + 4));

        if (BVar12 != 0) {

          local_c8 = (uint *)(uVar9 | 0x80000028);

        }

      }

      uVar14 = param_2;

      FUN_00689520(param_2,param_5,*(undefined4 *)(param_1 + 4),*(undefined4 *)(param_1 + 8));

    }

    else {

      local_98 = local_64;

      if (((uint)local_60 & 8) != 0) {

        local_c8 = (uint *)(uVar9 | 0x80000010);

        pvVar10 = (void *)FUN_00689350(uVar14);

        if (pvVar10 != (void *)0x0) {

          operator_delete(pvVar10);

        }

        if (((uint)local_60 & 0x20) != 0) {

          local_c8 = (uint *)(uVar9 | 0x80000050);

        }

      }

      local_a4 = 0;

      cVar8 = FUN_006881a0(uVar14,&local_a4);

      if ((cVar8 != '\0') && (param_5 - local_a4 <= DAT_008f8c6c)) {

        local_c8 = (uint *)((uint)local_c8 | 4);

      }

    }

    uVar9 = FUN_0068e7a0(uVar14);

    if (uVar9 != 0) {

      if (((uint)local_c8 & 1) == 0) {

        *(uint *)(param_1 + 0x358) = *(uint *)(param_1 + 0x358) & ~uVar9;

      }

      else {

        *(uint *)(param_1 + 0x358) = *(uint *)(param_1 + 0x358) | uVar9;

      }

    }

    while (*(int *)(param_1 + 0x3c8) != 0) {

      iVar11 = **(int **)(param_1 + 0x3cc);

      if (((iVar11 == 0) || ((uint)(param_5 - *(int *)(iVar11 + 8)) < 5000)) ||

         (*(int *)(param_1 + 0x3c8) == 0)) break;

      pvVar10 = (void *)**(int **)(param_1 + 0x3cc);

      FUN_00687a50(&local_a4,pvVar10);

      if (local_9c != 0) {

        FUN_00428ba0(local_a4,local_a0,local_9c);

      }

      if (*(int *)(param_1 + 0x3d4) != 0) {

        iVar11 = *(int *)(param_1 + 0x3d4) + -1;

        *(int *)(param_1 + 0x3d4) = iVar11;

        if (iVar11 != 0) {

          **(undefined4 **)(param_1 + 0x3cc) = (*(undefined4 **)(param_1 + 0x3cc))[iVar11];

          *(undefined4 *)(*(int *)(param_1 + 0x3cc) + *(int *)(param_1 + 0x3d4) * 4) = 0;

        }

      }

      if (*(int *)(param_1 + 0x3c8) != 0) {

        FUN_00687ed0(0,**(undefined4 **)(param_1 + 0x3cc));

      }

      uVar14 = param_2;

      if (pvVar10 != (void *)0x0) {

        operator_delete(pvVar10);

        uVar14 = param_2;

      }

    }

    if ((!bVar4) && (pvVar10 = (void *)FUN_004171e0(&param_2), pvVar10 != (void *)0x0)) {

      operator_delete(pvVar10);

    }

  }

  else {

    bVar4 = true;

  }

  bVar3 = false;

  if (((((uint)local_c8 & 2) != 0) && (local_b0 != (uint *)0x0)) &&

     ((uVar9 = local_b0[5], uVar9 == 1 || ((uVar9 == 5 || (uVar9 == 4)))))) {

    bVar3 = true;

  }

  local_74 = local_98;

  local_50 = local_98;

  local_c4 = 0;

  local_84 = 0;

  local_a0 = 0;

  local_78 = uVar14;

  local_70 = local_c8;

  local_54 = uVar14;

  local_4c = local_c8;

  cVar8 = FUN_00430ea0(&local_78,&local_c4);

  uVar9 = 0;

  if (cVar8 == '\0') {

    FUN_00688150(param_1 + 0x6c);

    bVar5 = false;

LAB_00689c78:

    do {

      LVar7 = local_94.top;

      if ((uint *)local_94.top == (uint *)0x0) break;

      puVar1 = *(uint **)(local_94.top + 0xc);

      if (puVar1 == (uint *)0x0) {

        local_94.right = 0;

      }

      else {

        puVar1[4] = 0;

      }

      uVar14 = *(uint *)local_94.top;

      uVar9 = *(uint *)(local_94.top + 4);

      uVar2 = *(uint *)(local_94.top + 8);

      local_94.top = (LONG)puVar1;

      operator_delete((void *)LVar7);

      local_94.bottom = local_94.bottom + -1;

      if (uVar14 != 1) {

        if (uVar14 == 2) break;

        for (puVar1 = *(uint **)(*(int *)(param_1 + 0x338) +

                                (uVar14 % *(uint *)(param_1 + 0x340)) * 4); puVar1 != (uint *)0x0;

            puVar1 = (uint *)puVar1[1]) {

          if (*puVar1 == uVar14) {

            if ((puVar1 != (uint *)0x0) && (puVar1[4] != 0)) {

              local_b8 = (undefined **)0x0;

              local_b4 = (uint *)0x0;

              local_bc = 0xffffffff;

              cVar8 = FUN_0068e540(&local_78,&local_80,&local_bc);

              if ((cVar8 != '\0') &&

                 ((!bVar5 || (cVar8 = FUN_0068b300(&local_54,&local_bc), cVar8 != '\0')))) {

                local_c4 = local_80.x;

                local_54 = local_bc;

                local_50 = local_b8;

                local_4c = local_b4;

                bVar5 = true;

                local_a4 = uVar14;

                local_a0 = uVar9;

                local_9c = uVar2;

                local_84 = uVar14;

              }

            }

            break;

          }

        }

        goto LAB_00689c78;

      }

    } while ((param_2 & 0xff) !=

             *(uint *)(*(int *)(param_1 + 0x11c) * 0x30 + 0x24 + *(int *)(param_1 + 0x110)));

    local_94.left = (LONG)&PTR_FUN_0079931c;

    FUN_00431730();

    uVar14 = param_2;

    uVar9 = local_84;

  }

  if (bVar3) {

    FUN_00430ee0();

    local_48 = local_5c;

    local_44 = local_58;

    local_38 = local_60;

    local_3c = local_64;

    local_30 = param_5;

    local_c = local_a8;

    local_10 = local_ac;

    local_8 = local_b0[6];

    local_34 = 0.0;

    local_40 = uVar14;

    FUN_004326d0(&local_48);

  }

  iVar11 = 0;

  if ((local_c4 != 0) && (iVar11 = 0, local_c4 != 1)) {

    if (local_c4 == 2) {

      iVar11 = *(int *)(param_1 + 0x3e4) + param_4;

      *(int *)(param_1 + 0x3e4) = iVar11;

    }

    else if (local_c4 == 3) {

      iVar11 = *(int *)(param_1 + 1000) + param_4;

      *(int *)(param_1 + 1000) = iVar11;

    }

    else {

      iVar11 = FUN_00557a30();

      if ((iVar11 == 0) &&

         (((((local_c4 != 7 && (local_c4 != 8)) && (local_c4 != 10)) && (local_c4 != 0xb)) ||

          (((BVar12 = GetCursorPos(&local_80), BVar12 == 0 ||

            (BVar12 = ScreenToClient(*(HWND *)(param_1 + 0x10c),&local_80), BVar12 == 0)) ||

           (iVar11 = FUN_00557a60(local_80.x,local_80.y), iVar11 == 0)))))) {

        if ((((uint)local_4c & 0xa9) == 0) && (local_c0 == DAT_00796344)) {

          local_c0 = 1.0;

        }

        FUN_00430ee0();

        local_48 = local_c4;

        local_40 = local_78;

        local_38 = local_70;

        local_3c = local_74;

        local_34 = local_c0;

        local_10 = local_ac;

        local_30 = param_5;

        local_c = local_a8;

        local_8 = local_a0;

        local_44 = uVar9;

        iVar11 = FUN_004328c0(&local_48);

      }

    }

  }

  uVar13 = (undefined3)((uint)iVar11 >> 8);

  if (bVar4) {

    local_68 = param_3;

    local_64 = local_98;

    local_6c = param_4;

    local_5c = local_c4;

    local_60 = local_c8;

    local_58 = uVar9;

    FUN_00689250(&param_2,&local_6c);

    uVar13 = extraout_var;

  }

  return CONCAT31(uVar13,1);

}





// --- FUN_0068a050 at 0x0068A050 (size: 30) ---


void * __thiscall FUN_0068a050(void *param_1,byte param_2)



{

  FUN_00689770();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0068a070 at 0x0068A070 (size: 555) ---


uint __thiscall FUN_0068a070(int param_1,int param_2,int *param_3)



{

  int *piVar1;

  uint *puVar2;

  uint uVar3;

  uint uVar4;

  undefined4 *puVar5;

  uint uVar6;

  undefined8 uVar7;

  int iVar8;

  int iVar9;

  uint local_15c;

  uint local_158;

  uint *local_154 [6];

  undefined4 local_13c [6];

  undefined4 uStack_124;

  

  puVar5 = (undefined4 *)(*(int *)(param_1 + 0x110) + param_2 * 0x30);

  uVar6 = puVar5[9] & 0xff | *param_3 << 0x10;

  for (puVar2 = *(uint **)(*(int *)(param_1 + 0x18c) + (uVar6 % *(uint *)(param_1 + 0x194)) * 4);

      local_158 = uVar6, puVar2 != (uint *)0x0; puVar2 = (uint *)puVar2[1]) {

    if (*puVar2 == uVar6) {

      if (puVar2 != (uint *)0x0) {

        local_15c = puVar2[2];

        goto LAB_0068a11b;

      }

      break;

    }

  }

  piVar1 = (int *)*puVar5;

  local_13c[0] = 0x13c;

  puVar2 = (uint *)(**(code **)(*piVar1 + 0x38))(piVar1,local_13c,*param_3,1);

  if ((int)puVar2 < 0) {

LAB_0068a145:

    return (uint)puVar2 & 0xffffff00;

  }

  local_15c = FUN_006871e0(uStack_124);

  puVar2 = (uint *)FUN_006891f0(&local_158,&local_15c);

LAB_0068a11b:

  uVar3 = local_15c;

  if (local_15c == 0) goto LAB_0068a145;

  FUN_00688470(uVar6,local_15c,local_154);

  puVar2 = (uint *)param_3[1];

  if (local_154[0] == puVar2) {

    if (uVar3 != 2) goto LAB_0068a145;

LAB_0068a22e:

    uVar4 = FUN_00687320(2,puVar2);

    if (uVar4 == 0) goto LAB_0068a279;

    uVar4 = (uVar4 & 0xff) << 8 ^ uVar6;

    FUN_00689890(uVar4,1,0x80,param_3[2]);

    iVar9 = param_3[2];

    iVar8 = 0;

    uVar3 = 1;

  }

  else {

    if (uVar3 == 2) goto LAB_0068a22e;

    if (((int)uVar3 < 3) || (4 < (int)uVar3)) goto LAB_0068a279;

    uVar7 = FUN_00687320(uVar3,puVar2);

    uVar4 = (uint)uVar7;

    uVar3 = FUN_00687320(local_15c,(int)((ulonglong)uVar7 >> 0x20));

    if (uVar3 != uVar4) {

      if (uVar3 != 0) {

        local_158 = (uVar3 & 0xff) << 8 ^ uVar6;

        FUN_00689890(local_158,1,0,param_3[2]);

        FUN_00689890(local_158,local_15c,0,param_3[2]);

      }

      uVar3 = local_15c;

      if (uVar4 == 0) goto LAB_0068a279;

      FUN_00689890((uVar4 & 0xff) << 8 ^ uVar6,1,0x80,param_3[2]);

    }

    uVar3 = local_15c;

    if (uVar4 == 0) goto LAB_0068a279;

    iVar9 = param_3[2];

    uVar3 = param_3[1] >> 0x1f;

    uVar4 = (uVar4 & 0xff) << 8 ^ uVar6;

    iVar8 = (param_3[1] ^ uVar3) - uVar3;

    uVar3 = local_15c;

  }

  FUN_00689890(uVar4,uVar3,iVar8,iVar9);

  uVar3 = local_15c;

LAB_0068a279:

  uVar6 = FUN_00689890(uVar6,uVar3,param_3[1],param_3[2]);

  return uVar6;

}





// --- FUN_0068a2a0 at 0x0068A2A0 (size: 298) ---


void __thiscall FUN_0068a2a0(int param_1,undefined4 param_2)



{

  uint uVar1;

  DWORD DVar2;

  int iVar3;

  undefined4 uVar4;

  

  if ((char)param_2 == '\0') {

    iVar3 = *(int *)(param_1 + 0x3e0);

    if (iVar3 == 0) {

      uVar1 = FUN_0054fd20();

      *(uint *)(param_1 + 4) = uVar1 >> 1;

      uVar1 = FUN_0054fd30();

      *(uint *)(param_1 + 8) = uVar1 >> 1;

    }

    else if ((0 < iVar3) && (iVar3 < 3)) {

      *(undefined4 *)(param_1 + 4) = *(undefined4 *)(param_1 + 0x3d8);

      *(undefined4 *)(param_1 + 8) = *(undefined4 *)(param_1 + 0x3dc);

    }

    if (*(char *)(param_1 + 0x3ec) != '\0') {

      FUN_006873b0();

    }

    if ((*(int *)(param_1 + 0x3f0) != 0) &&

       (iVar3 = *(int *)(param_1 + 0x3f0) + -1, *(int *)(param_1 + 0x3f0) = iVar3, iVar3 == 0)) {

      ReleaseCapture();

    }

    uVar4 = 1;

  }

  else {

    if (*(char *)(param_1 + 0x3ec) == '\0') goto LAB_0068a375;

    if (*(int *)(param_1 + 0x3e0) == 1) {

      *(undefined4 *)(param_1 + 0x3d8) = *(undefined4 *)(param_1 + 4);

      *(undefined4 *)(param_1 + 0x3dc) = *(undefined4 *)(param_1 + 8);

    }

    iVar3 = *(int *)(param_1 + 0x3f0) + 1;

    *(int *)(param_1 + 0x3f0) = iVar3;

    if (iVar3 == 1) {

      SetCapture(*(HWND *)(param_1 + 0x10c));

    }

    uVar4 = 0;

  }

  FUN_00439620(uVar4);

LAB_0068a375:

  FUN_00430e90(param_2);

  uVar4 = *(undefined4 *)(*(int *)(param_1 + 0x124) * 0x30 + 0x24 + *(int *)(param_1 + 0x110));

  DVar2 = GetTickCount();

  FUN_00689890(CONCAT22(1,(ushort)(byte)uVar4),1,-((char)param_2 != '\0') & 0x80,DVar2);

  return;

}





// --- FUN_0068a3d0 at 0x0068A3D0 (size: 255) ---


void __thiscall FUN_0068a3d0(int param_1,int param_2)



{

  bool bVar1;

  uint uVar2;

  uint uVar3;

  uint local_18 [6];

  

  uVar2 = *(uint *)(param_2 + 0xc);

  if ((uVar2 & 0xc0000000) != 0x40000000) {

    uVar3 = uVar2 >> 0x10 & 0xff;

    bVar1 = (bool)((byte)(uVar2 >> 0x18) & 1);

    if (uVar3 == 0x45) {

      bVar1 = (uVar2 & 0x1000000) == 0;

    }

    else if (uVar3 == 0x36) {

      uVar3 = 0x2a;

    }

    uVar3 = -(uint)(bVar1 != false) & 0x80 | uVar3;

    uVar2 = *(uint *)(*(int *)(param_1 + 0x11c) * 0x30 + 0x24 + *(int *)(param_1 + 0x110)) & 0xff |

            uVar3 << 0x10;

    if ((*(int *)(param_2 + 4) == 0x100) || (*(int *)(param_2 + 4) == 0x104)) {

      bVar1 = true;

    }

    else {

      bVar1 = false;

    }

    if ((!bVar1) && (uVar3 == 0xb7)) {

      FUN_00689890(uVar2,1,0x80,*(undefined4 *)(param_2 + 0x10));

    }

    FUN_00688470(uVar2,1,local_18);

    if (local_18[0] != (-(uint)bVar1 & 0x80)) {

      FUN_00689890(uVar2,1,-(uint)bVar1 & 0x80,*(undefined4 *)(param_2 + 0x10));

    }

  }

  return;

}





// --- FUN_0068a4d0 at 0x0068A4D0 (size: 197) ---


void __thiscall FUN_0068a4d0(int param_1,int param_2,char param_3,undefined4 param_4)



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  uint local_18 [6];

  

  if ((param_3 == '\0') &&

     (iVar1 = *(int *)(param_1 + 0x3f0) + 1, *(int *)(param_1 + 0x3f0) = iVar1, iVar1 == 1)) {

    SetCapture(*(HWND *)(param_1 + 0x10c));

  }

  uVar3 = (param_2 + 0xc) * 0x10000 |

          *(uint *)(*(int *)(param_1 + 0x120) * 0x30 + 0x24 + *(int *)(param_1 + 0x110)) & 0xff;

  uVar2 = (param_3 != '\0') - 1 & 0x80;

  FUN_00688470(uVar3,1,local_18);

  if (local_18[0] != uVar2) {

    FUN_00689890(uVar3,1,uVar2,param_4);

  }

  if (((param_3 != '\0') && (*(int *)(param_1 + 0x3f0) != 0)) &&

     (iVar1 = *(int *)(param_1 + 0x3f0) + -1, *(int *)(param_1 + 0x3f0) = iVar1, iVar1 == 0)) {

    ReleaseCapture();

  }

  return;

}





// --- FUN_0068a5a0 at 0x0068A5A0 (size: 116) ---


void __thiscall FUN_0068a5a0(int param_1,int param_2,undefined4 param_3)



{

  uint uVar1;

  

  uVar1 = *(uint *)(*(int *)(param_1 + 0x120) * 0x30 + 0x24 + *(int *)(param_1 + 0x110)) & 0xff;

  if (param_2 < 1) {

    uVar1 = uVar1 | 0x80200;

  }

  else {

    uVar1 = uVar1 | 0x80100;

  }

  FUN_00689890(uVar1,1,0x80,param_3);

  FUN_00689890(uVar1,1,0,param_3);

  return;

}





// --- FUN_0068a620 at 0x0068A620 (size: 511) ---


void __fastcall FUN_0068a620(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  uint *puVar3;

  uint uVar4;

  DWORD DVar5;

  undefined4 *puVar6;

  uint uVar7;

  int iVar8;

  int *piVar9;

  undefined4 *puVar10;

  int *piVar11;

  undefined4 *puVar12;

  undefined4 local_60 [4];

  uint local_50;

  uint local_48 [2];

  undefined4 local_40;

  undefined4 local_3c;

  undefined4 local_38;

  undefined4 local_34;

  DWORD local_30;

  undefined4 local_10;

  undefined4 local_c;

  uint local_8;

  

  DVar5 = timeGetTime();

  iVar1 = *(int *)(param_1 + 0x20c);

  do {

    if (iVar1 == 0) {

      FUN_005870f0();

      if ((DAT_0083da58 != 0) && (*(int **)(DAT_0083da58 + 0xb8) != (int *)0x0)) {

        (**(code **)(**(int **)(DAT_0083da58 + 0xb8) + 0x70))();

      }

      if ((*(char *)(param_1 + 0x19) != '\0') && (*(int *)(param_1 + 0x118) != 0)) {

        FUN_00689890(CONCAT22(1,(ushort)(byte)*(undefined4 *)

                                               (*(int *)(param_1 + 0x124) * 0x30 + 0x24 +

                                               *(int *)(param_1 + 0x110))),1,0x80,DVar5);

      }

      return;

    }

    piVar11 = *(int **)(param_1 + 0x204);

    while (piVar11 != (int *)(*(int *)(param_1 + 0x200) + *(int *)(param_1 + 0x208) * 4)) {

      if (**(int **)(param_1 + 0x204) != 0) {

        piVar11 = *(int **)(param_1 + 0x204);

        puVar6 = (undefined4 *)*piVar11;

        goto LAB_0068a688;

      }

      piVar11 = *(int **)(param_1 + 0x204) + 1;

      *(int **)(param_1 + 0x204) = piVar11;

    }

    piVar11 = (int *)0x0;

    puVar6 = (undefined4 *)0x0;

LAB_0068a688:

    uVar2 = *puVar6;

    iVar1 = puVar6[1];

    puVar10 = puVar6 + 2;

    puVar12 = local_60;

    for (iVar8 = 6; iVar8 != 0; iVar8 = iVar8 + -1) {

      *puVar12 = *puVar10;

      puVar10 = puVar10 + 1;

      puVar12 = puVar12 + 1;

    }

    if (iVar1 == 0) {

      piVar9 = piVar11;

      do {

        piVar9 = piVar9 + 1;

        if (piVar9 == (int *)(*(int *)(param_1 + 0x200) + *(int *)(param_1 + 0x208) * 4)) break;

      } while (*piVar9 == 0);

    }

    puVar10 = (undefined4 *)*piVar11;

    if (puVar10 == puVar6) {

LAB_0068a6d4:

      *piVar11 = puVar10[1];

    }

    else {

      do {

        puVar12 = puVar10;

        puVar10 = (undefined4 *)puVar12[1];

      } while (puVar10 != puVar6);

      if (puVar12 == (undefined4 *)0x0) goto LAB_0068a6d4;

      puVar12[1] = puVar10[1];

    }

    *(int *)(param_1 + 0x20c) = *(int *)(param_1 + 0x20c) + -1;

    operator_delete(puVar6);

    uVar7 = FUN_0068e7a0(uVar2);

    uVar4 = local_50;

    if (uVar7 != 0) {

      *(uint *)(param_1 + 0x358) = *(uint *)(param_1 + 0x358) & ~uVar7;

    }

    for (puVar3 = *(uint **)(*(int *)(param_1 + 0xf0) + (local_50 % *(uint *)(param_1 + 0xf8)) * 4);

        puVar3 != (uint *)0x0; puVar3 = (uint *)puVar3[1]) {

      if (*puVar3 == local_50) {

        if (puVar3 != (uint *)0x0) {

          FUN_00430ee0();

          local_3c = local_60[2];

          local_10 = *(undefined4 *)(param_1 + 4);

          local_38 = local_60[3];

          local_c = *(undefined4 *)(param_1 + 8);

          local_8 = puVar3[6];

          local_48[0] = uVar4;

          local_34 = 0;

          local_40 = uVar2;

          local_30 = DVar5;

          FUN_004328c0(local_48);

        }

        break;

      }

    }

    iVar1 = *(int *)(param_1 + 0x20c);

  } while( true );

}





// --- FUN_0068a830 at 0x0068A830 (size: 768) ---


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



void __fastcall FUN_0068a830(int param_1)



{

  undefined4 uVar1;

  char cVar2;

  int *piVar3;

  int iVar4;

  BOOL BVar5;

  uint uVar6;

  undefined1 *puVar7;

  uint uVar8;

  int iVar9;

  tagPOINT local_a0c;

  uint local_a04;

  undefined1 local_a00 [2560];

  

  if ((_DAT_008f8bb4 & 1) == 0) {

    _DAT_008f8bb4 = _DAT_008f8bb4 | 1;

    DAT_008f8bac = *(int *)(param_1 + 4);

    DAT_008f8bb0 = *(int *)(param_1 + 8);

  }

  local_a0c.x = 0;

  if (*(int *)(param_1 + 0x118) != 0) {

    iVar9 = 0;

    do {

      uVar6 = local_a0c.x;

      if ((*(char *)(iVar9 + 0x2c + *(int *)(param_1 + 0x110)) != '\0') &&

         (cVar2 = FUN_00687130(*(undefined4 *)(iVar9 + *(int *)(param_1 + 0x110)),1), cVar2 != '\0')

         ) {

        if (uVar6 == *(uint *)(param_1 + 0x11c)) {

          local_a0c.x = -1;

          piVar3 = *(int **)(iVar9 + *(int *)(param_1 + 0x110));

          (**(code **)(*piVar3 + 100))(piVar3);

          piVar3 = *(int **)(iVar9 + *(int *)(param_1 + 0x110));

        }

        else {

          if (uVar6 != *(uint *)(param_1 + 0x120)) {

            if ((uVar6 != *(uint *)(param_1 + 0x124)) &&

               (*(int *)(*(int *)(param_1 + 0x110) + iVar9) != 0)) {

              local_a04 = 0x80;

              piVar3 = *(int **)(*(int *)(param_1 + 0x110) + iVar9);

              iVar4 = (**(code **)(*piVar3 + 0x28))(piVar3,0x14,local_a00,&local_a04,0);

              if (iVar4 < 0) {

                if (iVar4 == -0x7ff8fff4) {

                  piVar3 = *(int **)(iVar9 + *(int *)(param_1 + 0x110));

                  (**(code **)(*piVar3 + 0x1c))(piVar3);

                }

                else if (iVar4 == -0x7ff8ffe2) {

                  piVar3 = *(int **)(iVar9 + *(int *)(param_1 + 0x110));

                  (**(code **)(*piVar3 + 0x1c))(piVar3);

                }

              }

              else if ((*(char *)(param_1 + 0x3ed) != '\0') && (uVar8 = 0, local_a04 != 0)) {

                puVar7 = local_a00;

                do {

                  FUN_0068a070(local_a0c.x,puVar7);

                  uVar8 = uVar8 + 1;

                  puVar7 = puVar7 + 0x14;

                  uVar6 = local_a0c.x;

                } while (uVar8 < local_a04);

              }

            }

            goto LAB_0068a9ad;

          }

          local_a0c.x = -1;

          piVar3 = *(int **)(iVar9 + *(int *)(param_1 + 0x110));

          (**(code **)(*piVar3 + 100))(piVar3);

          piVar3 = *(int **)(iVar9 + *(int *)(param_1 + 0x110));

        }

        (**(code **)(*piVar3 + 0x28))(piVar3,0x14,0,&stack0xfffff5f0,0);

      }

LAB_0068a9ad:

      local_a0c.x = uVar6 + 1;

      iVar9 = iVar9 + 0x30;

    } while ((uint)local_a0c.x < *(uint *)(param_1 + 0x118));

  }

  if ((*(int *)(param_1 + 0x3e4) != 0) || (*(int *)(param_1 + 1000) != 0)) {

    BVar5 = GetCursorPos(&local_a0c);

    if (BVar5 != 0) {

      local_a0c.x = local_a0c.x + *(int *)(param_1 + 0x3e4);

      local_a0c.y = local_a0c.y + *(int *)(param_1 + 1000);

      SetCursorPos(local_a0c.x,local_a0c.y);

      *(int *)(param_1 + 4) = *(int *)(param_1 + 4) + *(int *)(param_1 + 0x3e4);

      *(int *)(param_1 + 8) = *(int *)(param_1 + 8) + *(int *)(param_1 + 1000);

    }

    *(undefined4 *)(param_1 + 0x3e4) = 0;

    *(undefined4 *)(param_1 + 1000) = 0;

  }

  uVar1 = DAT_008379a8;

  iVar9 = *(int *)(param_1 + 4);

  if ((DAT_008f8bac == iVar9) && (DAT_008f8bb0 == *(int *)(param_1 + 8))) {

    if ((*(char *)(param_1 + 0x19) != '\0') &&

       (*(double *)(param_1 + 0x10) + _DAT_007e3c88 < (double)CONCAT44(DAT_008379ac,DAT_008379a8)))

    {

      FUN_004313c0(0,0);

      return;

    }

  }

  else {

    *(undefined4 *)(param_1 + 0x14) = DAT_008379ac;

    *(undefined4 *)(param_1 + 0x10) = uVar1;

    if (*(char *)(param_1 + 0x19) == '\0') {

      FUN_00431390(iVar9,*(undefined4 *)(param_1 + 8));

    }

    else {

      FUN_004313c0(iVar9 - DAT_008f8bac,*(int *)(param_1 + 8) - DAT_008f8bb0);

      uVar6 = FUN_0054fd30();

      local_a0c.x = FUN_0054fd20();

      local_a0c.x = (uint)local_a0c.x >> 1;

      *(LONG *)(param_1 + 4) = local_a0c.x;

      *(uint *)(param_1 + 8) = uVar6 >> 1;

      local_a0c.y = uVar6 >> 1;

      BVar5 = ClientToScreen(*(HWND *)(param_1 + 0x10c),&local_a0c);

      if (BVar5 != 0) {

        SetCursorPos(local_a0c.x,local_a0c.y);

      }

    }

    DAT_008f8bac = *(int *)(param_1 + 4);

    DAT_008f8bb0 = *(int *)(param_1 + 8);

  }

  return;

}





// --- FUN_0068abb0 at 0x0068ABB0 (size: 16) ---


void FUN_0068abb0(void)



{

  FUN_0068a830();

  FUN_00431d60();

  return;

}





// --- FUN_0068b0b0 at 0x0068B0B0 (size: 147) ---


undefined4 FUN_0068b0b0(undefined4 param_1)



{

  switch(param_1) {

  default:

    return 0;

  case 1:

    FUN_0042c9c0(DAT_008f8e50,3);

    return 1;

  case 2:

    FUN_0042c9c0(DAT_008f8e54,3);

    return 1;

  case 3:

    FUN_0042c9c0(DAT_008f8e58,3);

    return 1;

  case 4:

    FUN_0042c9c0(DAT_008f8e5c,3);

    return 1;

  case 5:

    FUN_0042c9c0(DAT_008f8e60,3);

    return 1;

  case 6:

    FUN_0042c9c0(DAT_008f8e64,3);

    return 1;

  }

}





// --- FUN_0068b160 at 0x0068B160 (size: 39) ---


undefined4 __thiscall FUN_0068b160(int *param_1,int *param_2)



{

  if (((*param_1 == *param_2) && (param_1[1] == param_2[1])) && (param_1[2] == param_2[2])) {

    return 1;

  }

  return 0;

}





// --- FUN_0068b190 at 0x0068B190 (size: 36) ---


uint __thiscall FUN_0068b190(int *param_1,int *param_2)



{

  if (((*param_1 == *param_2) && (param_1[1] == param_2[1])) &&

     (param_2 = (int *)param_2[2], (param_1[2] & (uint)param_2) != 0)) {

    return CONCAT31((int3)((uint)param_2 >> 8),1);

  }

  return (uint)param_2 & 0xffffff00;

}





// --- FUN_0068b1c0 at 0x0068B1C0 (size: 89) ---


int FUN_0068b1c0(uint param_1)



{

  uint uVar1;

  

  uVar1 = (param_1 >> 1 & 0x55555555) + (param_1 & 0x55555555);

  uVar1 = (uVar1 >> 2 & 0x33333333) + (uVar1 & 0x33333333);

  uVar1 = (uVar1 >> 4 & 0xf0f0f0f) + (uVar1 & 0xf0f0f0f);

  uVar1 = (uVar1 >> 8 & 0xff00ff) + (uVar1 & 0xff00ff);

  return (uVar1 >> 0x10) + (uVar1 & 0xffff);

}





// --- FUN_0068b220 at 0x0068B220 (size: 54) ---


void __thiscall FUN_0068b220(undefined4 *param_1,int param_2)



{

  undefined4 *puVar1;

  

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) != 0) {

      *puVar1 = *param_1;

      return;

    }

    *param_1 = *puVar1;

  }

  return;

}





// --- FUN_0068b260 at 0x0068B260 (size: 147) ---


uint __thiscall FUN_0068b260(uint *param_1,uint *param_2)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  uint uVar4;

  bool bVar5;

  

  uVar1 = param_2[2];

  uVar2 = param_1[2];

  uVar3 = 0;

  if ((int)uVar2 < 0) {

    if ((int)uVar1 < 0) {

      if (((*param_1 == *param_2) && (param_1[1] == param_2[1])) && (uVar2 == uVar1)) {

        return 1;

      }

      return 0;

    }

    if (*param_2 != *param_1) goto LAB_0068b2eb;

    uVar3 = param_1[1] & param_2[1];

    bVar5 = uVar3 == param_2[1];

  }

  else {

    uVar3 = *param_2;

    if ((int)uVar1 < 0) {

      if (*param_1 != uVar3) goto LAB_0068b2eb;

      uVar4 = param_1[1];

      uVar3 = param_2[1] & uVar4;

    }

    else {

      if (*param_1 != uVar3) goto LAB_0068b2eb;

      uVar3 = param_1[1];

      uVar4 = param_2[1];

    }

    bVar5 = uVar3 == uVar4;

  }

  if ((bVar5) && ((uVar2 & uVar1) != 0)) {

    return CONCAT31((int3)(uVar3 >> 8),1);

  }

LAB_0068b2eb:

  return uVar3 & 0xffffff00;

}





// --- FUN_0068b300 at 0x0068B300 (size: 132) ---


bool __thiscall FUN_0068b300(int *param_1,int *param_2,int *param_3)



{

  uint uVar1;

  uint uVar2;

  bool bVar3;

  uint uVar4;

  uint uVar5;

  

  if (((*param_2 == *param_3) && (param_2[1] == param_3[1])) && (param_2[2] == param_3[2])) {

    return false;

  }

  if (*param_3 == *param_1) {

    uVar5 = param_1[1] & param_3[1];

    if ((uVar5 == param_3[1]) && (uVar1 = param_3[2], (param_1[2] & uVar1) != 0)) {

      bVar3 = true;

      if ((uint)param_2[2] <= uVar1) {

        if (uVar1 == param_2[2]) {

          uVar4 = param_2[1] & param_1[1];

          uVar1 = FUN_0068b1c0(uVar5);

          uVar2 = FUN_0068b1c0(uVar4);

          if (uVar1 < uVar2) {

            return false;

          }

          if (uVar1 == uVar2) {

            bVar3 = uVar4 < uVar5;

          }

        }

        return bVar3;

      }

    }

  }

  return false;

}





// --- FUN_0068b390 at 0x0068B390 (size: 83) ---


int __thiscall FUN_0068b390(int *param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *puVar2;

  

  iVar1 = (**(code **)(*param_1 + 4))();

  if (iVar1 == 0) {

    return 0;

  }

  if (*(undefined4 **)(iVar1 + 8) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(iVar1 + 8))(1);

  }

  *(undefined4 *)(iVar1 + 8) = 0;

  puVar2 = (undefined4 *)FUN_005df0f5(8);

  if (puVar2 != (undefined4 *)0x0) {

    *puVar2 = &PTR_FUN_00798108;

    puVar2[1] = param_2;

    *(undefined4 **)(iVar1 + 8) = puVar2;

    return iVar1;

  }

  *(undefined4 *)(iVar1 + 8) = 0;

  return iVar1;

}





// --- FUN_0068b3f0 at 0x0068B3F0 (size: 64) ---


undefined4 * __thiscall FUN_0068b3f0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_008001c0;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0068b430 at 0x0068B430 (size: 393) ---


undefined4 __thiscall FUN_0068b430(char *param_1,undefined4 *param_2,undefined4 *param_3)



{

  int iVar1;

  LONG LVar2;

  

  FUN_00401340("Keyboard");

  iVar1 = _stricmp((char *)*param_2,param_1);

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  if (iVar1 == 0) {

    *param_3 = 1;

    return 1;

  }

  FUN_00401340("Mouse");

  iVar1 = _stricmp((char *)*param_2,param_1);

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  if (iVar1 == 0) {

    *param_3 = 2;

    return 1;

  }

  FUN_00401340("Joystick");

  iVar1 = _stricmp((char *)*param_2,param_1);

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  if (iVar1 == 0) {

    *param_3 = 3;

    return 1;

  }

  FUN_00401340("Virtual");

  iVar1 = _stricmp((char *)*param_2,param_1);

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  if (iVar1 == 0) {

    *param_3 = 4;

    return 1;

  }

  *param_3 = 0;

  return 0;

}





// --- FUN_0068b5c0 at 0x0068B5C0 (size: 573) ---


undefined4 __thiscall FUN_0068b5c0(char *param_1,undefined4 *param_2,undefined4 *param_3)



{

  int iVar1;

  LONG LVar2;

  

  FUN_00401340("AxisPositive");

  iVar1 = _stricmp((char *)*param_2,param_1);

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  if (iVar1 == 0) {

    *param_3 = 1;

    return 1;

  }

  FUN_00401340("AxisNegative");

  iVar1 = _stricmp((char *)*param_2,param_1);

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  if (iVar1 == 0) {

    *param_3 = 2;

    return 1;

  }

  FUN_00401340("POVUp");

  iVar1 = _stricmp((char *)*param_2,param_1);

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  if (iVar1 == 0) {

    *param_3 = 3;

    return 1;

  }

  FUN_00401340("POVRight");

  iVar1 = _stricmp((char *)*param_2,param_1);

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  if (iVar1 == 0) {

    *param_3 = 4;

    return 1;

  }

  FUN_00401340("POVDown");

  iVar1 = _stricmp((char *)*param_2,param_1);

  FUN_004011b0();

  if (iVar1 == 0) {

    *param_3 = 5;

    return 1;

  }

  FUN_00401340("POVLeft");

  iVar1 = _stricmp((char *)*param_2,param_1);

  FUN_004011b0();

  if (iVar1 == 0) {

    *param_3 = 6;

    return 1;

  }

  FUN_00401340(&DAT_00795028);

  iVar1 = _stricmp((char *)*param_2,param_1);

  FUN_004011b0();

  if (iVar1 == 0) {

    *param_3 = 0;

    return 1;

  }

  *param_3 = 0;

  return 0;

}





// --- FUN_0068b800 at 0x0068B800 (size: 199) ---


int * FUN_0068b800(int *param_1,int param_2,int param_3)



{

  int iVar1;

  int *piVar2;

  int *piVar3;

  LONG *pLVar4;

  int *piVar5;

  undefined1 local_c [12];

  

  if (((param_2 != 1) && (param_2 != 2)) && (param_2 != 3)) {

    pLVar4 = (LONG *)(PTR_DAT_008183b4 + -0x10);

    *param_1 = (int)PTR_DAT_008183b4;

    InterlockedIncrement(pLVar4);

    return param_1;

  }

  piVar2 = (int *)FUN_0052dcf0(local_c);

  piVar5 = (int *)piVar2[1];

  piVar3 = (int *)piVar2[2];

  while (piVar3 != (int *)0x0) {

    do {

      if (piVar3[2] == param_3) {

        iVar1 = *piVar3;

        *param_1 = iVar1;

        InterlockedIncrement((LONG *)(iVar1 + -0x10));

        return param_1;

      }

      piVar3 = (int *)piVar3[1];

    } while (piVar3 != (int *)0x0);

    do {

      piVar5 = piVar5 + 1;

      if (piVar5 == (int *)(*(int *)(*piVar2 + 0x60) + *(int *)(*piVar2 + 0x68) * 4))

      goto LAB_0068b889;

      piVar3 = (int *)*piVar5;

    } while (piVar3 == (int *)0x0);

  }

LAB_0068b889:

  pLVar4 = (LONG *)(PTR_DAT_008183b4 + -0x10);

  *param_1 = (int)PTR_DAT_008183b4;

  InterlockedIncrement(pLVar4);

  return param_1;

}





// --- FUN_0068b8d0 at 0x0068B8D0 (size: 88) ---


undefined4 FUN_0068b8d0(int param_1)



{

  switch(param_1 + -1) {

  case 0:

    FUN_00405000("Keyboard");

    return 1;

  case 1:

    FUN_00405000("Mouse");

    return 1;

  case 2:

    FUN_00405000("Joystick");

    return 1;

  case 3:

    FUN_00405000("Virtual");

    return 1;

  default:

    return 0;

  }

}





// --- FUN_0068b940 at 0x0068B940 (size: 223) ---


undefined4 FUN_0068b940(uint param_1)



{

  switch(param_1 & 0x7fffffff) {

  case 1:

    FUN_00405000(&DAT_00800298);

    return 1;

  case 2:

    FUN_00405000(&DAT_00800294);

    return 1;

  case 3:

    FUN_00405000("Click");

    return 1;

  case 4:

    FUN_00405000(&DAT_00800288);

    return 1;

  default:

    return 0;

  case 8:

    FUN_00405000("DblClickDown");

    return 1;

  case 0x10:

    FUN_00405000("DblClickUp");

    return 1;

  case 0x18:

    FUN_00405000("DblClick");

    return 1;

  case 0x20:

    FUN_00405000("NearbyDown");

    return 1;

  case 0x40:

    FUN_00405000("NearbyUp");

    return 1;

  case 0x60:

    FUN_00405000("MouseDblClick");

    return 1;

  case 0x80:

    FUN_00405000("Analog");

    return 1;

  }

}





// --- FUN_0068bad0 at 0x0068BAD0 (size: 138) ---


undefined4 FUN_0068bad0(undefined4 param_1)



{

  switch(param_1) {

  case 0:

    FUN_00405000(&DAT_00795028);

    return 1;

  case 1:

    FUN_00405000("AxisPositive");

    return 1;

  case 2:

    FUN_00405000("AxisNegative");

    return 1;

  case 3:

    FUN_00405000("POVUp");

    return 1;

  case 4:

    FUN_00405000("POVRight");

    return 1;

  case 5:

    FUN_00405000("POVDown");

    return 1;

  case 6:

    FUN_00405000("POVLeft");

    return 1;

  default:

    return 0;

  }

}





// --- FUN_0068bb80 at 0x0068BB80 (size: 304) ---


undefined4 __thiscall FUN_0068bb80(uint *param_1,undefined4 param_2,undefined *param_3)



{

  LONG *lpAddend;

  undefined *puVar1;

  char cVar2;

  LONG LVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  undefined *puVar6;

  

  FUN_0068b390(*param_1 & 0xff);

  FUN_0068b800(&param_3,param_3,*(undefined2 *)((int)param_1 + 2));

  puVar1 = param_3;

  lpAddend = (LONG *)(param_3 + -0x10);

  InterlockedIncrement(lpAddend);

  puVar6 = puVar1;

  InterlockedIncrement(lpAddend);

  FUN_00426fe0(puVar6);

  puVar5 = (undefined4 *)(puVar1 + -0x14);

  LVar3 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

  if ((LVar3 == 0) && (puVar5 != (undefined4 *)0x0)) {

    (**(code **)*puVar5)(1);

  }

  if (*(char *)((int)param_1 + 1) != '\0') {

    param_3 = PTR_DAT_00818344;

    InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

    cVar2 = FUN_0068bad0(*(undefined1 *)((int)param_1 + 1),&param_3);

    if (cVar2 == '\0') {

      puVar4 = (undefined4 *)(param_3 + -0x14);

      LVar3 = InterlockedDecrement((LONG *)(param_3 + -0x10));

      if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

        (**(code **)*puVar4)(1);

      }

      LVar3 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

      if ((LVar3 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      return 0;

    }

    puVar6 = param_3;

    InterlockedIncrement((LONG *)(param_3 + -0x10));

    FUN_00426f90(puVar6);

    puVar4 = (undefined4 *)(param_3 + -0x14);

    LVar3 = InterlockedDecrement((LONG *)(param_3 + -0x10));

    if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

      (**(code **)*puVar4)(1);

    }

  }

  LVar3 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

  if ((LVar3 == 0) && (puVar5 != (undefined4 *)0x0)) {

    (**(code **)*puVar5)(1);

  }

  return 1;

}





// --- FUN_0068bcb0 at 0x0068BCB0 (size: 81) ---


undefined4 * __thiscall FUN_0068bcb0(undefined4 *param_1,undefined4 *param_2)



{

  undefined4 uVar1;

  LONG *lpAddend;

  undefined4 *unaff_retaddr;

  

  if (DAT_00837ff4 == (int *)0x0) {

    lpAddend = (LONG *)(PTR_DAT_008183b4 + -0x10);

    *param_2 = PTR_DAT_008183b4;

    InterlockedIncrement(lpAddend);

    return param_2;

  }

  uVar1 = (**(code **)(*DAT_00837ff4 + 0x54))(*param_1);

  FUN_0068b800(unaff_retaddr,uVar1,*(undefined2 *)((int)param_1 + 2));

  return unaff_retaddr;

}





// --- FUN_0068bd10 at 0x0068BD10 (size: 54) ---


undefined4 FUN_0068bd10(undefined4 param_1,undefined4 *param_2)



{

  undefined4 uVar1;

  undefined1 local_c [8];

  int local_4;

  

  FUN_00433100(local_c,param_1);

  if (local_4 != 0) {

    uVar1 = *(undefined4 *)(local_4 + 8);

    *param_2 = uVar1;

    return CONCAT31((int3)((uint)uVar1 >> 8),1);

  }

  return 0;

}





// --- FUN_0068bd50 at 0x0068BD50 (size: 128) ---


undefined4 FUN_0068bd50(undefined4 param_1)



{

  undefined4 local_10;

  undefined1 local_c [8];

  int local_4;

  

  local_10 = 0xffffffff;

  FUN_00433100(local_c,param_1);

  if (local_4 == 0) {

    FUN_00433100(local_c,param_1);

    if (local_4 == 0) {

      FUN_00433100(local_c,param_1);

      if (local_4 == 0) {

        FUN_0068bd10(param_1,&local_10);

        return local_10;

      }

    }

  }

  return *(undefined4 *)(local_4 + 8);

}





// --- FUN_0068bdd0 at 0x0068BDD0 (size: 143) ---


undefined4 * __thiscall FUN_0068bdd0(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_008001c0;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_0068be60 at 0x0068BE60 (size: 1089) ---


undefined4 FUN_0068be60(undefined4 param_1,uint *param_2)



{

  char cVar1;

  int iVar2;

  LONG LVar3;

  char *pcVar4;

  uint uVar5;

  char *pcVar6;

  char *pcVar7;

  char *local_40;

  char *local_3c;

  char *pcStack_38;

  char *pcStack_34;

  char *pcStack_30;

  char *pcStack_2c;

  char *pcStack_28;

  char *pcStack_24;

  char *pcStack_20;

  char *pcStack_1c;

  char *pcStack_18;

  char *pcStack_14;

  undefined **local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  *param_2 = 0;

  local_10 = &PTR_FUN_00795074;

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  thunk_FUN_0040c2d0(param_1,0x2f,&local_10);

  local_40 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  cVar1 = FUN_00405120(&local_40);

  do {

    if (cVar1 == '\0') {

      pcVar7 = local_40 + -0x14;

      LVar3 = InterlockedDecrement((LONG *)(local_40 + -0x10));

      if ((LVar3 == 0) && (pcVar7 != (char *)0x0)) {

        (*(code *)**(undefined4 **)pcVar7)(1);

      }

      local_10 = &PTR_FUN_00795074;

      FUN_00405210();

      return 1;

    }

    pcVar7 = "Down";

    do {

      pcVar6 = pcVar7;

      pcVar7 = pcVar6 + 1;

    } while (*pcVar6 != '\0');

    FUN_00401280(pcVar6 + -0x800298);

    pcVar7 = local_40;

    pcVar4 = "Down";

    pcVar6 = local_3c;

    do {

      cVar1 = *pcVar4;

      pcVar4 = pcVar4 + 1;

      *pcVar6 = cVar1;

      pcVar6 = pcVar6 + 1;

    } while (cVar1 != '\0');

    iVar2 = _stricmp(local_40,local_3c);

    pcVar6 = local_3c + -0x14;

    LVar3 = InterlockedDecrement((LONG *)(local_3c + -0x10));

    if ((LVar3 == 0) && (pcVar6 != (char *)0x0)) {

      (*(code *)**(undefined4 **)pcVar6)(1);

    }

    if (iVar2 == 0) {

      uVar5 = *param_2 | 1;

    }

    else {

      FUN_00401340(&DAT_00800294);

      iVar2 = _stricmp(pcVar7,pcStack_38);

      pcVar6 = pcStack_38 + -0x14;

      LVar3 = InterlockedDecrement((LONG *)(pcStack_38 + -0x10));

      if ((LVar3 == 0) && (pcVar6 != (char *)0x0)) {

        (*(code *)**(undefined4 **)pcVar6)(1);

      }

      if (iVar2 == 0) {

        uVar5 = *param_2 | 2;

      }

      else {

        FUN_00401340("Click");

        iVar2 = _stricmp(pcVar7,pcStack_34);

        pcVar6 = pcStack_34 + -0x14;

        LVar3 = InterlockedDecrement((LONG *)(pcStack_34 + -0x10));

        if ((LVar3 == 0) && (pcVar6 != (char *)0x0)) {

          (*(code *)**(undefined4 **)pcVar6)(1);

        }

        if (iVar2 == 0) {

          uVar5 = *param_2 | 3;

        }

        else {

          FUN_00401340(&DAT_00800288);

          iVar2 = _stricmp(pcVar7,pcStack_30);

          pcVar6 = pcStack_30 + -0x14;

          LVar3 = InterlockedDecrement((LONG *)(pcStack_30 + -0x10));

          if ((LVar3 == 0) && (pcVar6 != (char *)0x0)) {

            (*(code *)**(undefined4 **)pcVar6)(1);

          }

          if (iVar2 == 0) {

            uVar5 = *param_2 | 4;

          }

          else {

            FUN_00401340("DblClickDown");

            iVar2 = _stricmp(pcVar7,pcStack_2c);

            pcVar6 = pcStack_2c + -0x14;

            LVar3 = InterlockedDecrement((LONG *)(pcStack_2c + -0x10));

            if ((LVar3 == 0) && (pcVar6 != (char *)0x0)) {

              (*(code *)**(undefined4 **)pcVar6)(1);

            }

            if (iVar2 == 0) {

              uVar5 = *param_2 | 8;

            }

            else {

              FUN_00401340("DblClickUp");

              iVar2 = _stricmp(pcVar7,pcStack_28);

              pcVar6 = pcStack_28 + -0x14;

              LVar3 = InterlockedDecrement((LONG *)(pcStack_28 + -0x10));

              if ((LVar3 == 0) && (pcVar6 != (char *)0x0)) {

                (*(code *)**(undefined4 **)pcVar6)(1);

              }

              if (iVar2 == 0) {

                uVar5 = *param_2 | 0x10;

              }

              else {

                FUN_00401340("DblClick");

                iVar2 = _stricmp(pcVar7,pcStack_24);

                pcVar6 = pcStack_24 + -0x14;

                LVar3 = InterlockedDecrement((LONG *)(pcStack_24 + -0x10));

                if ((LVar3 == 0) && (pcVar6 != (char *)0x0)) {

                  (*(code *)**(undefined4 **)pcVar6)(1);

                }

                if (iVar2 == 0) {

                  uVar5 = *param_2 | 0x18;

                }

                else {

                  FUN_00401340("NearbyDown");

                  iVar2 = _stricmp(pcVar7,pcStack_20);

                  FUN_004011b0();

                  if (iVar2 == 0) {

                    uVar5 = *param_2 | 0x20;

                  }

                  else {

                    FUN_00401340("NearbyUp");

                    iVar2 = _stricmp(pcVar7,pcStack_1c);

                    FUN_004011b0();

                    if (iVar2 == 0) {

                      uVar5 = *param_2 | 0x40;

                    }

                    else {

                      FUN_00401340("MouseDblClick");

                      iVar2 = _stricmp(pcVar7,pcStack_18);

                      FUN_004011b0();

                      if (iVar2 == 0) {

                        uVar5 = *param_2 | 0x60;

                      }

                      else {

                        FUN_00401340("Analog");

                        iVar2 = _stricmp(pcVar7,pcStack_14);

                        FUN_004011b0();

                        if (iVar2 != 0) {

                          LVar3 = InterlockedDecrement((LONG *)(pcVar7 + -0x10));

                          if ((LVar3 == 0) && (pcVar7 + -0x14 != (char *)0x0)) {

                            (*(code *)**(undefined4 **)(pcVar7 + -0x14))(1);

                          }

                          local_10 = &PTR_FUN_00795074;

                          FUN_00405210();

                          return 0;

                        }

                        uVar5 = *param_2 | 0x80;

                      }

                    }

                  }

                }

              }

            }

          }

        }

      }

    }

    *param_2 = uVar5;

    cVar1 = FUN_00405120(&local_40);

  } while( true );

}





// --- FUN_0068c2b0 at 0x0068C2B0 (size: 523) ---


undefined4 __thiscall FUN_0068c2b0(undefined1 *param_1,int *param_2)



{

  undefined *puVar1;

  char cVar2;

  uint uVar3;

  undefined4 uVar4;

  int iVar5;

  int iVar6;

  LONG LVar7;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined1 unaff_BL;

  undefined1 unaff_BP;

  undefined4 unaff_ESI;

  undefined4 uVar8;

  undefined *puVar9;

  uint auStack_c [2];

  undefined4 uStack_4;

  

  if (param_2 != (int *)0x0) {

    uVar3 = FUN_0065ca40();

    if ((uVar3 < 2) || (3 < uVar3)) {

      uVar4 = extraout_ECX;

      FUN_00401340("ERROR - Must have 2 or 3 sub nodes, has %d instead.\n");

      FUN_0065d620(param_2,uVar4,uVar3);

    }

    else {

      uVar4 = (**(code **)(*param_2 + 0xc))(0);

      auStack_c[0] = 0xffffffff;

      cVar2 = FUN_00448290(auStack_c);

      puVar1 = PTR_DAT_00818344;

      if ((cVar2 != '\0') && (auStack_c[0] < 0x100)) {

        uVar4 = (**(code **)(*param_2 + 0xc))(1);

        FUN_00401a40();

        FUN_00426020(&uStack_4);

        iVar5 = FUN_0068bd50(&uStack_4);

        if ((iVar5 != -1) && ((short)((uint)iVar5 >> 0x10) == 0)) {

          auStack_c[0] = 0;

          iVar6 = (**(code **)(*param_2 + 0xc))(2);

          if (iVar6 != 0) {

            FUN_00401a40();

            FUN_00426020(&stack0xffffffe8);

            cVar2 = FUN_0068b5c0(&stack0xffffffe8,&stack0xfffffff0);

            if (cVar2 == '\0') {

              uVar4 = unaff_ESI;

              FUN_00401340("ERROR - invalid sub control index \"%s\"\n");

              FUN_0065d620(iVar6,unaff_ESI,uVar4);

              FUN_004011b0();

              FUN_004011b0();

              return 0;

            }

            FUN_004011b0();

          }

          *param_1 = unaff_BP;

          param_1[1] = unaff_BL;

          *(short *)(param_1 + 2) = (short)iVar5;

          FUN_004011b0();

          return 1;

        }

        uVar8 = uStack_4;

        FUN_00401340("ERROR - invalid device constant name \"%s\"\n");

        FUN_0065d620(uVar4,uStack_4,uVar8);

        FUN_004011b0();

        return 0;

      }

      InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

      FUN_00426020(&stack0x00000000);

      uVar8 = extraout_ECX_00;

      puVar9 = puVar1;

      FUN_00401340("ERROR - invalid device index \"%s\"\n");

      FUN_0065d620(uVar4,uVar8,puVar9);

      LVar7 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

      if ((LVar7 == 0) && ((undefined4 *)(puVar1 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(puVar1 + -0x14))(1);

        return 0;

      }

    }

  }

  return 0;

}





// --- FUN_0068c4c0 at 0x0068C4C0 (size: 157) ---


undefined4 FUN_0068c4c0(int *param_1,int *param_2)



{

  int iVar1;

  int *piVar2;

  LONG LVar3;

  undefined4 *puVar4;

  undefined1 local_c [8];

  int local_4;

  

  piVar2 = (int *)FUN_005df0f5(0xc);

  if (piVar2 == (int *)0x0) {

    piVar2 = (int *)0x0;

  }

  else {

    iVar1 = *param_1;

    *piVar2 = iVar1;

    InterlockedIncrement((LONG *)(iVar1 + -0x10));

    piVar2[1] = 0;

    piVar2[2] = *param_2;

  }

  FUN_00433100(local_c,piVar2);

  if (local_4 == 0) {

    FUN_00432b30(piVar2);

    return 1;

  }

  if (piVar2 != (int *)0x0) {

    puVar4 = (undefined4 *)(*piVar2 + -0x14);

    LVar3 = InterlockedDecrement((LONG *)(*piVar2 + -0x10));

    if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

      (**(code **)*puVar4)(1);

    }

    operator_delete(piVar2);

  }

  return 0;

}





// --- FUN_0068c560 at 0x0068C560 (size: 156) ---


void FUN_0068c560(int param_1)



{

  undefined1 *puVar1;

  LONG LVar2;

  undefined4 *puVar3;

  

  FUN_00401340(param_1);

  puVar1 = (undefined1 *)((*(uint *)(param_1 + -4) - 1) + param_1);

  if (2 < *(uint *)(param_1 + -4)) {

    puVar1 = (undefined1 *)(param_1 + 2);

  }

  switch(*puVar1) {

  case 0x4a:

    break;

  case 0x4b:

    break;

  default:

    goto switchD_0068c596_caseD_4c;

  case 0x4d:

    break;

  case 0x56:

  }

  FUN_0068c4c0(&param_1,&stack0x00000008);

switchD_0068c596_caseD_4c:

  puVar3 = (undefined4 *)(param_1 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  return;

}





// --- FUN_0068c620 at 0x0068C620 (size: 82) ---


undefined4 * __thiscall FUN_0068c620(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_00800350;

  FUN_00433a10();

  param_1[1] = &PTR_FUN_008001c0;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0068c680 at 0x0068C680 (size: 238) ---


void __fastcall FUN_0068c680(undefined4 *param_1)



{

  param_1[0x57] = &PTR_FUN_00800350;

  FUN_00433a10();

  param_1[0x58] = &PTR_FUN_008001c0;

  if ((undefined4 *)param_1[0x70] != param_1 + 0x59) {

    operator_delete__((undefined4 *)param_1[0x70]);

  }

  param_1[0x70] = 0;

  param_1[0x71] = 0;

  param_1[0x72] = 0;

  param_1[0x73] = 0;

  param_1[0x3a] = &PTR_FUN_00800350;

  FUN_00433a10();

  param_1[0x3b] = &PTR_FUN_008001c0;

  if ((undefined4 *)param_1[0x53] != param_1 + 0x3c) {

    operator_delete__((undefined4 *)param_1[0x53]);

  }

  param_1[0x53] = 0;

  param_1[0x54] = 0;

  param_1[0x55] = 0;

  param_1[0x56] = 0;

  param_1[0x1d] = &PTR_FUN_00800350;

  FUN_00433a10();

  param_1[0x1e] = &PTR_FUN_008001c0;

  if ((undefined4 *)param_1[0x36] != param_1 + 0x1f) {

    operator_delete__((undefined4 *)param_1[0x36]);

  }

  param_1[0x36] = 0;

  param_1[0x37] = 0;

  param_1[0x38] = 0;

  param_1[0x39] = 0;

  *param_1 = &PTR_FUN_00800350;

  FUN_00433a10();

  param_1[1] = &PTR_FUN_008001c0;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  return;

}





// --- FUN_0068c770 at 0x0068C770 (size: 3637) ---


void FUN_0068c770(void)



{

  FUN_0068c560("DIK_ESCAPE",1);

  FUN_0068c560("DIK_1",2);

  FUN_0068c560("DIK_2",3);

  FUN_0068c560("DIK_3",4);

  FUN_0068c560("DIK_4",5);

  FUN_0068c560("DIK_5",6);

  FUN_0068c560("DIK_6",7);

  FUN_0068c560("DIK_7",8);

  FUN_0068c560("DIK_8",9);

  FUN_0068c560("DIK_9",10);

  FUN_0068c560("DIK_0",0xb);

  FUN_0068c560("DIK_MINUS",0xc);

  FUN_0068c560("DIK_EQUALS",0xd);

  FUN_0068c560("DIK_BACK",0xe);

  FUN_0068c560("DIK_TAB",0xf);

  FUN_0068c560("DIK_Q",0x10);

  FUN_0068c560("DIK_W",0x11);

  FUN_0068c560("DIK_E",0x12);

  FUN_0068c560("DIK_R",0x13);

  FUN_0068c560("DIK_T",0x14);

  FUN_0068c560("DIK_Y",0x15);

  FUN_0068c560("DIK_U",0x16);

  FUN_0068c560("DIK_I",0x17);

  FUN_0068c560("DIK_O",0x18);

  FUN_0068c560("DIK_P",0x19);

  FUN_0068c560("DIK_LBRACKET",0x1a);

  FUN_0068c560("DIK_RBRACKET",0x1b);

  FUN_0068c560("DIK_RETURN",0x1c);

  FUN_0068c560("DIK_LCONTROL",0x1d);

  FUN_0068c560("DIK_A",0x1e);

  FUN_0068c560("DIK_S",0x1f);

  FUN_0068c560("DIK_D",0x20);

  FUN_0068c560("DIK_F",0x21);

  FUN_0068c560("DIK_G",0x22);

  FUN_0068c560("DIK_H",0x23);

  FUN_0068c560("DIK_J",0x24);

  FUN_0068c560("DIK_K",0x25);

  FUN_0068c560("DIK_L",0x26);

  FUN_0068c560("DIK_SEMICOLON",0x27);

  FUN_0068c560("DIK_APOSTROPHE",0x28);

  FUN_0068c560("DIK_GRAVE",0x29);

  FUN_0068c560("DIK_LSHIFT",0x2a);

  FUN_0068c560("DIK_BACKSLASH",0x2b);

  FUN_0068c560("DIK_Z",0x2c);

  FUN_0068c560("DIK_X",0x2d);

  FUN_0068c560("DIK_C",0x2e);

  FUN_0068c560("DIK_V",0x2f);

  FUN_0068c560("DIK_B",0x30);

  FUN_0068c560("DIK_N",0x31);

  FUN_0068c560("DIK_M",0x32);

  FUN_0068c560("DIK_COMMA",0x33);

  FUN_0068c560("DIK_PERIOD",0x34);

  FUN_0068c560("DIK_SLASH",0x35);

  FUN_0068c560("DIK_RSHIFT",0x36);

  FUN_0068c560("DIK_MULTIPLY",0x37);

  FUN_0068c560("DIK_LMENU",0x38);

  FUN_0068c560("DIK_SPACE",0x39);

  FUN_0068c560("DIK_CAPITAL",0x3a);

  FUN_0068c560("DIK_F1",0x3b);

  FUN_0068c560("DIK_F2",0x3c);

  FUN_0068c560("DIK_F3",0x3d);

  FUN_0068c560("DIK_F4",0x3e);

  FUN_0068c560("DIK_F5",0x3f);

  FUN_0068c560("DIK_F6",0x40);

  FUN_0068c560("DIK_F7",0x41);

  FUN_0068c560("DIK_F8",0x42);

  FUN_0068c560("DIK_F9",0x43);

  FUN_0068c560("DIK_F10",0x44);

  FUN_0068c560("DIK_F11",0x57);

  FUN_0068c560("DIK_F12",0x58);

  FUN_0068c560("DIK_F13",100);

  FUN_0068c560("DIK_F14",0x65);

  FUN_0068c560("DIK_F15",0x66);

  FUN_0068c560("DIK_NUMLOCK",0x45);

  FUN_0068c560("DIK_SCROLL",0x46);

  FUN_0068c560("DIK_NUMPAD7",0x47);

  FUN_0068c560("DIK_NUMPAD8",0x48);

  FUN_0068c560("DIK_NUMPAD9",0x49);

  FUN_0068c560("DIK_SUBTRACT",0x4a);

  FUN_0068c560("DIK_NUMPAD4",0x4b);

  FUN_0068c560("DIK_NUMPAD5",0x4c);

  FUN_0068c560("DIK_NUMPAD6",0x4d);

  FUN_0068c560("DIK_ADD",0x4e);

  FUN_0068c560("DIK_NUMPAD1",0x4f);

  FUN_0068c560("DIK_NUMPAD2",0x50);

  FUN_0068c560("DIK_NUMPAD3",0x51);

  FUN_0068c560("DIK_NUMPAD0",0x52);

  FUN_0068c560("DIK_DECIMAL",0x53);

  FUN_0068c560("DIK_NUMPADENTER",0x9c);

  FUN_0068c560("DIK_RCONTROL",0x9d);

  FUN_0068c560("DIK_NUMPADCOMMA",0xb3);

  FUN_0068c560("DIK_DIVIDE",0xb5);

  FUN_0068c560("DIK_SYSRQ",0xb7);

  FUN_0068c560("DIK_RMENU",0xb8);

  FUN_0068c560("DIK_PAUSE",0xc5);

  FUN_0068c560("DIK_HOME",199);

  FUN_0068c560("DIK_UP",200);

  FUN_0068c560("DIK_PRIOR",0xc9);

  FUN_0068c560("DIK_LEFT",0xcb);

  FUN_0068c560("DIK_RIGHT",0xcd);

  FUN_0068c560("DIK_END",0xcf);

  FUN_0068c560("DIK_DOWN",0xd0);

  FUN_0068c560("DIK_NEXT",0xd1);

  FUN_0068c560("DIK_INSERT",0xd2);

  FUN_0068c560("DIK_DELETE",0xd3);

  FUN_0068c560("DIK_LWIN",0xdb);

  FUN_0068c560("DIK_RWIN",0xdc);

  FUN_0068c560("DIK_APPS",0xdd);

  FUN_0068c560("DIK_MUTE",0xa0);

  FUN_0068c560("DIK_CALCULATOR",0xa1);

  FUN_0068c560("DIK_PLAYPAUSE",0xa2);

  FUN_0068c560("DIK_MEDIASTOP",0xa4);

  FUN_0068c560("DIK_VOLUMEDOWN",0xae);

  FUN_0068c560("DIK_VOLUMEUP",0xb0);

  FUN_0068c560("DIK_WEBHOME",0xb2);

  FUN_0068c560("DIK_WEBSEARCH",0xe5);

  FUN_0068c560("DIK_WEBFAVORITES",0xe6);

  FUN_0068c560("DIK_WEBREFRESH",0xe7);

  FUN_0068c560("DIK_WEBSTOP",0xe8);

  FUN_0068c560("DIK_WEBFORWARD",0xe9);

  FUN_0068c560("DIK_WEBBACK",0xea);

  FUN_0068c560("DIK_MYCOMPUTER",0xeb);

  FUN_0068c560("DIK_MAIL",0xec);

  FUN_0068c560("DIK_MEDIASELECT",0xed);

  FUN_0068c560("DIK_OEM_102",0x56);

  FUN_0068c560("DIK_ABNT_C1",0x73);

  FUN_0068c560("DIK_YEN",0x7d);

  FUN_0068c560("DIK_ABNT_C2",0x7e);

  FUN_0068c560("DIK_NUMPADEQUALS",0x8d);

  FUN_0068c560("DIK_PREVTRACK",0x90);

  FUN_0068c560("DIK_AT",0x91);

  FUN_0068c560("DIK_COLON",0x92);

  FUN_0068c560("DIK_UNDERLINE",0x93);

  FUN_0068c560("DIK_STOP",0x95);

  FUN_0068c560("DIK_AX",0x96);

  FUN_0068c560("DIK_UNLABELED",0x97);

  FUN_0068c560("DIK_NEXTTRACK",0x99);

  FUN_0068c560("DIK_BACKSPACE",0xe);

  FUN_0068c560("DIK_NUMPADSTAR",0x37);

  FUN_0068c560("DIK_LALT",0x38);

  FUN_0068c560("DIK_CAPSLOCK",0x3a);

  FUN_0068c560("DIK_NUMPADMINUS",0x4a);

  FUN_0068c560("DIK_NUMPADPLUS",0x4e);

  FUN_0068c560("DIK_NUMPADPERIOD",0x53);

  FUN_0068c560("DIK_NUMPADSLASH",0xb5);

  FUN_0068c560("DIK_RALT",0xb8);

  FUN_0068c560("DIK_UPARROW",200);

  FUN_0068c560("DIK_PGUP",0xc9);

  FUN_0068c560("DIK_LEFTARROW",0xcb);

  FUN_0068c560("DIK_RIGHTARROW",0xcd);

  FUN_0068c560("DIK_DOWNARROW",0xd0);

  FUN_0068c560("DIK_PGDN",0xd1);

  FUN_0068c560("DIK_CIRCUMFLEX",0x90);

  FUN_0068c560("DIMOFS_WHEEL",8);

  FUN_0068c560("DIMOFS_X",0);

  FUN_0068c560("DIMOFS_Y",4);

  FUN_0068c560("DIMOFS_Z",8);

  FUN_0068c560("DIMOFS_BUTTON0",0xc);

  FUN_0068c560("DIMOFS_BUTTON1",0xd);

  FUN_0068c560("DIMOFS_BUTTON2",0xe);

  FUN_0068c560("DIMOFS_BUTTON3",0xf);

  FUN_0068c560("DIMOFS_BUTTON4",0x10);

  FUN_0068c560("DIMOFS_BUTTON5",0x11);

  FUN_0068c560("DIMOFS_BUTTON6",0x12);

  FUN_0068c560("DIMOFS_BUTTON7",0x13);

  FUN_0068c560("DIJOFS_X",0);

  FUN_0068c560("DIJOFS_Y",4);

  FUN_0068c560("DIJOFS_Z",8);

  FUN_0068c560("DIJOFS_RX",0xc);

  FUN_0068c560("DIJOFS_RY",0x10);

  FUN_0068c560("DIJOFS_RZ",0x14);

  FUN_0068c560("DIJOFS_SLIDER0",0x18);

  FUN_0068c560("DIJOFS_SLIDER1",0x1c);

  FUN_0068c560("DIJOFS_SLIDER(0)",0x18);

  FUN_0068c560("DIJOFS_SLIDER(1)",0x1c);

  FUN_0068c560("DIJOFS_POV0",0x20);

  FUN_0068c560("DIJOFS_POV1",0x24);

  FUN_0068c560("DIJOFS_POV2",0x28);

  FUN_0068c560("DIJOFS_POV3",0x2c);

  FUN_0068c560("DIJOFS_POV(0)",0x20);

  FUN_0068c560("DIJOFS_POV(1)",0x24);

  FUN_0068c560("DIJOFS_POV(2)",0x28);

  FUN_0068c560("DIJOFS_POV(3)",0x2c);

  FUN_0068c560("DIJOFS_BUTTON0",0x30);

  FUN_0068c560("DIJOFS_BUTTON1",0x31);

  FUN_0068c560("DIJOFS_BUTTON2",0x32);

  FUN_0068c560("DIJOFS_BUTTON3",0x33);

  FUN_0068c560("DIJOFS_BUTTON4",0x34);

  FUN_0068c560("DIJOFS_BUTTON5",0x35);

  FUN_0068c560("DIJOFS_BUTTON6",0x36);

  FUN_0068c560("DIJOFS_BUTTON7",0x37);

  FUN_0068c560("DIJOFS_BUTTON8",0x38);

  FUN_0068c560("DIJOFS_BUTTON9",0x39);

  FUN_0068c560("DIJOFS_BUTTON10",0x3a);

  FUN_0068c560("DIJOFS_BUTTON11",0x3b);

  FUN_0068c560("DIJOFS_BUTTON12",0x3c);

  FUN_0068c560("DIJOFS_BUTTON13",0x3d);

  FUN_0068c560("DIJOFS_BUTTON14",0x3e);

  FUN_0068c560("DIJOFS_BUTTON15",0x3f);

  FUN_0068c560("DIJOFS_BUTTON16",0x40);

  FUN_0068c560("DIJOFS_BUTTON17",0x41);

  FUN_0068c560("DIJOFS_BUTTON18",0x42);

  FUN_0068c560("DIJOFS_BUTTON19",0x43);

  FUN_0068c560("DIJOFS_BUTTON20",0x44);

  FUN_0068c560("DIJOFS_BUTTON21",0x45);

  FUN_0068c560("DIJOFS_BUTTON22",0x46);

  FUN_0068c560("DIJOFS_BUTTON23",0x47);

  FUN_0068c560("DIJOFS_BUTTON24",0x48);

  FUN_0068c560("DIJOFS_BUTTON25",0x49);

  FUN_0068c560("DIJOFS_BUTTON26",0x4a);

  FUN_0068c560("DIJOFS_BUTTON27",0x4b);

  FUN_0068c560("DIJOFS_BUTTON28",0x4c);

  FUN_0068c560("DIJOFS_BUTTON29",0x4d);

  FUN_0068c560("DIJOFS_BUTTON30",0x4e);

  FUN_0068c560("DIJOFS_BUTTON31",0x4f);

  FUN_0068c560("DIJOFS_BUTTON(0)",0x30);

  FUN_0068c560("DIJOFS_BUTTON(1)",0x31);

  FUN_0068c560("DIJOFS_BUTTON(2)",0x32);

  FUN_0068c560("DIJOFS_BUTTON(3)",0x33);

  FUN_0068c560("DIJOFS_BUTTON(4)",0x34);

  FUN_0068c560("DIJOFS_BUTTON(5)",0x35);

  FUN_0068c560("DIJOFS_BUTTON(6)",0x36);

  FUN_0068c560("DIJOFS_BUTTON(7)",0x37);

  FUN_0068c560("DIJOFS_BUTTON(8)",0x38);

  FUN_0068c560("DIJOFS_BUTTON(9)",0x39);

  FUN_0068c560("DIJOFS_BUTTON(10)",0x3a);

  FUN_0068c560("DIJOFS_BUTTON(11)",0x3b);

  FUN_0068c560("DIJOFS_BUTTON(12)",0x3c);

  FUN_0068c560("DIJOFS_BUTTON(13)",0x3d);

  FUN_0068c560("DIJOFS_BUTTON(14)",0x3e);

  FUN_0068c560("DIJOFS_BUTTON(15)",0x3f);

  FUN_0068c560("DIJOFS_BUTTON(16)",0x40);

  FUN_0068c560("DIJOFS_BUTTON(17)",0x41);

  FUN_0068c560("DIJOFS_BUTTON(18)",0x42);

  FUN_0068c560("DIJOFS_BUTTON(19)",0x43);

  FUN_0068c560("DIJOFS_BUTTON(20)",0x44);

  FUN_0068c560("DIJOFS_BUTTON(21)",0x45);

  FUN_0068c560("DIJOFS_BUTTON(22)",0x46);

  FUN_0068c560("DIJOFS_BUTTON(23)",0x47);

  FUN_0068c560("DIJOFS_BUTTON(24)",0x48);

  FUN_0068c560("DIJOFS_BUTTON(25)",0x49);

  FUN_0068c560("DIJOFS_BUTTON(26)",0x4a);

  FUN_0068c560("DIJOFS_BUTTON(27)",0x4b);

  FUN_0068c560("DIJOFS_BUTTON(28)",0x4c);

  FUN_0068c560("DIJOFS_BUTTON(29)",0x4d);

  FUN_0068c560("DIJOFS_BUTTON(30)",0x4e);

  FUN_0068c560("DIJOFS_BUTTON(31)",0x4f);

  FUN_0068c560("DIV_MOUSELOOK",1);

  return;

}





// --- FUN_0068d5b0 at 0x0068D5B0 (size: 93) ---


undefined4 * __fastcall FUN_0068d5b0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_00800350;

  FUN_0068bdd0(0x17);

  param_1[0x1d] = &PTR_FUN_00800350;

  FUN_0068bdd0(0x17);

  param_1[0x3a] = &PTR_FUN_00800350;

  FUN_0068bdd0(0x17);

  param_1[0x57] = &PTR_FUN_00800350;

  FUN_0068bdd0(0x17);

  FUN_0068c770();

  return param_1;

}





// --- FUN_0068d610 at 0x0068D610 (size: 89) ---


void __thiscall

FUN_0068d610(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            )



{

  undefined4 *puVar1;

  

  if (*(undefined4 **)(param_1 + 8) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 8))(1);

  }

  *(undefined4 *)(param_1 + 8) = 0;

  puVar1 = (undefined4 *)FUN_005df0f5(0x14);

  if (puVar1 != (undefined4 *)0x0) {

    puVar1[1] = param_2;

    puVar1[2] = param_3;

    puVar1[3] = param_4;

    *puVar1 = &PTR_FUN_007fe998;

    puVar1[4] = param_5;

    *(undefined4 **)(param_1 + 8) = puVar1;

    return;

  }

  *(undefined4 *)(param_1 + 8) = 0;

  return;

}





// --- FUN_0068d670 at 0x0068D670 (size: 61) ---


int __thiscall

FUN_0068d670(int *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5)



{

  int iVar1;

  

  iVar1 = (**(code **)(*param_1 + 4))();

  if (iVar1 == 0) {

    return 0;

  }

  FUN_0068d610(param_2,param_3,param_4,param_5);

  return iVar1;

}





// --- FUN_0068d6b0 at 0x0068D6B0 (size: 89) ---


void FUN_0068d6b0(undefined4 *param_1,int param_2)



{

  undefined4 *puVar1;

  

  FUN_0040ad10(0x10);

  puVar1 = (undefined4 *)FUN_0040acf0(0x10);

  if (puVar1 != (undefined4 *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) != 0) {

      *puVar1 = *param_1;

      puVar1[1] = param_1[1];

      puVar1[2] = param_1[2];

      puVar1[3] = param_1[3];

      return;

    }

    *param_1 = *puVar1;

    param_1[1] = puVar1[1];

    param_1[2] = puVar1[2];

    param_1[3] = puVar1[3];

  }

  return;

}





// --- FUN_0068d710 at 0x0068D710 (size: 32) ---


uint FUN_0068d710(uint param_1)



{

  uint uVar1;

  uint uVar2;

  

  uVar1 = 0;

  uVar2 = 0x80000000;

  for (; param_1 != 0; param_1 = param_1 >> 1) {

    if ((param_1 & 1) != 0) {

      uVar1 = uVar1 | uVar2;

    }

    uVar2 = uVar2 >> 1;

  }

  return uVar1;

}





// --- FUN_0068d730 at 0x0068D730 (size: 108) ---


void __fastcall FUN_0068d730(int *param_1)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  undefined4 local_14 [5];

  

  param_1[2] = 0;

  if ((param_1[1] & 0x80000000U) != 0x80000000) {

    if (*param_1 != 0) {

      uVar1 = param_1[1] & 0x7fffffff;

      if (-1 < (int)(uVar1 - 1)) {

        iVar2 = (uVar1 - 1) * 0x14;

        do {

          puVar5 = (undefined4 *)(*param_1 + iVar2);

          iVar2 = iVar2 + -0x14;

          uVar1 = uVar1 - 1;

          puVar4 = local_14;

          for (iVar3 = 5; iVar3 != 0; iVar3 = iVar3 + -1) {

            *puVar5 = *puVar4;

            puVar4 = puVar4 + 1;

            puVar5 = puVar5 + 1;

          }

        } while (uVar1 != 0);

      }

    }

    return;

  }

  operator_delete__((void *)*param_1);

  *param_1 = 0;

  param_1[1] = 0;

  return;

}





// --- FUN_0068d7a0 at 0x0068D7A0 (size: 83) ---


int __thiscall FUN_0068d7a0(int *param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *puVar2;

  

  iVar1 = (**(code **)(*param_1 + 4))();

  if (iVar1 == 0) {

    return 0;

  }

  if (*(undefined4 **)(iVar1 + 8) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(iVar1 + 8))(1);

  }

  *(undefined4 *)(iVar1 + 8) = 0;

  puVar2 = (undefined4 *)FUN_005df0f5(8);

  if (puVar2 != (undefined4 *)0x0) {

    puVar2[1] = param_2;

    *puVar2 = &PTR_FUN_007980ec;

    *(undefined4 **)(iVar1 + 8) = puVar2;

    return iVar1;

  }

  *(undefined4 *)(iVar1 + 8) = 0;

  return iVar1;

}





// --- FUN_0068d800 at 0x0068D800 (size: 64) ---


undefined4 * __thiscall FUN_0068d800(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_00801108;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0068d840 at 0x0068D840 (size: 64) ---


undefined4 * __thiscall FUN_0068d840(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_0080110c;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0068d880 at 0x0068D880 (size: 64) ---


undefined4 * __thiscall FUN_0068d880(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_00801110;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0068d8c0 at 0x0068D8C0 (size: 69) ---


uint __thiscall FUN_0068d8c0(int *param_1,int param_2)



{

  uint uVar1;

  int *piVar2;

  

  uVar1 = 0;

  if (param_1[2] != 0) {

    piVar2 = (int *)(*param_1 + 0xc);

    do {

      if ((((piVar2[-2] == *(int *)(param_2 + 4)) && (piVar2[-1] == *(int *)(param_2 + 8))) &&

          (*piVar2 == *(int *)(param_2 + 0xc))) && (piVar2[1] == *(int *)(param_2 + 0x10))) {

        return uVar1;

      }

      uVar1 = uVar1 + 1;

      piVar2 = piVar2 + 5;

    } while (uVar1 < (uint)param_1[2]);

  }

  return 0xffffffff;

}





// --- FUN_0068d910 at 0x0068D910 (size: 176) ---


undefined4 __thiscall FUN_0068d910(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  

  if (param_2 < (uint)param_1[2]) {

    return 0;

  }

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    if (param_2 == 0) {

      FUN_0068d730();

      return 1;

    }

    iVar1 = thunk_FUN_005df0f5(param_2 * 0x14);

    if (iVar1 == 0) {

      return 0;

    }

    if (*param_1 != 0) {

      iVar4 = param_1[2];

      if (-1 < iVar4 + -1) {

        iVar2 = (iVar4 + -1) * 0x14;

        do {

          puVar5 = (undefined4 *)(*param_1 + iVar2);

          puVar6 = (undefined4 *)(iVar2 + iVar1);

          iVar2 = iVar2 + -0x14;

          iVar4 = iVar4 + -1;

          for (iVar3 = 5; iVar3 != 0; iVar3 = iVar3 + -1) {

            *puVar6 = *puVar5;

            puVar5 = puVar5 + 1;

            puVar6 = puVar6 + 1;

          }

        } while (iVar4 != 0);

      }

      if ((param_1[1] & 0x80000000U) == 0x80000000) {

        operator_delete__((void *)*param_1);

      }

    }

    *param_1 = iVar1;

    param_1[1] = param_2 | 0x80000000;

  }

  return 1;

}





// --- FUN_0068d9c0 at 0x0068D9C0 (size: 121) ---


undefined1 __thiscall FUN_0068d9c0(int *param_1,uint param_2,char param_3)



{

  char cVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  undefined4 local_14 [5];

  

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    uVar2 = param_2;

    if (param_3 == '\0') {

      uVar2 = FUN_00453850(param_2);

    }

    cVar1 = FUN_0068d910(uVar2);

    if (cVar1 == '\0') {

      return 0;

    }

  }

  else if (param_2 < (uint)param_1[2]) {

    iVar3 = param_2 * 0x14;

    uVar2 = param_2;

    do {

      puVar5 = local_14;

      puVar6 = (undefined4 *)(*param_1 + iVar3);

      for (iVar4 = 5; iVar4 != 0; iVar4 = iVar4 + -1) {

        *puVar6 = *puVar5;

        puVar5 = puVar5 + 1;

        puVar6 = puVar6 + 1;

      }

      uVar2 = uVar2 + 1;

      iVar3 = iVar3 + 0x14;

    } while (uVar2 < (uint)param_1[2]);

  }

  param_1[2] = param_2;

  return 1;

}





// --- FUN_0068da40 at 0x0068DA40 (size: 223) ---


undefined1 __thiscall FUN_0068da40(int *param_1,undefined4 *param_2)



{

  char cVar1;

  int iVar2;

  int *piVar3;

  LONG LVar4;

  undefined1 uVar5;

  int unaff_ESI;

  int *piStack_4;

  

  uVar5 = 0;

  if ((int *)param_1[2] != (int *)0x0) {

    piStack_4 = param_1;

    iVar2 = (**(code **)(*(int *)param_1[2] + 4))();

    if (iVar2 == 0xe) {

      iVar2 = param_1[2];

      *param_2 = *(undefined4 *)(iVar2 + 4);

      param_2[1] = *(undefined4 *)(iVar2 + 8);

      param_2[2] = *(undefined4 *)(iVar2 + 0xc);

      param_2[3] = *(undefined4 *)(iVar2 + 0x10);

      return 1;

    }

    (**(code **)(*(int *)param_1[2] + 0x14))(&piStack_4);

    piVar3 = (int *)FUN_005df0f5(0x14);

    if (piVar3 == (int *)0x0) {

      piVar3 = (int *)0x0;

    }

    else {

      *piVar3 = (int)&PTR_FUN_007fe998;

    }

    cVar1 = (**(code **)(*piVar3 + 0x10))(&stack0xfffffff8);

    if (cVar1 == '\0') {

      (**(code **)*piVar3)(1);

      uVar5 = 0;

    }

    else {

      *piStack_4 = piVar3[1];

      piStack_4[1] = piVar3[2];

      piStack_4[2] = piVar3[3];

      piStack_4[3] = piVar3[4];

      if ((undefined4 *)param_1[2] != (undefined4 *)0x0) {

        (*(code *)**(undefined4 **)param_1[2])(1);

      }

      param_1[2] = (int)piVar3;

      uVar5 = 1;

    }

    LVar4 = InterlockedDecrement((LONG *)(unaff_ESI + -0x10));

    if ((LVar4 == 0) && ((undefined4 *)(unaff_ESI + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(unaff_ESI + -0x14))(1);

    }

  }

  return uVar5;

}





// --- FUN_0068db20 at 0x0068DB20 (size: 70) ---


void __thiscall FUN_0068db20(int param_1,int *param_2,uint *param_3)



{

  int iVar1;

  int iVar2;

  char cVar3;

  uint uVar4;

  

  uVar4 = *param_3 % *(uint *)(param_1 + 0x68);

  iVar1 = *(int *)(param_1 + 0x60);

  iVar2 = *(int *)(iVar1 + uVar4 * 4);

  while ((iVar2 != 0 && (cVar3 = FUN_0068b260(param_3), cVar3 == '\0'))) {

    iVar2 = *(int *)(iVar2 + 0xc);

  }

  *param_2 = param_1;

  param_2[2] = iVar2;

  param_2[1] = iVar1 + uVar4 * 4;

  return;

}





// --- FUN_0068db70 at 0x0068DB70 (size: 82) ---


undefined4 __thiscall FUN_0068db70(int *param_1,undefined4 *param_2)



{

  undefined4 uVar1;

  int iVar2;

  undefined4 *puVar3;

  

  if ((param_1[1] & 0x7fffffffU) <= (uint)param_1[2]) {

    uVar1 = FUN_00453850((param_1[1] & 0x7fffffffU) + 1);

    uVar1 = FUN_0068d910(uVar1);

    if ((char)uVar1 == '\0') {

      return uVar1;

    }

  }

  puVar3 = (undefined4 *)(*param_1 + param_1[2] * 0x14);

  for (iVar2 = 5; iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar3 = *param_2;

    param_2 = param_2 + 1;

    puVar3 = puVar3 + 1;

  }

  iVar2 = param_1[2];

  param_1[2] = iVar2 + 1;

  return CONCAT31((int3)((uint)(iVar2 + 1) >> 8),1);

}





// --- FUN_0068dbd0 at 0x0068DBD0 (size: 154) ---


undefined1 FUN_0068dbd0(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  LONG *lpAddend;

  undefined *puVar1;

  char cVar2;

  LONG LVar3;

  undefined1 uVar4;

  undefined4 *puVar5;

  undefined *puVar6;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818344;

  uVar4 = 0;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  cVar2 = FUN_0041b060(param_2,param_3,&local_4);

  puVar1 = local_4;

  if (cVar2 != '\0') {

    lpAddend = (LONG *)(local_4 + -0x10);

    InterlockedIncrement(lpAddend);

    puVar6 = puVar1;

    InterlockedIncrement(lpAddend);

    FUN_00427050(puVar6);

    LVar3 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

    if ((LVar3 == 0) && ((undefined4 *)(puVar1 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(puVar1 + -0x14))(1);

    }

    uVar4 = 1;

  }

  puVar5 = (undefined4 *)(local_4 + -0x14);

  LVar3 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar3 == 0) && (puVar5 != (undefined4 *)0x0)) {

    (**(code **)*puVar5)(1);

  }

  return uVar4;

}





// --- FUN_0068dc70 at 0x0068DC70 (size: 60) ---


int FUN_0068dc70(int *param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  int iVar2;

  

  iVar2 = (**(code **)(*param_1 + 4))();

  if (iVar2 != 0) {

    cVar1 = FUN_0068dbd0(iVar2,param_2,param_3);

    if (cVar1 == '\0') {

      FUN_0065d360(iVar2);

      return 0;

    }

  }

  return iVar2;

}





// --- FUN_0068dcb0 at 0x0068DCB0 (size: 245) ---


undefined1 __thiscall

FUN_0068dcb0(int param_1,undefined *param_2,undefined4 param_3,undefined4 param_4)



{

  int *piVar1;

  uint uVar2;

  undefined1 uVar3;

  undefined4 uVar5;

  undefined *puVar6;

  int iVar7;

  undefined1 uVar4;

  

  uVar4 = 1;

  uVar3 = 1;

  piVar1 = (int *)FUN_00415730(1,8,0x27);

  uVar5 = param_3;

  if (piVar1 != (int *)0x0) {

    uVar2 = FUN_006863a0(param_3,*(undefined4 *)(param_1 + 4));

    puVar6 = param_2;

    uVar3 = uVar4;

    if (((3 < uVar2) && (uVar2 < 6)) && ((param_2[8] & 0xa9) == 0)) {

      param_2 = PTR_DAT_00818344;

      InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

      FUN_00401340("momentary, etc.");

      FUN_00401340("tap, dblclick, etc");

      FUN_0041b060(0x19,uVar5,&param_2);

      FUN_0068b940(*(undefined4 *)(puVar6 + 8),&param_3);

      uVar5 = param_3;

      puVar6 = param_2;

      iVar7 = param_1;

      FUN_00401340(

                  "Cannot use that activation type (%s) with \'%s\' because of its toggle type (%s)"

                  );

      FUN_0065d620(param_4,param_1,uVar5,puVar6,iVar7);

      uVar3 = 0;

      FUN_004011b0();

      FUN_004011b0();

      FUN_004011b0();

    }

    (**(code **)(*piVar1 + 0x14))();

  }

  return uVar3;

}





// --- FUN_0068ddb0 at 0x0068DDB0 (size: 541) ---


undefined4 FUN_0068ddb0(int param_1,undefined4 *param_2)



{

  char cVar1;

  int iVar2;

  LONG LVar3;

  undefined4 extraout_ECX;

  char *pcVar4;

  undefined4 uVar5;

  char *_Str1;

  char *local_8;

  char *local_4;

  

  if (param_1 == 0) {

    return 0;

  }

  local_8 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  FUN_00426020(&local_8);

  FUN_00401340("GUID_SysMouse");

  _Str1 = local_8;

  iVar2 = _stricmp(local_8,local_4);

  pcVar4 = local_4 + -0x14;

  LVar3 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

    (*(code *)**(undefined4 **)pcVar4)(1);

  }

  if (iVar2 != 0) {

    FUN_00401340("GUID_SysKeyboard");

    iVar2 = _stricmp(_Str1,local_4);

    pcVar4 = local_4 + -0x14;

    LVar3 = InterlockedDecrement((LONG *)(local_4 + -0x10));

    if ((LVar3 == 0) && (pcVar4 != (char *)0x0)) {

      (*(code *)**(undefined4 **)pcVar4)(1);

    }

    if (iVar2 != 0) {

      FUN_00401340("GUID_Virtual");

      iVar2 = _stricmp(_Str1,local_4);

      LVar3 = InterlockedDecrement((LONG *)(local_4 + -0x10));

      if ((LVar3 == 0) && (local_4 + -0x14 != (char *)0x0)) {

        (*(code *)**(undefined4 **)(local_4 + -0x14))(1);

      }

      if (iVar2 == 0) {

        *param_2 = DAT_008010e8;

        param_2[1] = DAT_008010ec;

        param_2[2] = DAT_008010f0;

        param_2[3] = DAT_008010f4;

      }

      else {

        cVar1 = FUN_0068da40(param_2);

        if (cVar1 == '\0') {

          uVar5 = extraout_ECX;

          FUN_00401340("ERROR - invalid GUID \"%s\"\n");

          FUN_0065d620(param_1,uVar5,_Str1);

          FUN_004011b0();

          return 0;

        }

      }

      FUN_004011b0();

      return 1;

    }

    *param_2 = DAT_007fe800;

    param_2[1] = DAT_007fe804;

    param_2[2] = DAT_007fe808;

    param_2[3] = DAT_007fe80c;

    LVar3 = InterlockedDecrement((LONG *)(_Str1 + -0x10));

    if ((LVar3 == 0) && (_Str1 + -0x14 != (char *)0x0)) {

      (*(code *)**(undefined4 **)(_Str1 + -0x14))(1);

    }

    return 1;

  }

  *param_2 = DAT_007fe810;

  param_2[1] = DAT_007fe814;

  param_2[2] = DAT_007fe818;

  param_2[3] = DAT_007fe81c;

  LVar3 = InterlockedDecrement((LONG *)(_Str1 + -0x10));

  if ((LVar3 == 0) && (_Str1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(_Str1 + -0x14))(1);

  }

  return 1;

}





// --- FUN_0068dfd0 at 0x0068DFD0 (size: 202) ---


bool FUN_0068dfd0(int *param_1)



{

  int iVar1;

  int *piVar2;

  int *piVar3;

  bool bVar4;

  

  iVar1 = 4;

  bVar4 = true;

  piVar2 = &DAT_007fe800;

  piVar3 = param_1;

  do {

    if (iVar1 == 0) break;

    iVar1 = iVar1 + -1;

    bVar4 = *piVar2 == *piVar3;

    piVar2 = piVar2 + 1;

    piVar3 = piVar3 + 1;

  } while (bVar4);

  if (bVar4) {

    FUN_00401340("GUID_SysKeyboard");

    iVar1 = FUN_00426fe0(iVar1);

    return iVar1 != 0;

  }

  iVar1 = 4;

  bVar4 = true;

  piVar2 = &DAT_007fe810;

  piVar3 = param_1;

  do {

    if (iVar1 == 0) break;

    iVar1 = iVar1 + -1;

    bVar4 = *piVar2 == *piVar3;

    piVar2 = piVar2 + 1;

    piVar3 = piVar3 + 1;

  } while (bVar4);

  if (bVar4) {

    FUN_00401340("GUID_SysMouse");

    iVar1 = FUN_00426fe0(iVar1);

    return iVar1 != 0;

  }

  iVar1 = 4;

  bVar4 = true;

  piVar2 = &DAT_008010e8;

  piVar3 = param_1;

  do {

    if (iVar1 == 0) break;

    iVar1 = iVar1 + -1;

    bVar4 = *piVar2 == *piVar3;

    piVar2 = piVar2 + 1;

    piVar3 = piVar3 + 1;

  } while (bVar4);

  if (bVar4) {

    FUN_00401340("GUID_Virtual");

    iVar1 = FUN_00426fe0(iVar1);

    return iVar1 != 0;

  }

  iVar1 = FUN_0068d670(*param_1,param_1[1],param_1[2],param_1[3]);

  return iVar1 != 0;

}





// --- FUN_0068e0a0 at 0x0068E0A0 (size: 44) ---


int __thiscall FUN_0068e0a0(int param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = FUN_0068d8c0(param_2);

  if (iVar1 == -1) {

    iVar1 = *(int *)(param_1 + 0x4c);

    FUN_0068db70(param_2);

  }

  return iVar1;

}





// --- FUN_0068e0d0 at 0x0068E0D0 (size: 288) ---


void __thiscall FUN_0068e0d0(int *param_1,int param_2)



{

  int iVar1;

  uint *puVar2;

  uint uVar3;

  byte *pbVar4;

  uint *puVar5;

  byte bVar6;

  uint uVar7;

  uint local_4;

  

  iVar1 = param_2;

  uVar7 = param_1[2];

  FUN_0040ad10(4);

  puVar2 = (uint *)FUN_0040acf0(4);

  if (puVar2 != (uint *)0x0) {

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      uVar7 = *puVar2;

    }

    else {

      *puVar2 = uVar7;

    }

  }

  if ((~*(byte *)(param_2 + 4) & 1) != 0) {

    uVar3 = FUN_0040a8f0();

    if (uVar3 < uVar7) {

      FUN_0040aa50();

      return;

    }

    param_1[2] = 0;

    FUN_0068d9c0(uVar7,1);

  }

  local_4 = 0;

  if (param_1[2] != 0) {

    param_2 = 0;

    do {

      bVar6 = *(byte *)(*param_1 + param_2);

      puVar2 = (uint *)(*param_1 + param_2);

      FUN_0040ad10(1);

      pbVar4 = (byte *)FUN_0040acf0(1);

      if (pbVar4 != (byte *)0x0) {

        if ((*(byte *)(iVar1 + 4) & 1) == 0) {

          bVar6 = *pbVar4;

        }

        else {

          *pbVar4 = bVar6;

        }

      }

      if ((*(byte *)(iVar1 + 4) & 5) == 0) {

        *puVar2 = (uint)bVar6;

      }

      FUN_0040ad10(0x10);

      puVar5 = (uint *)FUN_0040acf0(0x10);

      if (puVar5 != (uint *)0x0) {

        if ((*(byte *)(iVar1 + 4) & 1) == 0) {

          puVar2[1] = *puVar5;

          puVar2[2] = puVar5[1];

          puVar2[3] = puVar5[2];

          puVar2[4] = puVar5[3];

        }

        else {

          *puVar5 = puVar2[1];

          puVar5[1] = puVar2[2];

          puVar5[2] = puVar2[3];

          puVar5[3] = puVar2[4];

        }

      }

      local_4 = local_4 + 1;

      param_2 = param_2 + 0x14;

    } while (local_4 < (uint)param_1[2]);

  }

  return;

}





// --- FUN_0068e1f0 at 0x0068E1F0 (size: 441) ---


uint __thiscall FUN_0068e1f0(int *param_1,int *param_2)



{

  uint uVar1;

  uint *puVar2;

  char cVar3;

  uint in_EAX;

  uint *puVar4;

  int *piVar5;

  undefined4 uVar6;

  LONG LVar7;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined4 extraout_ECX_01;

  undefined4 *puVar8;

  bool bVar9;

  undefined *puVar10;

  undefined1 local_19;

  undefined *puStack_18;

  int *local_14;

  int *local_10;

  uint local_c;

  uint local_8;

  uint local_4;

  

  if (param_2 == (int *)0x0) {

    return in_EAX & 0xffffff00;

  }

  local_14 = param_1 + 2;

  puVar4 = (uint *)0x0;

  local_19 = 1;

  puVar2 = puVar4;

  local_10 = param_1;

  if (param_1[0x1d] != 0) {

    if (param_1[0x1e] == 0) {

      puVar4 = (uint *)0x0;

      puVar2 = puVar4;

    }

    else {

      puVar4 = (uint *)(param_1[0x1e] + -0x10);

      puVar2 = puVar4;

    }

  }

  while (puVar2 != (uint *)0x0) {

    local_c = *puVar2;

    local_8 = puVar2[1];

    local_4 = puVar2[2];

    uVar1 = puVar2[6];

    piVar5 = (int *)(**(code **)(*param_2 + 4))();

    uVar6 = extraout_ECX;

    if (piVar5 == (int *)0x0) {

LAB_0068e271:

      FUN_00401340("ERROR - failed to write action.\n");

      FUN_0065d620(param_2,uVar6);

      local_19 = 0;

    }

    else {

      cVar3 = FUN_0068dbd0(piVar5,0x19,uVar1);

      if (cVar3 == '\0') {

        FUN_0065d360(piVar5);

        uVar6 = extraout_ECX_00;

        goto LAB_0068e271;

      }

      uVar6 = (**(code **)(*piVar5 + 4))();

      cVar3 = FUN_0068bb80(uVar6,*(undefined4 *)

                                  (*(int *)(*local_10 + 0x44) + (local_c & 0xff) * 0x14));

      if (cVar3 == '\0') {

        uVar6 = extraout_ECX_01;

        FUN_00401340("ERROR - failed to write control spec.\n");

        FUN_0065d620(piVar5,uVar6);

        FUN_0065d360(piVar5);

        local_19 = 0;

      }

      else {

        bVar9 = local_4 != 3;

        if ((local_8 != 0) || (bVar9)) {

          uVar6 = FUN_0068d710(local_8);

          FUN_0068d7a0(uVar6);

          if (bVar9) {

            puStack_18 = PTR_DAT_00818344;

            InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

            cVar3 = FUN_0068b940(local_4,&puStack_18);

            if (cVar3 != '\0') {

              puVar10 = puStack_18;

              InterlockedIncrement((LONG *)(puStack_18 + -0x10));

              FUN_00426f90(puVar10);

            }

            puVar8 = (undefined4 *)(puStack_18 + -0x14);

            LVar7 = InterlockedDecrement((LONG *)(puStack_18 + -0x10));

            if ((LVar7 == 0) && (puVar8 != (undefined4 *)0x0)) {

              (**(code **)*puVar8)(1);

            }

          }

        }

      }

    }

    puVar4 = (uint *)puVar2[4];

    if (puVar4 == (uint *)0x0) break;

    puVar2 = puVar4 + -4;

  }

  return CONCAT31((int3)((uint)puVar4 >> 8),local_19);

}





// --- FUN_0068e3b0 at 0x0068E3B0 (size: 108) ---


undefined4 FUN_0068e3b0(undefined4 param_1,undefined4 *param_2,undefined4 *param_3)



{

  undefined4 *puVar1;

  char cVar2;

  undefined4 *puVar3;

  undefined1 local_c [8];

  undefined4 *local_4;

  

  FUN_0068db20(local_c,param_1);

  if (local_4 == (undefined4 *)0x0) {

    return 0;

  }

  puVar3 = local_4;

  for (puVar1 = (undefined4 *)local_4[3]; puVar1 != (undefined4 *)0x0;

      puVar1 = (undefined4 *)puVar1[3]) {

    cVar2 = FUN_0068b300(puVar3,puVar1);

    if (cVar2 != '\0') {

      puVar3 = puVar1;

    }

  }

  *param_3 = *puVar3;

  param_3[1] = puVar3[1];

  param_3[2] = puVar3[2];

  *param_2 = puVar3[6];

  return 1;

}





// --- FUN_0068e420 at 0x0068E420 (size: 275) ---


bool FUN_0068e420(undefined4 param_1,int *param_2)



{

  undefined4 uVar1;

  undefined4 uVar2;

  undefined4 *puVar3;

  int iVar4;

  char cVar5;

  undefined4 *puVar6;

  uint uVar7;

  uint uVar8;

  undefined1 local_10 [8];

  undefined4 *local_8;

  undefined4 local_4;

  

  FUN_00687dc0(0,1);

  FUN_0068db20(local_10,param_1);

  puVar3 = local_8;

  do {

    if (puVar3 == (undefined4 *)0x0) {

      return param_2[2] != 0;

    }

    cVar5 = FUN_0068b190(puVar3);

    if (cVar5 != '\0') {

      local_4 = puVar3[6];

      local_8 = (undefined4 *)puVar3[2];

      uVar1 = *puVar3;

      uVar2 = puVar3[1];

      if ((param_2[1] & 0x7fffffffU) <= (uint)param_2[2]) {

        uVar7 = (param_2[1] & 0x7fffffffU) + 1;

        if (uVar7 < 9) {

          uVar7 = 8;

        }

        else if (uVar7 < 0x4001) {

          iVar4 = 0x1f;

          if (uVar7 != 0) {

            for (; uVar7 >> iVar4 == 0; iVar4 = iVar4 + -1) {

            }

          }

          uVar8 = 1 << ((byte)iVar4 & 0x1f);

          if (uVar8 < uVar7) {

            uVar7 = uVar8 * 2;

          }

        }

        else if ((uVar7 & 0x3fff) != 0) {

          uVar7 = uVar7 + (0x4000 - (uVar7 & 0x3fff));

        }

        cVar5 = FUN_00687970(uVar7);

        if (cVar5 == '\0') goto LAB_0068e517;

      }

      puVar6 = (undefined4 *)(param_2[2] * 0x10 + *param_2);

      puVar6[2] = local_8;

      *puVar6 = uVar1;

      puVar6[1] = uVar2;

      puVar6[3] = local_4;

      param_2[2] = param_2[2] + 1;

    }

LAB_0068e517:

    puVar3 = (undefined4 *)puVar3[3];

  } while( true );

}





// --- FUN_0068e540 at 0x0068E540 (size: 8) ---


void FUN_0068e540(void)



{

  FUN_0068e3b0();

  return;

}





// --- FUN_0068e550 at 0x0068E550 (size: 8) ---


void FUN_0068e550(void)



{

  FUN_0068e420();

  return;

}





// --- FUN_0068e560 at 0x0068E560 (size: 154) ---


undefined1 __thiscall FUN_0068e560(int param_1,int param_2,int param_3)



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  

  iVar2 = param_3;

  param_3._0_1_ = 0;

  puVar4 = (undefined4 *)0x0;

  if (*(int *)(param_1 + 0x74) != 0) {

    if (*(int *)(param_1 + 0x78) == 0) {

      puVar4 = (undefined4 *)0x0;

    }

    else {

      puVar4 = (undefined4 *)(*(int *)(param_1 + 0x78) + -0x10);

    }

  }

  while( true ) {

    if (puVar4 == (undefined4 *)0x0) {

      return (undefined1)param_3;

    }

    if (puVar4[6] == param_2) {

      puVar3 = (undefined4 *)FUN_005df0f5(0x14);

      if (puVar3 != (undefined4 *)0x0) {

        *puVar3 = *puVar4;

        puVar3[1] = puVar4[1];

        puVar3[2] = puVar4[2];

        puVar3[3] = 0;

        puVar3[4] = 0;

        if (*(int *)(iVar2 + 4) == 0) {

          *(undefined4 **)(iVar2 + 4) = puVar3;

        }

        else {

          iVar1 = *(int *)(iVar2 + 8);

          *(undefined4 **)(iVar1 + 0xc) = puVar3;

          puVar3[4] = iVar1;

        }

        *(undefined4 **)(iVar2 + 8) = puVar3;

        *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;

      }

      param_3._0_1_ = 1;

    }

    if (puVar4[4] == 0) break;

    puVar4 = (undefined4 *)(puVar4[4] + -0x10);

  }

  return (undefined1)param_3;

}





// --- FUN_0068e600 at 0x0068E600 (size: 349) ---


undefined4 __thiscall FUN_0068e600(int param_1,int *param_2)



{

  char cVar1;

  int *piVar2;

  undefined4 uVar3;

  uint uVar4;

  LONG LVar5;

  int iVar6;

  int iVar7;

  undefined4 *puVar8;

  undefined4 *puVar9;

  undefined *puVar10;

  undefined1 *puVar11;

  undefined *puVar12;

  undefined *puStack_20;

  int local_1c;

  int local_18;

  undefined4 uStack_14;

  undefined1 auStack_10 [16];

  

  local_1c = param_1;

  local_18 = FUN_0065ca40();

  iVar7 = 0;

  if (local_18 < 1) {

    return 1;

  }

  do {

    piVar2 = (int *)(**(code **)(*param_2 + 0xc))(iVar7);

    puStack_20 = PTR_DAT_00818344;

    InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

    FUN_00426020(&puStack_20);

    cVar1 = FUN_0068b430(&puStack_20,&uStack_14);

    if (cVar1 == '\0') {

LAB_0068e715:

      puVar10 = puStack_20;

      puVar12 = puStack_20;

      FUN_00401340("ERROR - not a valid device \"%s\"\n");

      FUN_0065d620(piVar2,puVar10,puVar12);

      puVar8 = (undefined4 *)(puStack_20 + -0x14);

      LVar5 = InterlockedDecrement((LONG *)(puStack_20 + -0x10));

      if ((LVar5 == 0) && (puVar8 != (undefined4 *)0x0)) {

        (**(code **)*puVar8)(1);

      }

      return 0;

    }

    puVar11 = auStack_10;

    uVar3 = (**(code **)(*piVar2 + 0xc))(0,puVar11);

    cVar1 = FUN_0068ddb0(uVar3,puVar11);

    if (cVar1 == '\0') goto LAB_0068e715;

    uVar4 = *(uint *)(param_1 + 0x48) & 0x7fffffff;

    if (*(uint *)(param_1 + 0x4c) < uVar4) {

LAB_0068e6ba:

      puVar8 = &uStack_14;

      puVar9 = (undefined4 *)(*(int *)(param_1 + 0x44) + *(int *)(param_1 + 0x4c) * 0x14);

      for (iVar6 = 5; iVar6 != 0; iVar6 = iVar6 + -1) {

        *puVar9 = *puVar8;

        puVar8 = puVar8 + 1;

        puVar9 = puVar9 + 1;

      }

      *(int *)(param_1 + 0x4c) = *(int *)(param_1 + 0x4c) + 1;

    }

    else {

      uVar3 = FUN_00453850(uVar4 + 1);

      cVar1 = FUN_0068d910(uVar3);

      if (cVar1 != '\0') goto LAB_0068e6ba;

    }

    puVar8 = (undefined4 *)(puStack_20 + -0x14);

    LVar5 = InterlockedDecrement((LONG *)(puStack_20 + -0x10));

    if ((LVar5 == 0) && (puVar8 != (undefined4 *)0x0)) {

      (**(code **)*puVar8)(1);

    }

    iVar7 = iVar7 + 1;

    param_1 = local_1c;

    if (local_18 <= iVar7) {

      return 1;

    }

  } while( true );

}





// --- FUN_0068e760 at 0x0068E760 (size: 52) ---


undefined4 __thiscall FUN_0068e760(int param_1,uint param_2)



{

  uint *puVar1;

  bool bVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0xb0) + (param_2 % *(uint *)(param_1 + 0xb8)) * 4);

  bVar2 = puVar1 == (uint *)0x0;

  if (!bVar2) {

    do {

      if (*puVar1 == param_2) break;

      puVar1 = (uint *)puVar1[1];

    } while (puVar1 != (uint *)0x0);

    bVar2 = puVar1 == (uint *)0x0;

  }

  return CONCAT31((int3)((uint)puVar1 >> 8),!bVar2);

}





// --- FUN_0068e7a0 at 0x0068E7A0 (size: 63) ---


uint __thiscall FUN_0068e7a0(int param_1,uint param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0xb0) + (param_2 % *(uint *)(param_1 + 0xb8)) * 4);

  while( true ) {

    if (puVar1 == (uint *)0x0) {

      return 0;

    }

    if (*puVar1 == param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  return puVar1[4];

}





// --- FUN_0068e7e0 at 0x0068E7E0 (size: 97) ---


undefined4 * __thiscall FUN_0068e7e0(int param_1,undefined4 *param_2,int param_3)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)0x0;

  if (*(int *)(param_1 + 0xbc) != 0) {

    if (*(int *)(param_1 + 0xc0) == 0) {

      puVar1 = (undefined4 *)0x0;

    }

    else {

      puVar1 = (undefined4 *)(*(int *)(param_1 + 0xc0) + -8);

    }

  }

  for (; puVar1 != (undefined4 *)0x0; puVar1 = (undefined4 *)(puVar1[2] + -8)) {

    if (param_3 == puVar1[4]) {

      *param_2 = *puVar1;

      return param_2;

    }

    if (puVar1[2] == 0) break;

  }

  *param_2 = 0xffffffff;

  return param_2;

}





// --- FUN_0068e850 at 0x0068E850 (size: 1125) ---


undefined4 __thiscall FUN_0068e850(int param_1,int *param_2)



{

  LONG *pLVar1;

  char cVar2;

  undefined4 uVar3;

  LONG LVar4;

  undefined4 uVar5;

  int *piVar6;

  int iVar7;

  undefined4 *puVar8;

  undefined4 extraout_ECX;

  char *pcVar9;

  char *pcVar10;

  uint *puVar11;

  int iVar12;

  undefined4 uVar13;

  int *piVar14;

  int *piStack_a4;

  int local_a0;

  char *pcStack_9c;

  uint uStack_98;

  int iStack_94;

  

  iVar12 = *(int *)(param_1 + 0x30);

  local_a0 = param_1;

  InterlockedIncrement((LONG *)(iVar12 + -0x10));

  iVar7 = iVar12;

  InterlockedIncrement((LONG *)(iVar12 + -0x10));

  uVar3 = FUN_00426fe0(iVar7);

  LVar4 = InterlockedDecrement((LONG *)(iVar12 + -0x10));

  if ((LVar4 == 0) && ((undefined4 *)(iVar12 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iVar12 + -0x14))(1);

  }

  FUN_0042dc80();

  uVar13 = 3;

  uVar5 = FUN_004016b0("ID_KeymapHelp",3);

  FUN_0042c9c0(uVar5,uVar13);

  FUN_0042e980(&uStack_98,0);

  FUN_00408fd0(&piStack_a4,0);

  FUN_0065d5c0(&piStack_a4);

  piVar6 = piStack_a4 + -5;

  LVar4 = InterlockedDecrement(piStack_a4 + -4);

  if ((LVar4 == 0) && (piVar6 != (int *)0x0)) {

    (**(code **)*piVar6)(1);

  }

  LVar4 = InterlockedDecrement((LONG *)(uStack_98 - 0x10));

  if ((LVar4 == 0) && ((undefined4 *)(uStack_98 - 0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(uStack_98 - 0x14))(1);

  }

  FUN_0068dfd0(local_a0 + 0x34,uVar3);

  uVar3 = extraout_ECX;

  FUN_00401340("Devices");

  FUN_00426fe0(uVar3);

  uStack_98 = 0;

  if (*(int *)(local_a0 + 0x4c) != 0) {

    pcStack_9c = (char *)0x0;

    do {

      piStack_a4 = (int *)PTR_DAT_00818344;

      InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

      cVar2 = FUN_0068b8d0(*(undefined4 *)(pcStack_9c + *(int *)(local_a0 + 0x44)),&piStack_a4);

      piVar6 = piStack_a4;

      if (cVar2 != '\0') {

        pLVar1 = piStack_a4 + -4;

        InterlockedIncrement(pLVar1);

        piVar14 = piVar6;

        InterlockedIncrement(pLVar1);

        uVar3 = FUN_00426fe0(piVar14);

        LVar4 = InterlockedDecrement(piVar6 + -4);

        if ((LVar4 == 0) && (piVar6 + -5 != (int *)0x0)) {

          (**(code **)piVar6[-5])(1);

        }

        FUN_0068dfd0(pcStack_9c + *(int *)(local_a0 + 0x44) + 4,uVar3);

      }

      piVar6 = piStack_a4 + -5;

      LVar4 = InterlockedDecrement(piStack_a4 + -4);

      if ((LVar4 == 0) && (piVar6 != (int *)0x0)) {

        (**(code **)*piVar6)(1);

      }

      uStack_98 = uStack_98 + 1;

      pcStack_9c = pcStack_9c + 0x14;

    } while (uStack_98 < *(uint *)(local_a0 + 0x4c));

  }

  iVar12 = local_a0;

  FUN_00401340("MetaKeys");

  piVar6 = (int *)FUN_00426fe0(iVar12);

  iStack_94 = local_a0 + 0x50;

  puVar11 = (uint *)0x0;

  if (*(int *)(local_a0 + 0xbc) != 0) {

    if (*(int *)(local_a0 + 0xc0) == 0) {

      puVar11 = (uint *)0x0;

    }

    else {

      puVar11 = (uint *)(*(int *)(local_a0 + 0xc0) + -8);

    }

  }

  for (; puVar11 != (uint *)0x0; puVar11 = (uint *)(puVar11[2] - 8)) {

    uStack_98 = puVar11[4];

    iVar12 = 0;

    if (uStack_98 != 0) {

      for (; (uStack_98 >> iVar12 & 1) == 0; iVar12 = iVar12 + 1) {

      }

    }

    iVar12 = 0x20 - iVar12;

    if (iVar12 == 0x21) {

      iVar12 = 0;

    }

    iVar7 = (**(code **)(*piVar6 + 4))();

    if (iVar7 != 0) {

      if (*(undefined4 **)(iVar7 + 8) != (undefined4 *)0x0) {

        (**(code **)**(undefined4 **)(iVar7 + 8))(1);

      }

      *(undefined4 *)(iVar7 + 8) = 0;

      puVar8 = (undefined4 *)FUN_005df0f5(8);

      if (puVar8 == (undefined4 *)0x0) {

        puVar8 = (undefined4 *)0x0;

      }

      else {

        *puVar8 = &PTR_FUN_00798108;

        puVar8[1] = iVar12;

      }

      *(undefined4 **)(iVar7 + 8) = puVar8;

    }

    cVar2 = FUN_0068bb80(iVar7,*(undefined4 *)(*(int *)(local_a0 + 0x44) + (*puVar11 & 0xff) * 0x14)

                        );

    if (cVar2 == '\0') goto LAB_0068ec85;

    if (puVar11[2] == 0) break;

  }

  pcVar10 = "Bindings";

  do {

    pcVar9 = pcVar10;

    pcVar10 = pcVar9 + 1;

  } while (*pcVar9 != '\0');

  FUN_00401280(pcVar9 + -0x80124c);

  pcVar9 = "Bindings";

  pcVar10 = pcStack_9c;

  do {

    cVar2 = *pcVar9;

    pcVar9 = pcVar9 + 1;

    *pcVar10 = cVar2;

    pcVar10 = pcVar10 + 1;

  } while (cVar2 != '\0');

  piVar6 = (int *)(**(code **)(*param_2 + 4))();

  pcVar10 = pcStack_9c;

  if (piVar6 == (int *)0x0) {

    pcVar10 = pcStack_9c + -0x14;

    LVar4 = InterlockedDecrement((LONG *)(pcStack_9c + -0x10));

    if ((LVar4 == 0) && (pcVar10 != (char *)0x0)) {

      (*(code *)**(undefined4 **)pcVar10)(1);

    }

    piStack_a4 = (int *)0x0;

    piVar6 = piStack_a4;

  }

  else {

    pLVar1 = (LONG *)(pcStack_9c + -0x10);

    InterlockedIncrement(pLVar1);

    if ((undefined4 *)piVar6[2] != (undefined4 *)0x0) {

      (*(code *)**(undefined4 **)piVar6[2])(1);

    }

    piVar6[2] = 0;

    puVar8 = (undefined4 *)FUN_005df0f5(8);

    if (puVar8 == (undefined4 *)0x0) {

      puVar8 = (undefined4 *)0x0;

    }

    else {

      *puVar8 = &PTR_FUN_00798140;

      puVar8[1] = pcVar10;

      InterlockedIncrement(pLVar1);

    }

    piVar6[2] = (int)puVar8;

    LVar4 = InterlockedDecrement((LONG *)(pcVar10 + -0x10));

    if ((LVar4 == 0) && (pcVar10 + -0x14 != (char *)0x0)) {

      (*(code *)**(undefined4 **)(pcVar10 + -0x14))(1);

    }

    pcVar10 = pcStack_9c + -0x14;

    LVar4 = InterlockedDecrement((LONG *)(pcStack_9c + -0x10));

    if ((LVar4 == 0) && (pcVar10 != (char *)0x0)) {

      (*(code *)**(undefined4 **)pcVar10)(1);

    }

  }

  piStack_a4 = piVar6;

  iStack_94 = local_a0 + 200;

  puVar8 = (undefined4 *)0x0;

  if (*(int *)(local_a0 + 0x134) != 0) {

    if (*(int *)(local_a0 + 0x138) == 0) {

      puVar8 = (undefined4 *)0x0;

    }

    else {

      puVar8 = (undefined4 *)(*(int *)(local_a0 + 0x138) + -8);

    }

  }

  for (; puVar8 != (undefined4 *)0x0; puVar8 = (undefined4 *)(puVar8[2] + -8)) {

    uVar3 = *puVar8;

    iVar12 = (**(code **)(*piStack_a4 + 4))();

    if (iVar12 == 0) goto LAB_0068ec85;

    cVar2 = FUN_0068dbd0(iVar12,0x1a,uVar3);

    if (cVar2 == '\0') {

      FUN_0065d360(iVar12);

LAB_0068ec85:

      FUN_0042e590();

      return 0;

    }

    FUN_0068e1f0(iVar12);

    if (puVar8[2] == 0) break;

  }

  FUN_0042e590();

  return 1;

}





// --- FUN_0068ecc0 at 0x0068ECC0 (size: 143) ---


undefined4 * __thiscall FUN_0068ecc0(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_00801108;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_0068ed50 at 0x0068ED50 (size: 143) ---


undefined4 * __thiscall FUN_0068ed50(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_0080110c;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_0068ede0 at 0x0068EDE0 (size: 143) ---


undefined4 * __thiscall FUN_0068ede0(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_00801110;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_0068ee70 at 0x0068EE70 (size: 64) ---


void __thiscall FUN_0068ee70(int param_1,undefined4 param_2,int *param_3,int param_4)



{

  int iVar1;

  int iVar2;

  

  iVar2 = *param_3;

  if (iVar2 != param_4) {

    do {

      iVar1 = iVar2;

      iVar2 = *(int *)(iVar1 + 0xc);

    } while (iVar2 != param_4);

    if (iVar1 != 0) {

      *(undefined4 *)(iVar1 + 0xc) = *(undefined4 *)(iVar2 + 0xc);

      *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

      return;

    }

  }

  *param_3 = *(int *)(iVar2 + 0xc);

  *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

  return;

}





// --- FUN_0068eeb0 at 0x0068EEB0 (size: 202) ---


uint __thiscall FUN_0068eeb0(int param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int *piVar5;

  

  if (param_2 == *(uint *)(param_1 + 0x68)) {

    return param_2 & 0xffffff00;

  }

  iVar3 = *(int *)(param_1 + 0x6c);

  iVar1 = 0;

  do {

    if (iVar3 == 0) {

      if (*(void **)(param_1 + 0x60) != (void *)(param_1 + 4)) {

        operator_delete__(*(void **)(param_1 + 0x60));

      }

      *(undefined4 *)(param_1 + 0x60) = 0;

      *(undefined4 *)(param_1 + 100) = 0;

      *(undefined4 *)(param_1 + 0x68) = 0;

      *(undefined4 *)(param_1 + 0x6c) = 0;

      FUN_00693b20(param_2);

      while (iVar1 != 0) {

        iVar3 = *(int *)(iVar1 + 0xc);

        FUN_0068f350(iVar1);

        iVar1 = iVar3;

      }

      return 1;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar5 = *(int **)(param_1 + 100);

        iVar4 = *piVar5;

        goto LAB_0068eefe;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    piVar5 = (int *)0x0;

    iVar4 = 0;

LAB_0068eefe:

    iVar3 = *piVar5;

    if (iVar3 == iVar4) {

LAB_0068ef11:

      *piVar5 = *(int *)(iVar3 + 0xc);

    }

    else {

      do {

        iVar2 = iVar3;

        iVar3 = *(int *)(iVar2 + 0xc);

      } while (iVar3 != iVar4);

      if (iVar2 == 0) goto LAB_0068ef11;

      *(undefined4 *)(iVar2 + 0xc) = *(undefined4 *)(iVar3 + 0xc);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    *(int *)(iVar4 + 0xc) = iVar1;

    iVar3 = *(int *)(param_1 + 0x6c);

    iVar1 = iVar4;

  } while( true );

}





// --- FUN_0068ef80 at 0x0068EF80 (size: 202) ---


uint __thiscall FUN_0068ef80(int param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int *piVar5;

  

  if (param_2 == *(uint *)(param_1 + 0x68)) {

    return param_2 & 0xffffff00;

  }

  iVar3 = *(int *)(param_1 + 0x6c);

  iVar1 = 0;

  do {

    if (iVar3 == 0) {

      if (*(void **)(param_1 + 0x60) != (void *)(param_1 + 4)) {

        operator_delete__(*(void **)(param_1 + 0x60));

      }

      *(undefined4 *)(param_1 + 0x60) = 0;

      *(undefined4 *)(param_1 + 100) = 0;

      *(undefined4 *)(param_1 + 0x68) = 0;

      *(undefined4 *)(param_1 + 0x6c) = 0;

      FUN_00693b20(param_2);

      while (iVar1 != 0) {

        iVar3 = *(int *)(iVar1 + 4);

        FUN_0068f390(iVar1);

        iVar1 = iVar3;

      }

      return 1;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar5 = *(int **)(param_1 + 100);

        iVar4 = *piVar5;

        goto LAB_0068efce;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    piVar5 = (int *)0x0;

    iVar4 = 0;

LAB_0068efce:

    iVar3 = *piVar5;

    if (iVar3 == iVar4) {

LAB_0068efe1:

      *piVar5 = *(int *)(iVar3 + 4);

    }

    else {

      do {

        iVar2 = iVar3;

        iVar3 = *(int *)(iVar2 + 4);

      } while (iVar3 != iVar4);

      if (iVar2 == 0) goto LAB_0068efe1;

      *(undefined4 *)(iVar2 + 4) = *(undefined4 *)(iVar3 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    *(int *)(iVar4 + 4) = iVar1;

    iVar3 = *(int *)(param_1 + 0x6c);

    iVar1 = iVar4;

  } while( true );

}





// --- FUN_0068f050 at 0x0068F050 (size: 202) ---


uint __thiscall FUN_0068f050(int param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int *piVar5;

  

  if (param_2 == *(uint *)(param_1 + 0x68)) {

    return param_2 & 0xffffff00;

  }

  iVar3 = *(int *)(param_1 + 0x6c);

  iVar1 = 0;

  do {

    if (iVar3 == 0) {

      if (*(void **)(param_1 + 0x60) != (void *)(param_1 + 4)) {

        operator_delete__(*(void **)(param_1 + 0x60));

      }

      *(undefined4 *)(param_1 + 0x60) = 0;

      *(undefined4 *)(param_1 + 100) = 0;

      *(undefined4 *)(param_1 + 0x68) = 0;

      *(undefined4 *)(param_1 + 0x6c) = 0;

      FUN_00693b20(param_2);

      while (iVar1 != 0) {

        iVar3 = *(int *)(iVar1 + 4);

        FUN_0068f3d0(iVar1);

        iVar1 = iVar3;

      }

      return 1;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar5 = *(int **)(param_1 + 100);

        iVar4 = *piVar5;

        goto LAB_0068f09e;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    piVar5 = (int *)0x0;

    iVar4 = 0;

LAB_0068f09e:

    iVar3 = *piVar5;

    if (iVar3 == iVar4) {

LAB_0068f0b1:

      *piVar5 = *(int *)(iVar3 + 4);

    }

    else {

      do {

        iVar2 = iVar3;

        iVar3 = *(int *)(iVar2 + 4);

      } while (iVar3 != iVar4);

      if (iVar2 == 0) goto LAB_0068f0b1;

      *(undefined4 *)(iVar2 + 4) = *(undefined4 *)(iVar3 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    *(int *)(iVar4 + 4) = iVar1;

    iVar3 = *(int *)(param_1 + 0x6c);

    iVar1 = iVar4;

  } while( true );

}





// --- FUN_0068f120 at 0x0068F120 (size: 85) ---


int FUN_0068f120(undefined4 param_1)



{

  undefined4 local_c;

  undefined4 local_8;

  int local_4;

  

  FUN_0068db20(&local_c,param_1);

  if (local_4 != 0) {

    FUN_0068ee70(local_c,local_8,local_4);

    return local_4;

  }

  return 0;

}





// --- FUN_0068f180 at 0x0068F180 (size: 122) ---


void __fastcall FUN_0068f180(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  void *pvVar4;

  int *piVar5;

  

  iVar1 = *(int *)(param_1 + 0x6c);

  do {

    if (iVar1 == 0) {

      return;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar5 = *(int **)(param_1 + 100);

        pvVar4 = (void *)*piVar5;

        goto LAB_0068f1bf;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    piVar5 = (int *)0x0;

    pvVar4 = (void *)0x0;

LAB_0068f1bf:

    pvVar3 = (void *)*piVar5;

    if (pvVar3 == pvVar4) {

LAB_0068f1d2:

      *piVar5 = *(int *)((int)pvVar3 + 0xc);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 0xc);

      } while (pvVar3 != pvVar4);

      if (pvVar2 == (void *)0x0) goto LAB_0068f1d2;

      *(undefined4 *)((int)pvVar2 + 0xc) = *(undefined4 *)((int)pvVar3 + 0xc);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    if (pvVar4 != (void *)0x0) {

      operator_delete(pvVar4);

    }

    iVar1 = *(int *)(param_1 + 0x6c);

  } while( true );

}





// --- FUN_0068f200 at 0x0068F200 (size: 73) ---


void __fastcall FUN_0068f200(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

  local_4 = *(undefined4 *)(param_1 + 0x68);

  puVar2 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&local_4,local_4,0);

  if ((puVar2 != (undefined4 *)puVar1) || (puVar2 = puVar2 + -1, puVar2 != (undefined4 *)puVar1)) {

    puVar2 = puVar2 + 1;

  }

  FUN_0068eeb0(*puVar2);

  return;

}





// --- FUN_0068f250 at 0x0068F250 (size: 73) ---


void __fastcall FUN_0068f250(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

  local_4 = *(undefined4 *)(param_1 + 0x68);

  puVar2 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&local_4,local_4,0);

  if ((puVar2 != (undefined4 *)puVar1) || (puVar2 = puVar2 + -1, puVar2 != (undefined4 *)puVar1)) {

    puVar2 = puVar2 + 1;

  }

  FUN_0068ef80(*puVar2);

  return;

}





// --- FUN_0068f2a0 at 0x0068F2A0 (size: 73) ---


void __fastcall FUN_0068f2a0(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

  local_4 = *(undefined4 *)(param_1 + 0x68);

  puVar2 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&local_4,local_4,0);

  if ((puVar2 != (undefined4 *)puVar1) || (puVar2 = puVar2 + -1, puVar2 != (undefined4 *)puVar1)) {

    puVar2 = puVar2 + 1;

  }

  FUN_0068f050(*puVar2);

  return;

}





// --- FUN_0068f2f0 at 0x0068F2F0 (size: 81) ---


void __fastcall FUN_0068f2f0(int param_1)



{

  int *piVar1;

  int iVar2;

  undefined4 *puVar3;

  

  do {

    piVar1 = *(int **)(param_1 + 0x70);

    if (piVar1 == (int *)0x0) break;

    if ((int *)piVar1[1] == (int *)0x0) {

      iVar2 = *piVar1;

      *(int *)(param_1 + 0x70) = iVar2;

      if (iVar2 != 0) {

        *(undefined4 *)(iVar2 + 4) = 0;

      }

    }

    else {

      *(int *)piVar1[1] = *piVar1;

    }

    if (*piVar1 == 0) {

      puVar3 = *(undefined4 **)(*(int *)(param_1 + 0x74) + 4);

      *(undefined4 **)(param_1 + 0x74) = puVar3;

      if (puVar3 != (undefined4 *)0x0) {

        *puVar3 = 0;

      }

    }

    else {

      *(int *)(*piVar1 + 4) = piVar1[1];

    }

    *piVar1 = 0;

    piVar1[1] = 0;

  } while (piVar1 != (int *)0x0);

  FUN_0068f180();

  return;

}





// --- FUN_0068f350 at 0x0068F350 (size: 62) ---


void __thiscall FUN_0068f350(int param_1,uint *param_2)



{

  uint *puVar1;

  

  if (*(int *)(param_1 + 0x68) * 2 < *(int *)(param_1 + 0x6c) + 1) {

    FUN_0068f200();

  }

  puVar1 = (uint *)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  param_2[3] = *puVar1;

  *puVar1 = (uint)param_2;

  if (puVar1 < *(uint **)(param_1 + 100)) {

    *(uint **)(param_1 + 100) = puVar1;

  }

  *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

  return;

}





// --- FUN_0068f390 at 0x0068F390 (size: 62) ---


void __thiscall FUN_0068f390(int param_1,uint *param_2)



{

  uint *puVar1;

  

  if (*(int *)(param_1 + 0x68) * 2 < *(int *)(param_1 + 0x6c) + 1) {

    FUN_0068f250();

  }

  puVar1 = (uint *)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  param_2[1] = *puVar1;

  *puVar1 = (uint)param_2;

  if (puVar1 < *(uint **)(param_1 + 100)) {

    *(uint **)(param_1 + 100) = puVar1;

  }

  *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

  return;

}





// --- FUN_0068f3d0 at 0x0068F3D0 (size: 62) ---


void __thiscall FUN_0068f3d0(int param_1,uint *param_2)



{

  uint *puVar1;

  

  if (*(int *)(param_1 + 0x68) * 2 < *(int *)(param_1 + 0x6c) + 1) {

    FUN_0068f2a0();

  }

  puVar1 = (uint *)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  param_2[1] = *puVar1;

  *puVar1 = (uint)param_2;

  if (puVar1 < *(uint **)(param_1 + 100)) {

    *(uint **)(param_1 + 100) = puVar1;

  }

  *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

  return;

}





// --- FUN_0068f410 at 0x0068F410 (size: 105) ---


uint __thiscall FUN_0068f410(int param_1,uint *param_2)



{

  int iVar1;

  uint uVar2;

  undefined1 local_c [8];

  uint local_4;

  

  FUN_0068db20(local_c,param_2);

  if (local_4 != 0) {

    return local_4 & 0xffffff00;

  }

  if (*(int *)(param_1 + 0x68) * 2 < *(int *)(param_1 + 0x6c) + 1) {

    FUN_0068f200();

  }

  uVar2 = *param_2 % *(uint *)(param_1 + 0x68);

  iVar1 = *(int *)(param_1 + 0x60);

  param_2[3] = *(uint *)(iVar1 + uVar2 * 4);

  *(uint **)(iVar1 + uVar2 * 4) = param_2;

  uVar2 = iVar1 + uVar2 * 4;

  if (uVar2 < *(uint *)(param_1 + 100)) {

    *(uint *)(param_1 + 100) = uVar2;

  }

  *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

  return CONCAT31((int3)(uVar2 >> 8),1);

}





// --- FUN_0068f480 at 0x0068F480 (size: 120) ---


uint __thiscall FUN_0068f480(int param_1,uint *param_2)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0068f4ab:

      if ((int)(*(uint *)(param_1 + 0x68) * 2) < *(int *)(param_1 + 0x6c) + 1) {

        FUN_0068f250();

      }

      uVar3 = *param_2 % *(uint *)(param_1 + 0x68);

      iVar2 = *(int *)(param_1 + 0x60);

      param_2[1] = *(uint *)(iVar2 + uVar3 * 4);

      *(uint **)(iVar2 + uVar3 * 4) = param_2;

      uVar3 = iVar2 + uVar3 * 4;

      if (uVar3 < *(uint *)(param_1 + 100)) {

        *(uint *)(param_1 + 100) = uVar3;

      }

      iVar2 = *(int *)(param_1 + 0x6c) + 1;

      *(int *)(param_1 + 0x6c) = iVar2;

      return CONCAT31((int3)((uint)iVar2 >> 8),1);

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return (uint)puVar1 & 0xffffff00;

      }

      goto LAB_0068f4ab;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_0068f500 at 0x0068F500 (size: 120) ---


uint __thiscall FUN_0068f500(int param_1,uint *param_2)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0068f52b:

      if ((int)(*(uint *)(param_1 + 0x68) * 2) < *(int *)(param_1 + 0x6c) + 1) {

        FUN_0068f2a0();

      }

      uVar3 = *param_2 % *(uint *)(param_1 + 0x68);

      iVar2 = *(int *)(param_1 + 0x60);

      param_2[1] = *(uint *)(iVar2 + uVar3 * 4);

      *(uint **)(iVar2 + uVar3 * 4) = param_2;

      uVar3 = iVar2 + uVar3 * 4;

      if (uVar3 < *(uint *)(param_1 + 100)) {

        *(uint *)(param_1 + 100) = uVar3;

      }

      iVar2 = *(int *)(param_1 + 0x6c) + 1;

      *(int *)(param_1 + 0x6c) = iVar2;

      return CONCAT31((int3)((uint)iVar2 >> 8),1);

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return (uint)puVar1 & 0xffffff00;

      }

      goto LAB_0068f52b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_0068f580 at 0x0068F580 (size: 102) ---


undefined4 __thiscall FUN_0068f580(int param_1,int param_2)



{

  int iVar1;

  undefined1 local_c [12];

  

  iVar1 = FUN_0068db20(local_c,param_2);

  if (*(int *)(iVar1 + 8) == 0) {

    FUN_0068f410(param_2);

  }

  else if (param_2 == 0) {

    FUN_00410880(0);

  }

  else {

    FUN_00410880(param_2 + 0x10);

  }

  if (param_2 == 0) {

    param_2 = 0;

  }

  else {

    param_2 = param_2 + 0x10;

  }

  FUN_00410820(param_2,*(undefined4 *)(param_1 + 0x74));

  return 1;

}





// --- FUN_0068f5f0 at 0x0068F5F0 (size: 92) ---


undefined4 __thiscall FUN_0068f5f0(int param_1,uint *param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0068f61b:

      FUN_0068f480(param_2);

LAB_0068f623:

      FUN_00410820(param_2 + 2,*(undefined4 *)(param_1 + 0x74));

      return 1;

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        FUN_00410880(param_2 + 2);

        goto LAB_0068f623;

      }

      goto LAB_0068f61b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_0068f650 at 0x0068F650 (size: 92) ---


undefined4 __thiscall FUN_0068f650(int param_1,uint *param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0068f67b:

      FUN_0068f500(param_2);

LAB_0068f683:

      FUN_00410820(param_2 + 2,*(undefined4 *)(param_1 + 0x74));

      return 1;

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        FUN_00410880(param_2 + 2);

        goto LAB_0068f683;

      }

      goto LAB_0068f67b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_0068f6b0 at 0x0068F6B0 (size: 81) ---


bool FUN_0068f6b0(void)



{

  undefined1 local_c [8];

  void *local_4;

  

  FUN_0068db20(local_c,&stack0x00000004);

  if (local_4 != (void *)0x0) {

    FUN_00410880((int)local_4 + 0x10);

    FUN_0068f120(&stack0x00000004);

    operator_delete(local_4);

  }

  return local_4 != (void *)0x0;

}





// --- FUN_0068f710 at 0x0068F710 (size: 95) ---


undefined4 * __fastcall FUN_0068f710(undefined4 *param_1)



{

  FUN_00415460(DAT_008f9498);

  *param_1 = &PTR_LAB_00801280;

  FUN_00401340("User Defined Keymap");

  param_1[0x11] = 0;

  param_1[0x12] = 0;

  param_1[0x13] = 0;

  FUN_0068ed50(0);

  param_1[0x30] = 0;

  param_1[0x31] = 0;

  FUN_0068ede0(0);

  param_1[0x4e] = 0;

  param_1[0x4f] = 0;

  param_1[0x50] = 0;

  return param_1;

}





// --- FUN_0068f780 at 0x0068F780 (size: 81) ---


undefined4 __thiscall FUN_0068f780(int param_1,int param_2)



{

  int iVar1;

  undefined1 local_c [12];

  

  iVar1 = FUN_0068db20(local_c,param_2);

  if (*(int *)(iVar1 + 8) != 0) {

    return 0;

  }

  FUN_0068f410(param_2);

  if (param_2 == 0) {

    param_2 = 0;

  }

  else {

    param_2 = param_2 + 0x10;

  }

  FUN_00410820(param_2,*(undefined4 *)(param_1 + 0x74));

  return 1;

}





// --- FUN_0068f7e0 at 0x0068F7E0 (size: 69) ---


undefined4 __thiscall FUN_0068f7e0(int param_1,uint *param_2)



{

  uint *puVar1;

  undefined4 uVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  if (puVar1 != (uint *)0x0) {

    while (*puVar1 != *param_2) {

      puVar1 = (uint *)puVar1[1];

      if (puVar1 == (uint *)0x0) {

        return 0;

      }

    }

    if (puVar1 != (uint *)0x0) {

      uVar2 = FUN_0068f5f0();

      return uVar2;

    }

  }

  return 0;

}





// --- FUN_0068f830 at 0x0068F830 (size: 85) ---


undefined4 __thiscall FUN_0068f830(int param_1,uint *param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0068f85b:

      FUN_0068f480(param_2);

      FUN_00410820(param_2 + 2,*(undefined4 *)(param_1 + 0x74));

      return 1;

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return 0;

      }

      goto LAB_0068f85b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_0068f890 at 0x0068F890 (size: 69) ---


undefined4 __thiscall FUN_0068f890(int param_1,uint *param_2)



{

  uint *puVar1;

  undefined4 uVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  if (puVar1 != (uint *)0x0) {

    while (*puVar1 != *param_2) {

      puVar1 = (uint *)puVar1[1];

      if (puVar1 == (uint *)0x0) {

        return 0;

      }

    }

    if (puVar1 != (uint *)0x0) {

      uVar2 = FUN_0068f650();

      return uVar2;

    }

  }

  return 0;

}





// --- FUN_0068f8e0 at 0x0068F8E0 (size: 85) ---


undefined4 __thiscall FUN_0068f8e0(int param_1,uint *param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0068f90b:

      FUN_0068f500(param_2);

      FUN_00410820(param_2 + 2,*(undefined4 *)(param_1 + 0x74));

      return 1;

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return 0;

      }

      goto LAB_0068f90b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_0068f950 at 0x0068F950 (size: 305) ---


undefined1 __thiscall FUN_0068f950(int param_1,int param_2)



{

  void *pvVar1;

  undefined4 *puVar2;

  char cVar3;

  int *piVar4;

  int iVar5;

  int iVar6;

  int iVar7;

  undefined1 uVar8;

  void *pvVar9;

  

  uVar8 = 0;

  pvVar1 = (void *)0x0;

  if (*(int *)(param_1 + 0x74) != 0) {

    if (*(int *)(param_1 + 0x78) == 0) {

      pvVar1 = (void *)0x0;

    }

    else {

      pvVar1 = (void *)(*(int *)(param_1 + 0x78) + -0x10);

    }

  }

  do {

    while( true ) {

      if (pvVar1 == (void *)0x0) {

        return uVar8;

      }

      if (*(int *)((int)pvVar1 + 0x18) == param_2) break;

      if (*(int *)((int)pvVar1 + 0x10) == 0) {

        return uVar8;

      }

      pvVar1 = (void *)(*(int *)((int)pvVar1 + 0x10) + -0x10);

    }

    if (*(int *)((int)pvVar1 + 0x10) == 0) {

      pvVar9 = (void *)0x0;

    }

    else {

      pvVar9 = (void *)(*(int *)((int)pvVar1 + 0x10) + -0x10);

    }

    piVar4 = (int *)(-(uint)(pvVar1 != (void *)0x0) & (int)pvVar1 + 0x10U);

    if ((int *)piVar4[1] == (int *)0x0) {

      iVar5 = **(int **)(param_1 + 0x78);

      *(int *)(param_1 + 0x78) = iVar5;

      if (iVar5 != 0) {

        *(undefined4 *)(iVar5 + 4) = 0;

      }

    }

    else {

      *(int *)piVar4[1] = *piVar4;

    }

    if (*piVar4 == 0) {

      puVar2 = *(undefined4 **)(*(int *)(param_1 + 0x7c) + 4);

      *(undefined4 **)(param_1 + 0x7c) = puVar2;

      if (puVar2 != (undefined4 *)0x0) {

        *puVar2 = 0;

      }

    }

    else {

      *(int *)(*piVar4 + 4) = piVar4[1];

    }

    *piVar4 = 0;

    piVar4[1] = 0;

    iVar5 = FUN_00686fe0(*(undefined4 *)(param_1 + 0x70));

    piVar4 = (int *)(*(int *)(param_1 + 0x68) + iVar5 * 4);

    for (iVar5 = *(int *)(*(int *)(param_1 + 0x68) + iVar5 * 4); iVar5 != 0;

        iVar5 = *(int *)(iVar5 + 0xc)) {

      cVar3 = FUN_0068b260(pvVar1);

      if (cVar3 != '\0') {

        if (iVar5 != 0) {

          iVar7 = *piVar4;

          if (iVar7 == iVar5) goto LAB_0068fa3f;

          do {

            iVar6 = iVar7;

            iVar7 = *(int *)(iVar6 + 0xc);

          } while (iVar7 != iVar5);

          if (iVar6 == 0) {

LAB_0068fa3f:

            *piVar4 = *(int *)(iVar7 + 0xc);

          }

          else {

            *(undefined4 *)(iVar6 + 0xc) = *(undefined4 *)(iVar7 + 0xc);

          }

          *(int *)(param_1 + 0x74) = *(int *)(param_1 + 0x74) + -1;

        }

        break;

      }

    }

    if (pvVar1 != (void *)0x0) {

      operator_delete(pvVar1);

    }

    uVar8 = 1;

    pvVar1 = pvVar9;

  } while( true );

}





// --- FUN_0068fa90 at 0x0068FA90 (size: 288) ---


void __fastcall FUN_0068fa90(int param_1)



{

  int *piVar1;

  int iVar2;

  undefined4 *puVar3;

  uint *puVar4;

  void *pvVar5;

  uint *puVar6;

  uint *puVar7;

  uint uVar8;

  uint *puVar9;

  

  FUN_00448cd0();

LAB_0068faa0:

  puVar9 = (uint *)0x0;

  if (*(int *)(param_1 + 0x134) == 0) {

    return;

  }

  piVar1 = *(int **)(param_1 + 0x138);

  if (piVar1 != (int *)0x0) {

    if ((int *)piVar1[1] == (int *)0x0) {

      iVar2 = *piVar1;

      *(int *)(param_1 + 0x138) = iVar2;

      if (iVar2 != 0) {

        *(undefined4 *)(iVar2 + 4) = 0;

      }

    }

    else {

      *(int *)piVar1[1] = *piVar1;

    }

    if (*piVar1 == 0) {

      puVar3 = *(undefined4 **)(*(int *)(param_1 + 0x13c) + 4);

      *(undefined4 **)(param_1 + 0x13c) = puVar3;

      if (puVar3 != (undefined4 *)0x0) {

        *puVar3 = 0;

      }

    }

    else {

      *(int *)(*piVar1 + 4) = piVar1[1];

    }

    *piVar1 = 0;

    piVar1[1] = 0;

    if (piVar1 != (int *)0x0) {

      puVar9 = (uint *)(piVar1 + -2);

    }

  }

  uVar8 = *puVar9 % *(uint *)(param_1 + 0x130);

  puVar7 = *(uint **)(*(int *)(param_1 + 0x128) + uVar8 * 4);

  for (puVar4 = puVar7; puVar4 != (uint *)0x0; puVar4 = (uint *)puVar4[1]) {

    if (*puVar4 == *puVar9) {

      if (puVar4 != (uint *)0x0) {

        if (puVar7 != puVar4) goto LAB_0068fb38;

        goto LAB_0068fb45;

      }

      break;

    }

  }

  goto LAB_0068fb58;

LAB_0068fb38:

  do {

    puVar6 = puVar7;

    puVar7 = (uint *)puVar6[1];

  } while (puVar7 != puVar4);

  if (puVar6 == (uint *)0x0) {

LAB_0068fb45:

    *(uint *)(*(int *)(param_1 + 0x128) + uVar8 * 4) = puVar7[1];

  }

  else {

    puVar6[1] = puVar7[1];

  }

  *(int *)(param_1 + 0x134) = *(int *)(param_1 + 0x134) + -1;

LAB_0068fb58:

  pvVar5 = (void *)puVar9[4];

  operator_delete(puVar9);

  if (pvVar5 != (void *)0x0) {

    FUN_0068f2f0();

    *(undefined ***)((int)pvVar5 + 8) = &PTR_FUN_00801108;

    if (*(void **)((int)pvVar5 + 0x68) != (void *)((int)pvVar5 + 0xc)) {

      operator_delete__(*(void **)((int)pvVar5 + 0x68));

    }

    *(undefined4 *)((int)pvVar5 + 0x68) = 0;

    *(undefined4 *)((int)pvVar5 + 0x6c) = 0;

    *(undefined4 *)((int)pvVar5 + 0x70) = 0;

    *(undefined4 *)((int)pvVar5 + 0x74) = 0;

    operator_delete(pvVar5);

  }

  goto LAB_0068faa0;

}





// --- FUN_0068fbb0 at 0x0068FBB0 (size: 181) ---


char FUN_0068fbb0(undefined4 *param_1,undefined4 *param_2)



{

  char cVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined1 local_c [8];

  int local_4;

  

  iVar2 = FUN_0068db20(local_c,param_1);

  if (*(int *)(iVar2 + 8) == 0) {

    puVar3 = (undefined4 *)FUN_005df0f5(0x1c);

    if (puVar3 == (undefined4 *)0x0) {

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = *param_1;

      puVar3[1] = param_1[1];

      puVar3[2] = param_1[2];

      puVar3[3] = 0;

      puVar3[4] = 0;

      puVar3[5] = 0;

      puVar3[6] = *param_2;

    }

    cVar1 = FUN_0068f780(puVar3);

    if ((cVar1 == '\0') && (puVar3 != (undefined4 *)0x0)) {

      operator_delete(puVar3);

    }

    return cVar1;

  }

  FUN_0068db20(local_c,param_1);

  if (local_4 == 0) {

    return '\0';

  }

  cVar1 = FUN_0068f580(local_4);

  return cVar1;

}





// --- FUN_0068fc70 at 0x0068FC70 (size: 147) ---


char __thiscall FUN_0068fc70(int param_1,uint *param_2,uint *param_3)



{

  char cVar1;

  uint *puVar2;

  

  puVar2 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar2 == (uint *)0x0) {

LAB_0068fc9b:

      puVar2 = (uint *)FUN_005df0f5(0x14);

      if (puVar2 == (uint *)0x0) {

        puVar2 = (uint *)0x0;

      }

      else {

        *puVar2 = *param_2;

        puVar2[1] = 0;

        puVar2[2] = 0;

        puVar2[3] = 0;

        puVar2[4] = *param_3;

      }

      cVar1 = FUN_0068f830(puVar2);

      if ((cVar1 == '\0') && (puVar2 != (uint *)0x0)) {

        operator_delete(puVar2);

      }

      return cVar1;

    }

    if (*puVar2 == *param_2) {

      if (puVar2 != (uint *)0x0) {

        cVar1 = FUN_0068f7e0(param_2);

        return cVar1;

      }

      goto LAB_0068fc9b;

    }

    puVar2 = (uint *)puVar2[1];

  } while( true );

}





// --- FUN_0068fd10 at 0x0068FD10 (size: 147) ---


char __thiscall FUN_0068fd10(int param_1,uint *param_2,uint *param_3)



{

  char cVar1;

  uint *puVar2;

  

  puVar2 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar2 == (uint *)0x0) {

LAB_0068fd3b:

      puVar2 = (uint *)FUN_005df0f5(0x14);

      if (puVar2 == (uint *)0x0) {

        puVar2 = (uint *)0x0;

      }

      else {

        *puVar2 = *param_2;

        puVar2[1] = 0;

        puVar2[2] = 0;

        puVar2[3] = 0;

        puVar2[4] = *param_3;

      }

      cVar1 = FUN_0068f8e0(puVar2);

      if ((cVar1 == '\0') && (puVar2 != (uint *)0x0)) {

        operator_delete(puVar2);

      }

      return cVar1;

    }

    if (*puVar2 == *param_2) {

      if (puVar2 != (uint *)0x0) {

        cVar1 = FUN_0068f890(param_2);

        return cVar1;

      }

      goto LAB_0068fd3b;

    }

    puVar2 = (uint *)puVar2[1];

  } while( true );

}





// --- FUN_0068fdb0 at 0x0068FDB0 (size: 295) ---


void __thiscall FUN_0068fdb0(int param_1,int param_2)



{

  int iVar1;

  uint *puVar2;

  undefined4 *puVar3;

  int *piVar4;

  uint uVar5;

  uint uVar6;

  int iVar7;

  undefined4 local_c;

  int local_8;

  undefined4 local_4;

  

  iVar1 = param_2;

  uVar6 = *(uint *)(param_1 + 0x74);

  FUN_0040ad10(4);

  puVar2 = (uint *)FUN_0040acf0(4);

  if (puVar2 != (uint *)0x0) {

    if ((*(byte *)(iVar1 + 4) & 1) == 0) {

      uVar6 = *puVar2;

    }

    else {

      *puVar2 = uVar6;

    }

  }

  if ((*(byte *)(iVar1 + 4) & 1) == 0) {

    uVar5 = 0;

    if (uVar6 != 0) {

      do {

        local_c = 0xffffffff;

        local_8 = 0;

        local_4 = 0;

        FUN_006855e0(iVar1);

        FUN_0040ad10(4);

        piVar4 = (int *)FUN_0040acf0(4);

        if (piVar4 != (int *)0x0) {

          if ((*(byte *)(iVar1 + 4) & 1) == 0) {

            param_2 = *piVar4;

          }

          else {

            *piVar4 = param_2;

          }

        }

        if ((*(uint *)(iVar1 + 4) >> 2 & 1) != 0) {

          return;

        }

        FUN_0068fbb0(&local_c,&param_2);

        uVar5 = uVar5 + 1;

      } while (uVar5 < uVar6);

    }

  }

  else {

    local_8 = param_1 + 8;

    iVar7 = 0;

    if (*(int *)(param_1 + 0x74) != 0) {

      if (*(int *)(param_1 + 0x78) == 0) {

        iVar7 = 0;

      }

      else {

        iVar7 = *(int *)(param_1 + 0x78) + -0x10;

      }

    }

    if (iVar7 != 0) {

      while( true ) {

        FUN_006855e0(iVar1);

        FUN_0040ad10(4);

        puVar3 = (undefined4 *)FUN_0040acf0(4);

        if (puVar3 != (undefined4 *)0x0) {

          if ((*(byte *)(iVar1 + 4) & 1) == 0) {

            *(undefined4 *)(iVar7 + 0x18) = *puVar3;

          }

          else {

            *puVar3 = *(undefined4 *)(iVar7 + 0x18);

          }

        }

        if (*(int *)(iVar7 + 0x10) == 0) break;

        iVar7 = *(int *)(iVar7 + 0x10) + -0x10;

        if (iVar7 == 0) {

          return;

        }

      }

    }

  }

  return;

}





// --- FUN_0068fee0 at 0x0068FEE0 (size: 265) ---


uint __fastcall FUN_0068fee0(int param_1)



{

  int *piVar1;

  int *piVar2;

  char cVar3;

  uint uVar4;

  void *pvStack_1c;

  uint uStack_18;

  undefined4 uStack_14;

  undefined **local_10;

  int *local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  piVar2 = DAT_00837ff4;

  if (DAT_00837ff4 != (int *)0x0) {

    local_10 = &PTR_FUN_007a3c34;

    local_c = (int *)0x0;

    local_8 = 0;

    local_4 = 0;

    cVar3 = (**(code **)(*DAT_00837ff4 + 0x94))(*(undefined4 *)(param_1 + 4),&local_10);

    piVar1 = local_c;

    if (cVar3 != '\0') {

      for (; piVar1 != (int *)0x0; piVar1 = (int *)piVar1[1]) {

        if (*(int *)(param_1 + 4) != *piVar1) {

          pvStack_1c = (void *)0x0;

          uStack_18 = 0;

          uStack_14 = 0;

          cVar3 = (**(code **)(*piVar2 + 0x98))(&stack0x00000008,*piVar1,&pvStack_1c);

          if (cVar3 != '\0') {

            if ((uStack_18 & 0x80000000) == 0x80000000) {

              operator_delete__(pvStack_1c);

            }

            local_10 = &PTR_FUN_007a3c34;

            uVar4 = FUN_0049f850();

            return uVar4 & 0xffffff00;

          }

          if ((uStack_18 & 0x80000000) == 0x80000000) {

            operator_delete__(pvStack_1c);

          }

        }

      }

    }

    local_10 = &PTR_FUN_007a3c34;

    FUN_0049f850();

  }

  uVar4 = FUN_0068fbb0(&stack0x00000008,&stack0x00000004);

  return uVar4;

}





// --- FUN_0068fff0 at 0x0068FFF0 (size: 126) ---


undefined4 FUN_0068fff0(int param_1,undefined4 param_2,char param_3)



{

  char cVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)0x0;

  if (*(int *)(param_1 + 0x74) != 0) {

    if (*(int *)(param_1 + 0x78) == 0) {

      puVar2 = (undefined4 *)0x0;

    }

    else {

      puVar2 = (undefined4 *)(*(int *)(param_1 + 0x78) + -0x10);

    }

  }

  while( true ) {

    if (puVar2 == (undefined4 *)0x0) {

      return 1;

    }

    cVar1 = FUN_0068fee0(puVar2[6],*puVar2,puVar2[1],puVar2[2]);

    if ((cVar1 == '\0') && (param_3 == '\0')) break;

    if (puVar2[4] == 0) {

      return 1;

    }

    puVar2 = (undefined4 *)(puVar2[4] + -0x10);

  }

  return 0;

}





