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

// --- FUN_00670110 at 0x00670110 (size: 930) ---


void FUN_00670110(void)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  int in_EAX;

  undefined4 uVar4;

  int iVar5;

  int iVar6;

  uint uVar7;

  uint uVar8;

  int iVar9;

  int iVar10;

  int iVar11;

  uint *puVar12;

  int iVar13;

  byte bVar17;

  ushort uVar14;

  short sVar15;

  byte bVar18;

  byte bVar19;

  short sVar20;

  short sVar22;

  uint5 uVar21;

  short sVar23;

  short sVar24;

  byte bVar26;

  byte bVar27;

  ulonglong uVar25;

  undefined4 local_48;

  undefined4 local_44;

  int local_34;

  int local_30;

  int local_2c;

  ulonglong uVar16;

  

  uVar7 = DAT_008f86b0;

  local_44 = *(int *)(in_EAX + 8);

  if (local_44 == 0) {

    iVar10 = *(int *)(in_EAX + 0x14);

    bVar17 = *(byte *)(in_EAX + 0x24);

    local_44 = CONCAT13(bVar17,(int3)DAT_008f86b0);

    local_30 = *(int *)(in_EAX + 0x20);

    if (local_30 != 0) {

      iVar5 = *(int *)(in_EAX + 0x1c);

      iVar2 = *(int *)(in_EAX + 0x18);

      do {

        if (iVar5 != 0) {

          iVar13 = iVar5;

          do {

            iVar13 = iVar13 + -1;

            if (bVar17 != 0) {

              iVar11 = bVar17 + 1;

              uVar4 = local_44;

              if (iVar11 != 0x100) {

                uVar8 = *(uint *)(iVar10 + iVar13 * 4);

                local_48._3_1_ = (byte)(uVar8 >> 0x18);

                if (local_48._3_1_ != 0) {

                  bVar18 = (byte)(uVar8 >> 8);

                  bVar19 = (byte)(uVar8 >> 0x10);

                  bVar26 = (byte)(uVar7 >> 8);

                  bVar27 = (byte)(uVar7 >> 0x10);

                  if (local_48._3_1_ == 0xff) {

                    uVar3 = (uint)(CONCAT34((int3)(CONCAT25(0xff00,CONCAT14(bVar19,uVar8)) >> 0x20),

                                            uVar8) >> 0x18);

                    uVar21 = (uint5)uVar3 & 0xffffffff00;

                    uVar16 = (ulonglong)CONCAT43(uVar3,CONCAT12(bVar18,(ushort)uVar8)) &

                             0xffffffff00ffffff;

                    uVar14 = (ushort)uVar8 & 0xff;

                    uVar25 = (ulonglong)

                             CONCAT52(CONCAT23((short)(CONCAT14(bVar27,local_44) >> 0x18),

                                               CONCAT12(bVar26,(short)uVar7)) >> 0x10,(short)uVar7)

                             & 0xff00ff00ff;

                    sVar24 = (short)iVar11;

                    sVar20 = (short)(uVar16 >> 0x10);

                    sVar22 = (short)(uVar21 >> 8);

                    sVar23 = (short)(uVar21 >> 0x18);

                    sVar15 = uVar14 - (((ushort)(uVar14 * sVar24) >> 8) -

                                      ((ushort)((short)uVar25 * sVar24) >> 8));

                    sVar20 = sVar20 - (((ushort)(sVar20 * sVar24) >> 8) -

                                      ((ushort)((short)(uVar25 >> 0x10) * sVar24) >> 8));

                    sVar22 = sVar22 - (((ushort)(sVar22 * sVar24) >> 8) -

                                      ((ushort)((short)(uVar25 >> 0x20) * sVar24) >> 8));

                    sVar23 = sVar23 - (((ushort)(sVar23 * sVar24) >> 8) -

                                      ((ushort)((short)(uVar16 >> 0x30) * sVar24) >> 8));

                    uVar4 = CONCAT13((0 < sVar23) * (sVar23 < 0x100) * (char)sVar23 -

                                     (0xff < sVar23),

                                     CONCAT12((0 < sVar22) * (sVar22 < 0x100) * (char)sVar22 -

                                              (0xff < sVar22),

                                              CONCAT11((0 < sVar20) * (sVar20 < 0x100) *

                                                       (char)sVar20 - (0xff < sVar20),

                                                       (0 < sVar15) * (sVar15 < 0x100) *

                                                       (char)sVar15 - (0xff < sVar15))));

                  }

                  else {

                    iVar9 = local_48._3_1_ + 1 +

                            (iVar11 - ((int)((local_48._3_1_ + 1) * iVar11) >> 8));

                    local_48._0_1_ = (char)uVar8;

                    local_48 = CONCAT13((char)iVar9 + -1,

                                        CONCAT21(CONCAT11(bVar19 - (char)((int)(((uint)bVar19 -

                                                                                (uint)bVar27) *

                                                                               iVar11) / iVar9),

                                                          bVar18 - (char)((int)(((uint)bVar18 -

                                                                                (uint)bVar26) *

                                                                               iVar11) / iVar9)),

                                                 (char)local_48 -

                                                 (char)((int)(((uVar8 & 0xff) - (uVar7 & 0xff)) *

                                                             iVar11) / iVar9)));

                    uVar4 = local_48;

                  }

                }

              }

              *(undefined4 *)(iVar10 + iVar13 * 4) = uVar4;

            }

          } while (iVar13 != 0);

        }

        iVar10 = iVar10 - iVar2;

        local_30 = local_30 + -1;

      } while (local_30 != 0);

    }

  }

  else {

    iVar10 = *(int *)(in_EAX + 0x14);

    iVar5 = (uint)*(byte *)(in_EAX + 0x24) + (uint)(*(byte *)(in_EAX + 0x24) != 0);

    local_2c = *(int *)(in_EAX + 0x20);

    if (local_2c != 0) {

      iVar2 = *(int *)(in_EAX + 0x1c);

      iVar13 = *(int *)(in_EAX + 0xc);

      iVar11 = *(int *)(in_EAX + 0x18);

      do {

        if (iVar2 != 0) {

          puVar12 = (uint *)(iVar10 + iVar2 * 4);

          local_34 = iVar2;

          do {

            puVar1 = (uint *)((local_44 - iVar10) + -4 + (int)puVar12);

            puVar12 = puVar12 + -1;

            uVar7 = *puVar1 & 0xff000000 | DAT_008f86b0;

            uVar8 = uVar7 >> 0x18;

            if (iVar5 != 0x100) {

              uVar8 = (int)(uVar8 * iVar5) >> 8;

            }

            if (uVar8 != 0) {

              iVar9 = uVar8 + 1;

              if (iVar9 != 0x100) {

                uVar8 = *puVar12;

                local_48._3_1_ = (byte)(uVar8 >> 0x18);

                if (local_48._3_1_ != 0) {

                  bVar17 = (byte)(uVar8 >> 8);

                  bVar18 = (byte)(uVar8 >> 0x10);

                  if (local_48._3_1_ == 0xff) {

                    uVar3 = (uint)(CONCAT34((int3)(CONCAT25(0xff00,CONCAT14(bVar18,uVar8)) >> 0x20),

                                            uVar8) >> 0x18);

                    uVar21 = (uint5)uVar3 & 0xffffffff00;

                    uVar16 = (ulonglong)CONCAT43(uVar3,CONCAT12(bVar17,(ushort)uVar8)) &

                             0xffffffff00ffffff;

                    uVar14 = (ushort)uVar8 & 0xff;

                    uVar25 = (ulonglong)

                             CONCAT52(CONCAT23((short)(CONCAT14((char)(DAT_008f86b0 >> 0x10),uVar7)

                                                      >> 0x18),

                                               CONCAT12((char)(DAT_008f86b0 >> 8),

                                                        (short)DAT_008f86b0)) >> 0x10,

                                      (short)DAT_008f86b0) & 0xff00ff00ff;

                    sVar24 = (short)iVar9;

                    sVar20 = (short)(uVar16 >> 0x10);

                    sVar22 = (short)(uVar21 >> 8);

                    sVar23 = (short)(uVar21 >> 0x18);

                    sVar15 = uVar14 - (((ushort)(uVar14 * sVar24) >> 8) -

                                      ((ushort)((short)uVar25 * sVar24) >> 8));

                    sVar20 = sVar20 - (((ushort)(sVar20 * sVar24) >> 8) -

                                      ((ushort)((short)(uVar25 >> 0x10) * sVar24) >> 8));

                    sVar22 = sVar22 - (((ushort)(sVar22 * sVar24) >> 8) -

                                      ((ushort)((short)(uVar25 >> 0x20) * sVar24) >> 8));

                    sVar23 = sVar23 - (((ushort)(sVar23 * sVar24) >> 8) -

                                      ((ushort)((short)(uVar16 >> 0x30) * sVar24) >> 8));

                    uVar7 = CONCAT13((0 < sVar23) * (sVar23 < 0x100) * (char)sVar23 -

                                     (0xff < sVar23),

                                     CONCAT12((0 < sVar22) * (sVar22 < 0x100) * (char)sVar22 -

                                              (0xff < sVar22),

                                              CONCAT11((0 < sVar20) * (sVar20 < 0x100) *

                                                       (char)sVar20 - (0xff < sVar20),

                                                       (0 < sVar15) * (sVar15 < 0x100) *

                                                       (char)sVar15 - (0xff < sVar15))));

                  }

                  else {

                    iVar6 = local_48._3_1_ + 1 +

                            (iVar9 - ((int)((local_48._3_1_ + 1) * iVar9) >> 8));

                    local_48._0_1_ = (char)uVar8;

                    local_48 = CONCAT31(CONCAT12((char)iVar6 + -1,

                                                 CONCAT11(bVar18 - (char)((int)(((uint)bVar18 -

                                                                                ((DAT_008f86b0 &

                                                                                 0xff0000) >> 0x10))

                                                                               * iVar9) / iVar6),

                                                          bVar17 - (char)((int)(((uint)bVar17 -

                                                                                ((DAT_008f86b0 &

                                                                                 0xff00) >> 8)) *

                                                                               iVar9) / iVar6))),

                                        (char)local_48 -

                                        (char)((int)(((uVar8 & 0xff) - (DAT_008f86b0 & 0xff)) *

                                                    iVar9) / iVar6));

                    uVar7 = local_48;

                  }

                }

              }

              *puVar12 = uVar7;

            }

            local_34 = local_34 + -1;

          } while (local_34 != 0);

        }

        local_44 = local_44 + iVar13;

        iVar10 = iVar10 + iVar11;

        local_2c = local_2c + -1;

      } while (local_2c != 0);

    }

  }

  return;

}





// --- FUN_006704c0 at 0x006704C0 (size: 588) ---


void FUN_006704c0(void)



{

  uint *puVar1;

  byte bVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  int in_EAX;

  uint uVar6;

  undefined4 uVar7;

  uint uVar8;

  int iVar9;

  int iVar10;

  int iVar11;

  uint *puVar12;

  ushort uVar13;

  short sVar14;

  short sVar15;

  short sVar16;

  short sVar17;

  ushort uVar19;

  ulonglong uVar18;

  undefined4 local_30;

  int local_24;

  int local_1c;

  int local_18;

  

  uVar6 = DAT_008f86b0;

  local_30 = *(int *)(in_EAX + 8);

  iVar10 = *(int *)(in_EAX + 0x14);

  if (local_30 == 0) {

    bVar2 = *(byte *)(in_EAX + 0x24);

    local_30 = CONCAT13(bVar2,(int3)DAT_008f86b0);

    local_1c = *(int *)(in_EAX + 0x20);

    if (local_1c != 0) {

      iVar11 = *(int *)(in_EAX + 0x1c);

      iVar3 = *(int *)(in_EAX + 0x18);

      do {

        if (iVar11 != 0) {

          iVar9 = iVar11;

          do {

            iVar9 = iVar9 + -1;

            if (bVar2 != 0) {

              sVar14 = bVar2 + 1;

              uVar7 = local_30;

              if (sVar14 != 0x100) {

                uVar7 = *(undefined4 *)(iVar10 + iVar9 * 4);

                uVar13 = (ushort)uVar7 & 0xff;

                uVar18 = (ulonglong)

                         CONCAT52(CONCAT23((short)(CONCAT14((char)(uVar6 >> 0x10),local_30) >> 0x18)

                                           ,CONCAT12((char)(uVar6 >> 8),(short)uVar6)) >> 0x10,

                                  (short)uVar6) & 0xff00ff00ff;

                uVar19 = (ushort)(byte)((uint)uVar7 >> 8);

                sVar17 = (short)CONCAT21(0xff00,(char)((uint)uVar7 >> 0x10));

                sVar15 = uVar13 - (((ushort)(uVar13 * sVar14) >> 8) -

                                  ((ushort)((short)uVar18 * sVar14) >> 8));

                sVar16 = uVar19 - (((ushort)(uVar19 * sVar14) >> 8) -

                                  ((ushort)((short)(uVar18 >> 0x10) * sVar14) >> 8));

                sVar17 = sVar17 - (((ushort)(sVar17 * sVar14) >> 8) -

                                  ((ushort)((short)(uVar18 >> 0x20) * sVar14) >> 8));

                sVar14 = 0xff - (((ushort)(sVar14 * 0xff) >> 8) - ((ushort)(sVar14 * 0xff) >> 8));

                uVar7 = CONCAT13((0 < sVar14) * (sVar14 < 0x100) * (char)sVar14 - (0xff < sVar14),

                                 CONCAT12((0 < sVar17) * (sVar17 < 0x100) * (char)sVar17 -

                                          (0xff < sVar17),

                                          CONCAT11((0 < sVar16) * (sVar16 < 0x100) * (char)sVar16 -

                                                   (0xff < sVar16),

                                                   (0 < sVar15) * (sVar15 < 0x100) * (char)sVar15 -

                                                   (0xff < sVar15))));

              }

              *(undefined4 *)(iVar10 + iVar9 * 4) = uVar7;

            }

          } while (iVar9 != 0);

        }

        iVar10 = iVar10 - iVar3;

        local_1c = local_1c + -1;

      } while (local_1c != 0);

    }

  }

  else {

    iVar11 = (uint)*(byte *)(in_EAX + 0x24) + (uint)(*(byte *)(in_EAX + 0x24) != 0);

    local_18 = *(int *)(in_EAX + 0x20);

    if (local_18 != 0) {

      iVar3 = *(int *)(in_EAX + 0x1c);

      iVar9 = *(int *)(in_EAX + 0xc);

      iVar4 = *(int *)(in_EAX + 0x18);

      do {

        if (iVar3 != 0) {

          puVar12 = (uint *)(iVar10 + iVar3 * 4);

          local_24 = iVar3;

          do {

            puVar1 = (uint *)((int)puVar12 + (local_30 - iVar10) + -4);

            puVar12 = puVar12 + -1;

            uVar8 = *puVar1 & 0xff000000 | DAT_008f86b0;

            uVar6 = uVar8 >> 0x18;

            if (iVar11 != 0x100) {

              uVar6 = (int)(uVar6 * iVar11) >> 8;

            }

            if (uVar6 != 0) {

              if (uVar6 + 1 != 0x100) {

                uVar5 = *puVar12;

                uVar13 = (ushort)uVar5 & 0xff;

                uVar18 = (ulonglong)

                         CONCAT52(CONCAT23((short)(CONCAT14((char)(DAT_008f86b0 >> 0x10),uVar8) >>

                                                  0x18),

                                           CONCAT12((char)(DAT_008f86b0 >> 8),(short)DAT_008f86b0))

                                  >> 0x10,(short)DAT_008f86b0) & 0xff00ff00ff;

                sVar17 = (short)(uVar6 + 1);

                uVar19 = (ushort)(byte)(uVar5 >> 8);

                sVar16 = (short)CONCAT21(0xff00,(char)(uVar5 >> 0x10));

                sVar14 = uVar13 - (((ushort)(uVar13 * sVar17) >> 8) -

                                  ((ushort)((short)uVar18 * sVar17) >> 8));

                sVar15 = uVar19 - (((ushort)(uVar19 * sVar17) >> 8) -

                                  ((ushort)((short)(uVar18 >> 0x10) * sVar17) >> 8));

                sVar16 = sVar16 - (((ushort)(sVar16 * sVar17) >> 8) -

                                  ((ushort)((short)(uVar18 >> 0x20) * sVar17) >> 8));

                sVar17 = 0xff - (((ushort)(sVar17 * 0xff) >> 8) - ((ushort)(sVar17 * 0xff) >> 8));

                uVar8 = CONCAT13((0 < sVar17) * (sVar17 < 0x100) * (char)sVar17 - (0xff < sVar17),

                                 CONCAT12((0 < sVar16) * (sVar16 < 0x100) * (char)sVar16 -

                                          (0xff < sVar16),

                                          CONCAT11((0 < sVar15) * (sVar15 < 0x100) * (char)sVar15 -

                                                   (0xff < sVar15),

                                                   (0 < sVar14) * (sVar14 < 0x100) * (char)sVar14 -

                                                   (0xff < sVar14))));

              }

              *puVar12 = uVar8;

            }

            local_24 = local_24 + -1;

          } while (local_24 != 0);

        }

        local_30 = local_30 + iVar9;

        iVar10 = iVar10 + iVar4;

        local_18 = local_18 + -1;

      } while (local_18 != 0);

    }

  }

  return;

}





// --- FUN_00670710 at 0x00670710 (size: 588) ---


void FUN_00670710(void)



{

  uint *puVar1;

  byte bVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  int in_EAX;

  uint uVar6;

  undefined4 uVar7;

  uint uVar8;

  int iVar9;

  int iVar10;

  int iVar11;

  uint *puVar12;

  ushort uVar13;

  short sVar14;

  short sVar15;

  short sVar16;

  short sVar17;

  ushort uVar19;

  ulonglong uVar18;

  undefined4 local_30;

  int local_24;

  int local_1c;

  int local_18;

  

  uVar6 = DAT_008f86b0;

  local_30 = *(int *)(in_EAX + 8);

  iVar10 = *(int *)(in_EAX + 0x14);

  if (local_30 == 0) {

    bVar2 = *(byte *)(in_EAX + 0x24);

    local_30 = CONCAT13(bVar2,(int3)DAT_008f86b0);

    local_1c = *(int *)(in_EAX + 0x20);

    if (local_1c != 0) {

      iVar11 = *(int *)(in_EAX + 0x1c);

      iVar3 = *(int *)(in_EAX + 0x18);

      do {

        if (iVar11 != 0) {

          iVar9 = iVar11;

          do {

            iVar9 = iVar9 + -1;

            if (bVar2 != 0) {

              sVar14 = bVar2 + 1;

              uVar7 = local_30;

              if (sVar14 != 0x100) {

                uVar7 = *(undefined4 *)(iVar10 + iVar9 * 4);

                uVar13 = (ushort)uVar7 & 0xff;

                uVar18 = (ulonglong)

                         CONCAT52(CONCAT23((short)(CONCAT14((char)(uVar6 >> 0x10),local_30) >> 0x18)

                                           ,CONCAT12((char)(uVar6 >> 8),(short)uVar6)) >> 0x10,

                                  (short)uVar6) & 0xff00ff00ff;

                uVar19 = (ushort)(byte)((uint)uVar7 >> 8);

                sVar17 = (short)CONCAT21(0xff00,(char)((uint)uVar7 >> 0x10));

                sVar15 = uVar13 - (((ushort)(uVar13 * sVar14) >> 8) -

                                  ((ushort)((short)uVar18 * sVar14) >> 8));

                sVar16 = uVar19 - (((ushort)(uVar19 * sVar14) >> 8) -

                                  ((ushort)((short)(uVar18 >> 0x10) * sVar14) >> 8));

                sVar17 = sVar17 - (((ushort)(sVar17 * sVar14) >> 8) -

                                  ((ushort)((short)(uVar18 >> 0x20) * sVar14) >> 8));

                sVar14 = 0xff - (((ushort)(sVar14 * 0xff) >> 8) - ((ushort)(sVar14 * 0xff) >> 8));

                uVar7 = CONCAT13((0 < sVar14) * (sVar14 < 0x100) * (char)sVar14 - (0xff < sVar14),

                                 CONCAT12((0 < sVar17) * (sVar17 < 0x100) * (char)sVar17 -

                                          (0xff < sVar17),

                                          CONCAT11((0 < sVar16) * (sVar16 < 0x100) * (char)sVar16 -

                                                   (0xff < sVar16),

                                                   (0 < sVar15) * (sVar15 < 0x100) * (char)sVar15 -

                                                   (0xff < sVar15))));

              }

              *(undefined4 *)(iVar10 + iVar9 * 4) = uVar7;

            }

          } while (iVar9 != 0);

        }

        iVar10 = iVar10 - iVar3;

        local_1c = local_1c + -1;

      } while (local_1c != 0);

    }

  }

  else {

    iVar11 = (uint)*(byte *)(in_EAX + 0x24) + (uint)(*(byte *)(in_EAX + 0x24) != 0);

    local_18 = *(int *)(in_EAX + 0x20);

    if (local_18 != 0) {

      iVar3 = *(int *)(in_EAX + 0x1c);

      iVar9 = *(int *)(in_EAX + 0xc);

      iVar4 = *(int *)(in_EAX + 0x18);

      do {

        if (iVar3 != 0) {

          puVar12 = (uint *)(iVar10 + iVar3 * 4);

          local_24 = iVar3;

          do {

            puVar1 = (uint *)((local_30 - iVar10) + -4 + (int)puVar12);

            puVar12 = puVar12 + -1;

            uVar8 = *puVar1 & 0xff000000 | DAT_008f86b0;

            uVar6 = uVar8 >> 0x18;

            if (iVar11 != 0x100) {

              uVar6 = (int)(uVar6 * iVar11) >> 8;

            }

            if (uVar6 != 0) {

              if (uVar6 + 1 != 0x100) {

                uVar5 = *puVar12;

                uVar13 = (ushort)uVar5 & 0xff;

                uVar18 = (ulonglong)

                         CONCAT52(CONCAT23((short)(CONCAT14((char)(DAT_008f86b0 >> 0x10),uVar8) >>

                                                  0x18),

                                           CONCAT12((char)(DAT_008f86b0 >> 8),(short)DAT_008f86b0))

                                  >> 0x10,(short)DAT_008f86b0) & 0xff00ff00ff;

                sVar17 = (short)(uVar6 + 1);

                uVar19 = (ushort)(byte)(uVar5 >> 8);

                sVar16 = (short)CONCAT21(0xff00,(char)(uVar5 >> 0x10));

                sVar14 = uVar13 - (((ushort)(uVar13 * sVar17) >> 8) -

                                  ((ushort)((short)uVar18 * sVar17) >> 8));

                sVar15 = uVar19 - (((ushort)(uVar19 * sVar17) >> 8) -

                                  ((ushort)((short)(uVar18 >> 0x10) * sVar17) >> 8));

                sVar16 = sVar16 - (((ushort)(sVar16 * sVar17) >> 8) -

                                  ((ushort)((short)(uVar18 >> 0x20) * sVar17) >> 8));

                sVar17 = 0xff - (((ushort)(sVar17 * 0xff) >> 8) - ((ushort)(sVar17 * 0xff) >> 8));

                uVar8 = CONCAT13((0 < sVar17) * (sVar17 < 0x100) * (char)sVar17 - (0xff < sVar17),

                                 CONCAT12((0 < sVar16) * (sVar16 < 0x100) * (char)sVar16 -

                                          (0xff < sVar16),

                                          CONCAT11((0 < sVar15) * (sVar15 < 0x100) * (char)sVar15 -

                                                   (0xff < sVar15),

                                                   (0 < sVar14) * (sVar14 < 0x100) * (char)sVar14 -

                                                   (0xff < sVar14))));

              }

              *puVar12 = uVar8;

            }

            local_24 = local_24 + -1;

          } while (local_24 != 0);

        }

        local_30 = local_30 + iVar9;

        iVar10 = iVar10 + iVar4;

        local_18 = local_18 + -1;

      } while (local_18 != 0);

    }

  }

  return;

}





// --- FUN_00670960 at 0x00670960 (size: 696) ---


void FUN_00670960(void)



{

  int iVar1;

  byte bVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  ushort uVar6;

  ushort uVar7;

  int in_EAX;

  uint uVar8;

  byte *pbVar9;

  int iVar10;

  byte *pbVar11;

  int iVar12;

  int iVar13;

  short sVar14;

  short sVar15;

  short sVar16;

  ulonglong uVar17;

  uint local_30;

  undefined4 local_2c;

  int local_20;

  int local_1c;

  

  uVar8 = DAT_008f86b0;

  local_2c = *(int *)(in_EAX + 8);

  if (local_2c == 0) {

    bVar2 = *(byte *)(in_EAX + 0x24);

    iVar12 = *(int *)(in_EAX + 0x14);

    local_2c = CONCAT13(bVar2,(int3)DAT_008f86b0);

    local_1c = *(int *)(in_EAX + 0x20);

    if (local_1c != 0) {

      iVar10 = *(int *)(in_EAX + 0x18);

      iVar3 = *(int *)(in_EAX + 0x1c);

      do {

        if (iVar3 != 0) {

          pbVar9 = (byte *)(iVar3 * 3 + 2 + iVar12);

          local_20 = iVar3;

          do {

            pbVar11 = pbVar9 + -3;

            if (bVar2 != 0) {

              sVar14 = bVar2 + 1;

              if (sVar14 == 0x100) {

                local_30 = local_2c;

              }

              else {

                uVar7 = *(ushort *)(pbVar9 + -5);

                uVar6 = (ushort)(((uint5)*pbVar11 << 0x20) >> 0x18);

                uVar17 = (ulonglong)

                         CONCAT52(CONCAT23((short)(CONCAT14((char)(uVar8 >> 0x10),local_2c) >> 0x18)

                                           ,CONCAT12((char)(uVar8 >> 8),(short)uVar8)) >> 0x10,

                                  (short)uVar8) & 0xff00ff00ff;

                sVar16 = (short)(CONCAT23(uVar6,CONCAT12((char)(uVar7 >> 8),uVar7)) >> 0x10);

                uVar6 = uVar6 >> 8;

                sVar15 = (uVar7 & 0xff) -

                         (((ushort)((uVar7 & 0xff) * sVar14) >> 8) -

                         ((ushort)((short)uVar17 * sVar14) >> 8));

                sVar16 = sVar16 - (((ushort)(sVar16 * sVar14) >> 8) -

                                  ((ushort)((short)(uVar17 >> 0x10) * sVar14) >> 8));

                sVar14 = uVar6 - (((ushort)(uVar6 * sVar14) >> 8) -

                                 ((ushort)((short)(uVar17 >> 0x20) * sVar14) >> 8));

                local_30 = (uint)CONCAT12((0 < sVar14) * (sVar14 < 0x100) * (char)sVar14 -

                                          (0xff < sVar14),

                                          CONCAT11((0 < sVar16) * (sVar16 < 0x100) * (char)sVar16 -

                                                   (0xff < sVar16),

                                                   (0 < sVar15) * (sVar15 < 0x100) * (char)sVar15 -

                                                   (0xff < sVar15)));

              }

              pbVar9[-5] = (byte)local_30;

              pbVar9[-4] = (byte)(local_30 >> 8);

              *pbVar11 = (byte)(local_30 >> 0x10);

            }

            local_20 = local_20 + -1;

            pbVar9 = pbVar11;

          } while (local_20 != 0);

        }

        iVar12 = iVar12 - iVar10;

        local_1c = local_1c + -1;

      } while (local_1c != 0);

    }

  }

  else {

    iVar12 = *(int *)(in_EAX + 0x14);

    iVar10 = (uint)*(byte *)(in_EAX + 0x24) + (uint)(*(byte *)(in_EAX + 0x24) != 0);

    local_20 = *(int *)(in_EAX + 0x20);

    if (local_20 != 0) {

      iVar3 = *(int *)(in_EAX + 0x1c);

      iVar4 = *(int *)(in_EAX + 0xc);

      iVar5 = *(int *)(in_EAX + 0x18);

      do {

        if (iVar3 != 0) {

          pbVar9 = (byte *)(iVar3 * 3 + 2 + iVar12);

          iVar13 = iVar3;

          do {

            iVar1 = iVar13 * 4;

            iVar13 = iVar13 + -1;

            local_30 = *(uint *)(local_2c + -4 + iVar1) & 0xff000000 | DAT_008f86b0;

            pbVar11 = pbVar9 + -3;

            uVar8 = local_30 >> 0x18;

            if (iVar10 != 0x100) {

              uVar8 = (int)(uVar8 * iVar10) >> 8;

            }

            if (uVar8 != 0) {

              if (uVar8 + 1 != 0x100) {

                uVar7 = *(ushort *)(pbVar9 + -5);

                uVar6 = (ushort)(((uint5)*pbVar11 << 0x20) >> 0x18);

                uVar17 = (ulonglong)

                         CONCAT52(CONCAT23((short)(CONCAT14((char)(DAT_008f86b0 >> 0x10),local_30)

                                                  >> 0x18),

                                           CONCAT12((char)(DAT_008f86b0 >> 8),(short)DAT_008f86b0))

                                  >> 0x10,(short)DAT_008f86b0) & 0xff00ff00ff;

                sVar16 = (short)(uVar8 + 1);

                sVar15 = (short)(CONCAT23(uVar6,CONCAT12((char)(uVar7 >> 8),uVar7)) >> 0x10);

                uVar6 = uVar6 >> 8;

                sVar14 = (uVar7 & 0xff) -

                         (((ushort)((uVar7 & 0xff) * sVar16) >> 8) -

                         ((ushort)((short)uVar17 * sVar16) >> 8));

                sVar15 = sVar15 - (((ushort)(sVar15 * sVar16) >> 8) -

                                  ((ushort)((short)(uVar17 >> 0x10) * sVar16) >> 8));

                sVar16 = uVar6 - (((ushort)(uVar6 * sVar16) >> 8) -

                                 ((ushort)((short)(uVar17 >> 0x20) * sVar16) >> 8));

                local_30 = (uint)CONCAT12((0 < sVar16) * (sVar16 < 0x100) * (char)sVar16 -

                                          (0xff < sVar16),

                                          CONCAT11((0 < sVar15) * (sVar15 < 0x100) * (char)sVar15 -

                                                   (0xff < sVar15),

                                                   (0 < sVar14) * (sVar14 < 0x100) * (char)sVar14 -

                                                   (0xff < sVar14)));

              }

              pbVar9[-5] = (byte)local_30;

              pbVar9[-4] = (byte)(local_30 >> 8);

              *pbVar11 = (byte)(local_30 >> 0x10);

            }

            pbVar9 = pbVar11;

          } while (iVar13 != 0);

        }

        local_2c = local_2c + iVar4;

        iVar12 = iVar12 + iVar5;

        local_20 = local_20 + -1;

      } while (local_20 != 0);

    }

  }

  return;

}





// --- FUN_00670e60 at 0x00670E60 (size: 17) ---


void __fastcall FUN_00670e60(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007febfc;

  param_1[1] = 0;

  param_1[2] = 0;

  return;

}





// --- FUN_00670e80 at 0x00670E80 (size: 20) ---


void __thiscall FUN_00670e80(int param_1,undefined4 param_2,undefined4 param_3)



{

  *(undefined4 *)(param_1 + 8) = param_2;

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

  *(undefined4 *)(param_1 + 0x10) = param_3;

  return;

}





// --- FUN_00670eb0 at 0x00670EB0 (size: 15) ---


void __fastcall FUN_00670eb0(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007febfc;

  param_1[1] = 0;

  param_1[2] = 0;

  return;

}





// --- FUN_00670f20 at 0x00670F20 (size: 157) ---


void __fastcall FUN_00670f20(int param_1)



{

  bool bVar1;

  uint uVar2;

  uint uVar3;

  

  if (*(char *)(param_1 + 0x10) == '\0') {

    if (*(size_t *)(param_1 + 0xc) != 0) {

      qsort(*(void **)(param_1 + 4),*(size_t *)(param_1 + 0xc),4,(_PtFuncCompare *)&LAB_00670ef0);

      bVar1 = false;

      uVar2 = *(uint *)(param_1 + 0xc) - 1;

      if (1 < *(uint *)(param_1 + 0xc)) {

        do {

          if (*(int *)(*(int *)(param_1 + 4) + uVar2 * 4) ==

              *(int *)(*(int *)(param_1 + 4) + -4 + uVar2 * 4)) {

            if (uVar2 < *(uint *)(param_1 + 0xc)) {

              uVar3 = *(uint *)(param_1 + 0xc) - 1;

              *(uint *)(param_1 + 0xc) = uVar3;

              if (uVar2 != uVar3) {

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

                     *(undefined4 *)(*(int *)(param_1 + 4) + uVar3 * 4);

                *(undefined4 *)(*(int *)(param_1 + 4) + *(int *)(param_1 + 0xc) * 4) = 0;

              }

            }

            bVar1 = true;

          }

          uVar2 = uVar2 - 1;

        } while (uVar2 != 0);

        if (bVar1) {

          qsort(*(void **)(param_1 + 4),*(size_t *)(param_1 + 0xc),4,(_PtFuncCompare *)&LAB_00670ef0

               );

        }

      }

    }

    *(undefined1 *)(param_1 + 0x10) = 1;

  }

  return;

}





// --- FUN_00670fc0 at 0x00670FC0 (size: 24) ---


void __fastcall FUN_00670fc0(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007fec04;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  *(undefined1 *)(param_1 + 4) = 1;

  return;

}





// --- FUN_00670fe0 at 0x00670FE0 (size: 91) ---


undefined1 __thiscall FUN_00670fe0(int *param_1,uint param_2,char param_3)



{

  char cVar1;

  uint uVar2;

  

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

    uVar2 = param_2;

    if (param_3 == '\0') {

      uVar2 = FUN_00453850(param_2);

    }

    cVar1 = FUN_004180a0(uVar2);

    if (cVar1 == '\0') {

      return 0;

    }

  }

  else {

    uVar2 = param_2;

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

      do {

        *(undefined4 *)(*param_1 + uVar2 * 4) = 0;

        uVar2 = uVar2 + 1;

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

    }

  }

  param_1[2] = param_2;

  return 1;

}





// --- FUN_00671280 at 0x00671280 (size: 65) ---


undefined4 __thiscall FUN_00671280(int param_1,undefined4 param_2)



{

  char cVar1;

  uint uVar2;

  undefined4 uVar3;

  

  *(undefined1 *)(param_1 + 0x10) = 0;

  uVar2 = *(uint *)(param_1 + 8) & 0x7fffffff;

  if (uVar2 <= *(uint *)(param_1 + 0xc)) {

    uVar3 = FUN_00453850(uVar2 + 1);

    cVar1 = FUN_004180a0(uVar3);

    if (cVar1 == '\0') {

      return 1;

    }

  }

  *(undefined4 *)(*(int *)(param_1 + 4) + *(int *)(param_1 + 0xc) * 4) = param_2;

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

  return 1;

}





// --- FUN_006712d0 at 0x006712D0 (size: 66) ---


void __fastcall FUN_006712d0(undefined4 *param_1)



{

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  *(undefined1 *)(param_1 + 0xb) = 0;

  *param_1 = 0x5442;

  param_1[0xc] = DAT_008f86b4;

  param_1[0xd] = 0xffffffff;

  param_1[0xe] = 0xffffffff;

  FUN_00413960();

  return;

}





// --- FUN_00671320 at 0x00671320 (size: 18) ---


undefined4 FUN_00671320(undefined4 param_1)



{

  FUN_00413980();

  return param_1;

}





// --- FUN_00671360 at 0x00671360 (size: 61) ---


char __fastcall FUN_00671360(int param_1)



{

  int iVar1;

  char cVar2;

  

  cVar2 = '\0';

  if (*(char *)(param_1 + 4) != '\0') {

    if (*(char *)(param_1 + 5) == '\0') {

      FUN_00673220();

    }

    iVar1 = FUN_00674e50();

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

    FUN_00672f60();

    *(undefined1 *)(param_1 + 4) = 0;

  }

  return cVar2;

}





// --- FUN_006713b0 at 0x006713B0 (size: 45) ---


void __thiscall FUN_006713b0(int param_1,undefined4 param_2)



{

  if (*(char *)(param_1 + 5) == '\0') {

    FUN_004139a0(param_2);

    if (*(char *)(param_1 + 4) != '\0') {

      FUN_00673220();

    }

  }

  return;

}





// --- FUN_006713e0 at 0x006713E0 (size: 84) ---


undefined4 * __fastcall FUN_006713e0(undefined4 *param_1)



{

  FUN_00413980();

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  *(undefined1 *)(param_1 + 0xb) = 0;

  *param_1 = 0x5442;

  param_1[0xc] = DAT_008f86b4;

  param_1[0xd] = 0xffffffff;

  param_1[0xe] = 0xffffffff;

  FUN_00413960();

  return param_1;

}





// --- FUN_00671440 at 0x00671440 (size: 107) ---


void FUN_00671440(void)



{

  int iVar1;

  int iVar2;

  undefined4 uVar3;

  undefined1 local_c [12];

  

  iVar1 = FUN_00406d80();

  iVar2 = FUN_00406d80();

  if (iVar2 == iVar1 + 4) {

    iVar1 = FUN_00406db0();

    FUN_004074b0(iVar1 + 4,1);

    iVar1 = FUN_00406db0();

    uVar3 = FUN_00407140(local_c,0,iVar1 + 4);

    FUN_004070d0(uVar3);

    FUN_00406f90();

  }

  return;

}





// --- FUN_00671730 at 0x00671730 (size: 80) ---


undefined4 __thiscall FUN_00671730(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  

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

  iVar2 = *(int *)(param_1 + 0x71c);

  while (iVar2 <= param_2 / (iVar1 + -4) + 0x33) {

    if (*(char *)(param_1 + 6) == '\0') {

      FUN_00674b70();

    }

    else {

      FUN_00675040(0x100000);

    }

    iVar2 = *(int *)(param_1 + 0x71c);

  }

  return 1;

}





// --- FUN_00671780 at 0x00671780 (size: 73) ---


uint __thiscall FUN_00671780(int *param_1,undefined4 param_2)



{

  char cVar1;

  uint local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  local_14 = DAT_008f86b4;

  local_18 = 0;

  local_10 = 0;

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  cVar1 = (**(code **)(*param_1 + 0x74))(param_2,&DAT_008f86b8,&local_18,2);

  return -(uint)(cVar1 != '\0') & local_18;

}





// --- FUN_00671930 at 0x00671930 (size: 232) ---


undefined4 __thiscall FUN_00671930(int *param_1,undefined4 param_2)



{

  undefined4 uVar1;

  char cVar2;

  int iVar3;

  undefined4 uStack_3c;

  byte abStack_28 [12];

  undefined4 uStack_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  uStack_3c = 2;

  local_14 = DAT_008f86b4;

  local_18 = 0;

  local_10 = 0;

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  cVar2 = (**(code **)(*param_1 + 0x74))(param_2,&DAT_008f86b8,&local_18);

  if (cVar2 != '\0') {

    if ((abStack_28[0] & 1) == 0) {

      return uStack_1c;

    }

    uStack_3c = 0;

    FUN_00406d60();

    FUN_004074b0(8,1);

    FUN_00406db0();

    cVar2 = (**(code **)(*param_1 + 0x74))(param_2,&uStack_3c,abStack_28,5);

    if (cVar2 != '\0') {

      FUN_004074b0(4,1);

      iVar3 = FUN_00406d80();

      uVar1 = *(undefined4 *)(iVar3 + 4);

      FUN_00406f90();

      FUN_00406f90();

      return uVar1;

    }

    FUN_00406f90();

    FUN_00406f90();

  }

  return 0xffffffff;

}





// --- FUN_00671b60 at 0x00671B60 (size: 331) ---


undefined4 FUN_00671b60(undefined4 param_1,int param_2,byte *param_3,byte param_4)



{

  char cVar1;

  undefined4 *puVar2;

  int iVar3;

  byte *pbVar4;

  bool bVar5;

  undefined4 local_20;

  undefined4 local_1c;

  int *local_18;

  undefined1 local_14 [20];

  

  local_20 = 0;

  puVar2 = (undefined4 *)FUN_006747a0(param_1,&local_20);

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

    return 0;

  }

  pbVar4 = param_3;

  for (iVar3 = 6; iVar3 != 0; iVar3 = iVar3 + -1) {

    *(undefined4 *)pbVar4 = *puVar2;

    puVar2 = puVar2 + 1;

    pbVar4 = pbVar4 + 4;

  }

  if ((param_4 & 2) == 0) {

    bVar5 = (param_4 & 5) == 5;

    local_1c = *(undefined4 *)(param_3 + 8);

    *(uint *)(param_2 + 4) = (uint)*(ushort *)(param_3 + 2);

    if (!bVar5) {

      FUN_004074b0(*(int *)(param_3 + 0xc) + 4,1);

      FUN_00406db0();

    }

    cVar1 = FUN_00675480(param_2,local_1c,bVar5);

    if (cVar1 == '\0') {

      FUN_00406f90();

      return 0;

    }

    if (((char)local_18[0x1cb] != '\0') && (*(char *)((int)local_18 + 5) == '\0')) {

      FUN_00672ea0(param_1);

    }

    if ((((*param_3 & 1) != 0) && ((param_4 & 1) == 0)) && (!bVar5)) {

      FUN_00417600();

      cVar1 = (**(code **)(*local_18 + 0x88))(param_2,local_14);

      if (cVar1 == '\0') {

        FUN_00406f90();

        FUN_00406f90();

        return 0;

      }

      FUN_004176a0(&local_1c);

      FUN_00406f90();

      FUN_00406f90();

    }

  }

  return 1;

}





// --- FUN_00671d00 at 0x00671D00 (size: 63) ---


uint __thiscall FUN_00671d00(int param_1,undefined4 param_2,int param_3)



{

  undefined4 in_EAX;

  uint uVar1;

  

  uVar1 = CONCAT31((int3)((uint)in_EAX >> 8),*(char *)(param_1 + 5));

  if (*(char *)(param_1 + 5) == '\0') {

    uVar1 = FUN_006747a0(param_2,0);

    if ((uVar1 != 0) && ((param_3 == 0 || (*(int *)(uVar1 + 0x14) <= param_3)))) {

      uVar1 = FUN_00674af0(param_2);

      return uVar1;

    }

  }

  return uVar1 & 0xffffff00;

}





// --- FUN_00671d80 at 0x00671D80 (size: 254) ---


uint __fastcall FUN_00671d80(int *param_1)



{

  char cVar1;

  undefined4 uVar2;

  uint uVar3;

  int iStack_3c;

  undefined4 local_38;

  undefined4 local_34;

  undefined **ppuStack_2c;

  undefined4 uStack_28;

  undefined4 uStack_24;

  undefined4 uStack_14;

  undefined4 uStack_10;

  undefined4 uStack_c;

  undefined4 *puStack_4;

  

  local_38 = 0;

  local_34 = 0;

  FUN_00406d60();

  cVar1 = (**(code **)(*param_1 + 0xc))(DAT_008343b8,&local_38);

  if ((cVar1 != '\0') && (iStack_3c == 1)) {

    FUN_004074b0(4,1);

    FUN_00407390(&stack0xffffffb4,4);

    ppuStack_2c = &PTR_FUN_00793b3c;

    uStack_28 = 0;

    uStack_24 = 0;

    FUN_00406d60();

    uStack_14 = 0;

    uStack_10 = 0;

    uStack_c = 0;

    ppuStack_2c = &PTR_FUN_00793b50;

    FUN_0040b020(&PTR_PTR_008183b8,&stack0xffffffb4);

    FUN_00406f90();

    (**(code **)*puStack_4)(&ppuStack_2c);

    uVar3 = (uint)ppuStack_2c >> 2;

    FUN_0040b060();

    FUN_00406f90();

    uVar2 = FUN_00406f90();

    return CONCAT31((int3)((uint)uVar2 >> 8),~(byte)uVar3) & 0xffffff01;

  }

  FUN_00406f90();

  uVar3 = FUN_00406f90();

  return uVar3 & 0xffffff00;

}





// --- FUN_00671f80 at 0x00671F80 (size: 85) ---


undefined4 * __fastcall FUN_00671f80(undefined4 *param_1)



{

  LONG *lpAddend;

  

  *(undefined1 *)(param_1 + 1) = 0;

  *(undefined1 *)((int)param_1 + 5) = 0;

  *(undefined1 *)((int)param_1 + 6) = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  *param_1 = &PTR_LAB_007fec68;

  FUN_00674e20();

  FUN_00672f10(param_1 + 4);

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

  param_1[0x1bf] = PTR_DAT_00818344;

  InterlockedIncrement(lpAddend);

  FUN_006713e0();

  return param_1;

}





// --- FUN_00671fe0 at 0x00671FE0 (size: 123) ---


void __fastcall FUN_00671fe0(undefined4 *param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  *param_1 = &PTR_LAB_007fec68;

  if (*(char *)(param_1 + 1) != '\0') {

    if (*(char *)((int)param_1 + 5) == '\0') {

      FUN_00673220();

    }

    FUN_00674e50();

    FUN_00672f60();

    *(undefined1 *)(param_1 + 1) = 0;

  }

  FUN_00695670();

  puVar2 = (undefined4 *)(param_1[0x1bf] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(param_1[0x1bf] + -0x10));

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

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

  }

  FUN_00672f60();

  FUN_00674e40();

  *param_1 = &PTR_LAB_007fec08;

  return;

}





// --- FUN_00672060 at 0x00672060 (size: 537) ---


char __thiscall FUN_00672060(int *param_1,uint *param_2,undefined4 *param_3,uint param_4)



{

  uint uVar1;

  char cVar2;

  uint uVar3;

  uint *puVar4;

  uint uVar5;

  int iVar6;

  char cVar7;

  uint uVar8;

  int local_18;

  undefined4 local_14;

  undefined4 local_10;

  

  uVar1 = param_2[1];

  cVar7 = '\0';

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

  local_14 = *param_3;

  local_10 = param_3[1];

  FUN_004070d0(param_3 + 2);

  uVar8 = param_4 & 7;

  if (((*(char *)((int)param_1 + 5) != '\0') || (DAT_008f86b4 == uVar1)) ||

     (*(short *)((int)param_2 + 2) == 0)) goto switchD_00672107_default;

  *param_2 = *param_2 & 0xfffffffe;

  if (param_2[4] == 0) {

    uVar3 = FUN_0040fa90();

    param_2[4] = uVar3;

  }

  switch(uVar8) {

  case 1:

  case 5:

    break;

  case 2:

    FUN_00406f90();

    cVar2 = (**(code **)(*param_1 + 0x84))(param_3,&local_14);

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

    FUN_004176a0(param_3);

    break;

  case 3:

switchD_00672107_caseD_3:

    *param_2 = *param_2 | 1;

    break;

  case 4:

    FUN_00406f90();

    cVar2 = (**(code **)(*param_1 + 0x88))(param_3,&local_14);

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

    break;

  default:

    goto switchD_00672107_default;

  }

  uVar3 = FUN_00417640();

  param_2[3] = uVar3;

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

    puVar4 = (uint *)FUN_00417620();

    uVar3 = *puVar4;

    uVar5 = FUN_00417640();

    if ((uVar5 < 0x10) || (uVar5 = FUN_00417640(), uVar3 < uVar5)) {

switchD_00672107_default:

      FUN_00406f90();

      FUN_00406f90();

      return '\0';

    }

  }

  if (uVar8 != 5) {

    if ((param_4 & 8) != 0) {

      FUN_004176a0(&local_14);

      param_3[1] = (uint)*(ushort *)((int)param_2 + 2);

    }

    cVar2 = FUN_00671730(param_2[3]);

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

  }

  iVar6 = FUN_006747a0(uVar1,&local_18);

  if (uVar8 == 5) {

    param_2[3] = 0xfffffffe;

  }

  if (iVar6 == 0) {

    iVar6 = FUN_00674350(param_2,&local_14);

  }

  else {

    if ((param_2[5] != 0) && ((int)param_2[5] < *(int *)(iVar6 + 0x14))) {

      cVar7 = '\x01';

      goto LAB_0067223d;

    }

    param_2[2] = *(uint *)(local_18 + 0x10);

    iVar6 = FUN_006742c0(local_18,param_2,&local_14);

  }

  cVar7 = '\x01' - (iVar6 != 0);

LAB_0067223d:

  FUN_00406f90();

  FUN_00406f90();

  return cVar7;

}





// --- FUN_006722b0 at 0x006722B0 (size: 277) ---


undefined1 __thiscall FUN_006722b0(int *param_1,uint param_2,uint param_3)



{

  bool bVar1;

  undefined1 uVar2;

  uint uVar3;

  uint uVar4;

  int iVar5;

  int local_c;

  uint local_8;

  uint local_4;

  

  if (*(char *)((int)param_1 + 5) != '\0') {

    return 0;

  }

  iVar5 = 0;

  if (param_3 == 0) {

    return 1;

  }

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  bVar1 = true;

  if ((int)param_3 < 0) {

    uVar4 = DAT_008f86b4;

    uVar3 = param_3;

    do {

      if ((uVar4 != 0) && ((param_3 & 1) == 0)) {

        bVar1 = false;

      }

      uVar3 = uVar3 >> 1;

      uVar4 = param_3 & 1;

    } while (uVar3 != 0);

  }

  param_2 = param_2 & param_3;

  if (bVar1) {

    FUN_00674de0(&local_c,param_2,~param_3 | param_2);

  }

  else {

    FUN_00674dc0(&local_c);

  }

  uVar2 = 0;

  if (local_4 != 0) {

    uVar4 = 0;

    do {

      uVar3 = *(uint *)(iVar5 + 4 + local_c);

      if ((uVar3 & param_3) == param_2) {

        (**(code **)(*param_1 + 0x14))(uVar3,0);

        uVar2 = 1;

      }

      uVar4 = uVar4 + 1;

      iVar5 = iVar5 + 0x18;

    } while (uVar4 < local_4);

  }

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

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

  }

  return uVar2;

}





// --- FUN_006723d0 at 0x006723D0 (size: 530) ---


bool __thiscall FUN_006723d0(int *param_1,int param_2)



{

  undefined4 uVar1;

  bool bVar2;

  int iVar3;

  void *local_18;

  undefined1 local_14 [4];

  void *pvStack_10;

  uint uStack_c;

  

  if ((char)param_1[1] != '\0') {

    return false;

  }

  *(bool *)((int)param_1 + 5) = ((byte)*(undefined4 *)(param_2 + 0x10) & 4) == 4;

  *(bool *)((int)param_1 + 6) = ((byte)*(undefined4 *)(param_2 + 0x10) & 2) == 2;

  if (((byte)*(undefined4 *)(param_2 + 0x10) & 8) == 8) {

LAB_006724e5:

    FUN_006712d0();

    param_1[0x1c1] = *(int *)(param_2 + 0x18);

    param_1[0x1c2] = *(int *)(param_2 + 0x14);

    param_1[0x1c3] = *(int *)(param_2 + 8);

    param_1[0x1c4] = *(int *)(param_2 + 0xc);

    *(undefined1 *)(param_1 + 0x1cb) = 0;

    param_1[0x1cd] = *(int *)(param_2 + 0x1c);

    param_1[0x1ce] = *(int *)(param_2 + 0x20);

    iVar3 = FUN_00675780(param_1 + 0x1c0,param_2,param_2 + 4,*(uint *)(param_2 + 0x10) | 8);

    if (iVar3 == 0) {

      iVar3 = FUN_00672fb0(param_1 + 0x1c0);

      if (iVar3 == 0) {

        iVar3 = FUN_00674e70();

        if (iVar3 == 0) {

          FUN_00670fc0();

          (**(code **)(*param_1 + 0x2c))(local_14);

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

            operator_delete__(pvStack_10);

          }

          goto LAB_006725a9;

        }

      }

    }

  }

  else {

    local_18 = (void *)0x0;

    iVar3 = FUN_00675920(param_1 + 0x1c0,param_2,param_2 + 4,*(undefined4 *)(param_2 + 0x10),

                         &local_18);

    *(undefined1 *)(param_1 + 0x1cb) = 0;

    uVar1 = *(undefined4 *)(param_2 + 0x10);

    bVar2 = false;

    if (iVar3 == 0) {

      *(int *)(param_2 + 8) = param_1[0x1c3];

      *(int *)(param_2 + 0xc) = param_1[0x1c4];

      if (((-1 < *(int *)(param_2 + 0x1c)) && (*(int *)(param_2 + 0x1c) != param_1[0x1cd])) ||

         ((-1 < *(int *)(param_2 + 0x20) &&

          ((*(char *)(param_2 + 0x24) == '\0' && (*(int *)(param_2 + 0x20) != param_1[0x1ce])))))) {

        iVar3 = -6;

        goto LAB_006724bf;

      }

      iVar3 = FUN_006730f0(param_1 + 0x1c0);

      if (iVar3 != 0) goto LAB_006724bf;

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

        iVar3 = FUN_00673fc0(local_18);

        if (iVar3 != 0) goto LAB_006724bf;

      }

    }

    else {

LAB_006724bf:

      if (((byte)uVar1 & 0x10) == 0x10) {

        bVar2 = true;

      }

    }

    operator_delete(local_18);

    if (bVar2) goto LAB_006724e5;

    if (iVar3 == 0) goto LAB_006725a9;

  }

  FUN_00674e50();

LAB_006725a9:

  param_1[3] = param_1[0x1c4];

  param_1[2] = param_1[0x1c3];

  FUN_00402070(param_2);

  *(bool *)(param_1 + 1) = iVar3 == 0;

  return iVar3 == 0;

}





// --- FUN_006725f0 at 0x006725F0 (size: 116) ---


undefined1 __thiscall FUN_006725f0(int *param_1,uint param_2,char param_3)



{

  int iVar1;

  char cVar2;

  uint uVar3;

  undefined4 *puVar4;

  

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

    uVar3 = param_2;

    if (param_3 == '\0') {

      uVar3 = FUN_00453850(param_2);

    }

    cVar2 = FUN_0044b740(uVar3);

    if (cVar2 == '\0') {

      return 0;

    }

  }

  else if (param_2 < (uint)param_1[2]) {

    puVar4 = (undefined4 *)FUN_0050a140();

    uVar3 = param_2;

    do {

      iVar1 = *param_1;

      *(undefined4 *)(iVar1 + uVar3 * 8) = *puVar4;

      *(undefined4 *)(iVar1 + 4 + uVar3 * 8) = puVar4[1];

      uVar3 = uVar3 + 1;

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

  }

  param_1[2] = param_2;

  return 1;

}





// --- FUN_00672670 at 0x00672670 (size: 215) ---


void FUN_00672670(int *param_1,int param_2,int param_3)



{

  undefined4 *puVar1;

  int *piVar2;

  int *piVar3;

  undefined4 *puVar4;

  int iVar5;

  int iVar6;

  

  piVar2 = param_1;

  param_1 = (int *)param_1[2];

  FUN_0040ad10(4);

  piVar3 = (int *)FUN_0040acf0(4);

  if (piVar3 != (int *)0x0) {

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

      param_1 = (int *)*piVar3;

    }

    else {

      *piVar3 = (int)param_1;

    }

  }

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

    FUN_006725f0(param_1,1);

  }

  iVar6 = 0;

  if (0 < (int)param_1) {

    do {

      puVar1 = (undefined4 *)(*piVar2 + 4 + iVar6 * 8);

      FUN_0040ad10(4);

      puVar4 = (undefined4 *)FUN_0040acf0(4);

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

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

          *puVar1 = *puVar4;

        }

        else {

          *puVar4 = *puVar1;

        }

      }

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

        if (param_2 == 2) {

LAB_00672703:

          iVar5 = 1;

        }

        else {

          iVar5 = FUN_0041c280(*(undefined4 *)(*piVar2 + 4 + iVar6 * 8));

          if (iVar5 == 0) {

            if (param_2 == 1) {

              iVar5 = 6;

            }

            else {

              if (param_2 == 2) goto LAB_00672703;

              if (param_2 == 3) {

                iVar5 = 0x25;

              }

            }

          }

        }

        *(int *)(*piVar2 + iVar6 * 8) = iVar5;

      }

      iVar6 = iVar6 + 1;

    } while (iVar6 < (int)param_1);

  }

  return;

}





// --- FUN_006727f0 at 0x006727F0 (size: 25) ---


int * __thiscall FUN_006727f0(int *param_1,int *param_2)



{

  int iVar1;

  

  iVar1 = *param_1;

  *param_2 = iVar1;

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

  return param_2;

}





// --- FUN_00672810 at 0x00672810 (size: 236) ---


undefined4 __thiscall FUN_00672810(int *param_1,int *param_2,int *param_3)



{

  int *piVar1;

  int *piVar2;

  HANDLE hObject;

  LONG LVar3;

  int iVar4;

  

  piVar2 = param_3;

  piVar1 = param_2;

  if (*(int *)(*param_2 + -4) == 1) {

    return 0;

  }

  iVar4 = *(int *)(*param_3 + -4);

  if (iVar4 == 1) {

LAB_00672845:

    if (*(int *)(*param_1 + -4) == 1) {

      return 0;

    }

    param_2 = param_1;

    if (iVar4 == 1) goto LAB_00672854;

  }

  else {

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

      return 0;

    }

    if (iVar4 == 1) goto LAB_00672845;

  }

  param_2 = param_3;

LAB_00672854:

  param_2 = (int *)*param_2;

  InterlockedIncrement((LONG *)((int)param_2 + -0x10));

  FUN_0040cc80(&param_2,piVar1);

  iVar4 = 0x80;

  hObject = (HANDLE)(*(code *)PTR_FUN_00837374)(param_2,0x80000000,3,0,3,0x80,0);

  if (hObject == (HANDLE)0xffffffff) {

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

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

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

    }

    return 0;

  }

  CloseHandle(hObject);

  if (*(int *)(*param_1 + -4) == 1) {

    FUN_00402070(piVar2);

  }

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

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

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

  }

  return 1;

}





// --- FUN_00672900 at 0x00672900 (size: 620) ---


char __thiscall FUN_00672900(int *param_1,int param_2,int param_3,undefined *param_4)



{

  undefined *puVar1;

  char cVar2;

  LONG LVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  LONG *lpAddend;

  undefined4 *puVar6;

  undefined4 uVar7;

  char local_d;

  undefined1 auStack_c [4];

  undefined1 auStack_8 [8];

  

  if (*(int *)(param_2 + -4) == 1) {

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

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

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

      (**(code **)*puVar6)(1);

    }

    puVar6 = (undefined4 *)(param_3 + -0x14);

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

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

      (**(code **)*puVar6)(1);

    }

    return '\0';

  }

  puVar1 = (undefined *)*param_1;

  if (puVar1 != PTR_DAT_00818340) {

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

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

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

    }

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

    *param_1 = (int)PTR_DAT_00818340;

    InterlockedIncrement(lpAddend);

  }

  local_d = '\0';

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

    local_d = FUN_00672810(&param_2,&param_3);

    if (local_d != '\0') goto LAB_00672b24;

  }

  if ((char)param_4 == '\0') goto LAB_00672b24;

  FUN_00408ec0(0x106);

  param_4 = PTR_DAT_00818344;

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

  FUN_00408d90(0x105);

  cVar2 = FUN_0040db30(&param_4);

  if (cVar2 == '\0') {

LAB_00672a4b:

    FUN_00402730(L"PROJECT_DAT");

    cVar2 = FUN_0040c270(auStack_c,&param_3);

    FUN_004011b0();

    if (cVar2 != '\0') {

      local_d = FUN_00672810(&param_2,&param_3);

      if (local_d != '\0') goto LAB_00672b07;

    }

    if ((*(int *)(param_1[1] + -4) != 1) && (*(int *)(param_1[2] + -4) != 1)) {

      uVar7 = 0x80000002;

      puVar6 = &param_3;

      uVar4 = FUN_00403350(auStack_8,0);

      uVar5 = FUN_00403350(auStack_c,0);

      cVar2 = FUN_0040e2e0(uVar5,uVar4,puVar6,uVar7);

      FUN_004011b0();

      FUN_004011b0();

      if (cVar2 != '\0') {

        local_d = FUN_00672810(&param_2,&param_3);

      }

    }

  }

  else {

    uVar4 = FUN_00403350(auStack_c,0);

    FUN_00402070(uVar4);

    FUN_004011b0();

    local_d = FUN_00672810(&param_2,&param_3);

    if (local_d == '\0') goto LAB_00672a4b;

  }

LAB_00672b07:

  puVar6 = (undefined4 *)(param_4 + -0x14);

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

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

    (**(code **)*puVar6)(1);

  }

LAB_00672b24:

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

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

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

    (**(code **)*puVar6)(1);

  }

  puVar6 = (undefined4 *)(param_3 + -0x14);

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

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

    (**(code **)*puVar6)(1);

  }

  return local_d;

}





// --- FUN_00672b70 at 0x00672B70 (size: 121) ---


undefined1 FUN_00672b70(int param_1,int param_2)



{

  undefined1 uVar1;

  LONG LVar2;

  undefined4 uStack_18;

  undefined4 uStack_14;

  

  uStack_18 = 0;

  FUN_00403350(&uStack_14);

  FUN_00403350(&uStack_18,0);

  uVar1 = FUN_00672900();

  uStack_14 = 0x672bb4;

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

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

    uStack_14 = 0x672bc4;

    (*(code *)**(undefined4 **)(param_1 + -0x14))();

  }

  uStack_14 = 0x672bd1;

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

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

    uStack_14 = 0x672be1;

    (*(code *)**(undefined4 **)(param_2 + -0x14))();

  }

  return uVar1;

}





// --- FUN_00672bf0 at 0x00672BF0 (size: 141) ---


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



{

  int iVar1;

  undefined4 *puVar2;

  int iVar3;

  

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

    puVar2 = (undefined4 *)(param_1 + 0x110 + param_2 * 0x18);

    for (iVar1 = 6; iVar1 != 0; iVar1 = iVar1 + -1) {

      *param_3 = *puVar2;

      puVar2 = puVar2 + 1;

      param_3 = param_3 + 1;

    }

  }

  iVar3 = *(int *)(param_1 + 0x10c) + -1;

  iVar1 = param_1 + param_2 * 0x18;

  *(int *)(param_1 + 0x10c) = iVar3;

  memmove((void *)(iVar1 + 0x110),(void *)(iVar1 + 0x128),(iVar3 - param_2) * 0x18);

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

    memmove((void *)(param_1 + 0x18 + param_2 * 4),(void *)(param_1 + 0x1c + param_2 * 4),

            (*(int *)(param_1 + 0x10c) - param_2) * 4);

  }

  *(undefined1 *)(param_1 + 4) = 1;

  return 0;

}





// --- FUN_00672c80 at 0x00672C80 (size: 97) ---


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



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  

  memmove((void *)(param_1 + 0x128),(undefined4 *)(param_1 + 0x110),0x2d0);

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

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

  for (iVar2 = 6; iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar3 = *param_2;

    param_2 = param_2 + 1;

    puVar3 = puVar3 + 1;

  }

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

  if (iVar1 != 0) {

    memmove((void *)(param_1 + 0x18),(undefined4 *)(param_1 + 0x14),0x7c);

    *(undefined4 *)(param_1 + 0x14) = param_3;

  }

  return;

}





// --- FUN_00672d20 at 0x00672D20 (size: 123) ---


uint FUN_00672d20(uint param_1,int param_2,int *param_3)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  char cVar4;

  int iVar5;

  

  uVar1 = *(uint *)(param_2 + 0x10c);

  if (0x3d < (int)uVar1) {

    return uVar1 & 0xffffff00;

  }

  iVar3 = uVar1 - 1;

  cVar4 = '\0';

  iVar5 = 0;

  iVar2 = 0;

  if (-1 < iVar3) {

    do {

      iVar2 = (iVar3 + iVar5) / 2;

      uVar1 = *(uint *)(param_2 + 0x114 + iVar2 * 0x18);

      if (param_1 == uVar1) {

        cVar4 = '\x01';

        iVar5 = iVar3 + 1;

      }

      else if (param_1 < uVar1) {

        iVar3 = iVar2 + -1;

      }

      else {

        iVar5 = iVar2 + 1;

      }

    } while (iVar5 <= iVar3);

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

  }

  if (*(uint *)(param_2 + 0x114 + iVar2 * 0x18) < param_1) {

    iVar2 = iVar2 + 1;

  }

LAB_00672d8c:

  *param_3 = iVar2;

  return CONCAT31((int3)((uint)iVar2 >> 8),cVar4);

}





// --- FUN_00672da0 at 0x00672DA0 (size: 136) ---


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



{

  int iVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  undefined4 local_18 [6];

  

  puVar2 = (undefined4 *)(param_2 + 0x110);

  puVar3 = local_18;

  for (iVar1 = 6; iVar1 != 0; iVar1 = iVar1 + -1) {

    *puVar3 = *puVar2;

    puVar2 = puVar2 + 1;

    puVar3 = puVar3 + 1;

  }

  *param_3 = *(undefined4 *)(param_2 + 0x14);

  iVar1 = *(int *)(param_2 + 0x10c) + -1;

  *(int *)(param_2 + 0x10c) = iVar1;

  memmove((undefined4 *)(param_2 + 0x110),(void *)(param_2 + 0x128),iVar1 * 0x18);

  if (*(int *)(param_2 + 0x14) != 0) {

    memmove((int *)(param_2 + 0x14),(void *)(param_2 + 0x18),*(int *)(param_2 + 0x10c) * 4 + 4);

  }

  puVar2 = local_18;

  for (iVar1 = 6; iVar1 != 0; iVar1 = iVar1 + -1) {

    *param_1 = *puVar2;

    puVar2 = puVar2 + 1;

    param_1 = param_1 + 1;

  }

  return;

}





// --- FUN_00672e30 at 0x00672E30 (size: 105) ---


undefined4 FUN_00672e30(int param_1)



{

  undefined4 local_14;

  undefined4 local_10;

  

  if (*(char *)(param_1 + 4) != '\0') {

    *(undefined1 *)(param_1 + 4) = 0;

  }

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

  FUN_004073b0((undefined4 *)(param_1 + 0x10),0x6b8);

  FUN_006752a0(&local_14,*(undefined4 *)(param_1 + 0x10));

  FUN_00406f90();

  FUN_00406f90();

  return 0;

}





// --- FUN_00672ea0 at 0x00672EA0 (size: 27) ---


void __fastcall FUN_00672ea0(int param_1)



{

  if (*(char *)(*(int *)(param_1 + 0x6d8) + 0x2c) != '\0') {

    FUN_006771c0();

    return;

  }

  return;

}





// --- FUN_00672ec0 at 0x00672EC0 (size: 69) ---


void __fastcall FUN_00672ec0(undefined4 *param_1)



{

  uint uVar1;

  uint *puVar2;

  int iVar3;

  

  param_1[0x3e] = 0;

  puVar2 = param_1 + 0x3f;

  iVar3 = 0x3d;

  do {

    uVar1 = DAT_008f86d8;

    *puVar2 = *puVar2 & 0xffff0000;

    *(undefined2 *)((int)puVar2 + 2) = 0;

    puVar2[1] = uVar1;

    puVar2[2] = 0;

    puVar2[3] = 0;

    puVar2[4] = 0;

    puVar2[5] = 0;

    puVar2 = puVar2 + 6;

    iVar3 = iVar3 + -1;

  } while (iVar3 != 0);

  *param_1 = 0;

  return;

}





// --- FUN_00672f10 at 0x00672F10 (size: 79) ---


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



{

  *param_1 = 0;

  *(undefined1 *)(param_1 + 1) = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  FUN_00672ec0();

  param_1[0x1b5] = param_2;

  param_1[0x1b2] = 0;

  param_1[0x1b3] = 0;

  param_1[0x1b6] = 0;

  param_1[0x1b7] = 0;

  param_1[0x1b4] = 1;

  return param_1;

}





// --- FUN_00672f60 at 0x00672F60 (size: 75) ---


void __fastcall FUN_00672f60(int param_1)



{

  void *pvVar1;

  

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

    operator_delete__((void *)(*(int *)(param_1 + 0x6c8) + -4));

  }

  pvVar1 = *(void **)(param_1 + 0x6dc);

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

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

    FUN_00676da0();

    operator_delete(pvVar1);

  }

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

  return;

}





// --- FUN_00672fb0 at 0x00672FB0 (size: 307) ---


int __thiscall FUN_00672fb0(int param_1,undefined4 param_2)



{

  char cVar1;

  undefined4 *puVar2;

  undefined4 uVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined4 local_14;

  undefined4 local_10;

  

  iVar4 = 100;

  *(undefined4 *)(param_1 + 0x6d8) = param_2;

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

  puVar2 = (undefined4 *)thunk_FUN_005df0f5(0x2a624);

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = 100;

    puVar2 = puVar2 + 1;

    puVar5 = puVar2;

    do {

      *puVar5 = 0;

      *(undefined1 *)(puVar5 + 1) = 0;

      puVar5[2] = 0;

      puVar5[3] = 0;

      puVar5[4] = 0;

      FUN_00672ec0();

      puVar5 = puVar5 + 0x1b2;

      iVar4 = iVar4 + -1;

    } while (iVar4 != 0);

  }

  *(undefined4 **)(param_1 + 0x6c8) = puVar2;

  uVar3 = *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x14);

  puVar2 = (undefined4 *)(param_1 + 0x10);

  *puVar2 = uVar3;

  *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x20) = uVar3;

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

  FUN_004073b0(puVar2,0x6b8);

  iVar4 = FUN_00675150(&local_14,*puVar2);

  if (*(char *)(*(int *)(param_1 + 0x6d8) + 0x2c) == '\0') {

    if (iVar4 != 0) goto LAB_006730c5;

  }

  else {

    if (iVar4 != 0) goto LAB_006730c5;

    iVar4 = FUN_005df0f5(0x104);

    if (iVar4 == 0) {

      uVar3 = 0;

    }

    else {

      uVar3 = FUN_00676d30(*(undefined4 *)(param_1 + 0x6d4),*(undefined4 *)(param_1 + 0x6d8));

    }

    *(undefined4 *)(param_1 + 0x6dc) = uVar3;

    cVar1 = FUN_00675ab0();

    if (cVar1 == '\0') {

      iVar4 = -2;

      goto LAB_006730c5;

    }

  }

  iVar4 = FUN_00674e70();

LAB_006730c5:

  FUN_00406f90();

  FUN_00406f90();

  return iVar4;

}





// --- FUN_006730f0 at 0x006730F0 (size: 298) ---


int __thiscall FUN_006730f0(int param_1,undefined4 param_2)



{

  char cVar1;

  undefined4 *puVar2;

  undefined4 uVar3;

  int iVar4;

  undefined4 *puVar5;

  int local_18;

  undefined4 local_14;

  undefined4 local_10;

  

  iVar4 = 100;

  local_18 = 0;

  *(undefined4 *)(param_1 + 0x6d8) = param_2;

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

  puVar2 = (undefined4 *)thunk_FUN_005df0f5(0x2a624);

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = 100;

    puVar2 = puVar2 + 1;

    puVar5 = puVar2;

    do {

      *puVar5 = 0;

      *(undefined1 *)(puVar5 + 1) = 0;

      puVar5[2] = 0;

      puVar5[3] = 0;

      puVar5[4] = 0;

      FUN_00672ec0();

      puVar5 = puVar5 + 0x1b2;

      iVar4 = iVar4 + -1;

    } while (iVar4 != 0);

  }

  *(undefined4 **)(param_1 + 0x6c8) = puVar2;

  puVar2 = (undefined4 *)(param_1 + 0x10);

  *puVar2 = *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x20);

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

  FUN_004073b0(puVar2,0x6b8);

  cVar1 = FUN_00675480(&local_14,*puVar2,0);

  if (cVar1 == '\0') {

    local_18 = -1;

  }

  if ((*(char *)(*(int *)(param_1 + 0x6d8) + 0x2c) != '\0') && (local_18 == 0)) {

    iVar4 = FUN_005df0f5(0x104);

    if (iVar4 == 0) {

      uVar3 = 0;

    }

    else {

      uVar3 = FUN_00676d30(*(undefined4 *)(param_1 + 0x6d4),*(undefined4 *)(param_1 + 0x6d8));

    }

    *(undefined4 *)(param_1 + 0x6dc) = uVar3;

    cVar1 = FUN_00675c40();

    if (cVar1 == '\0') {

      local_18 = -1;

    }

  }

  FUN_00406f90();

  FUN_00406f90();

  return local_18;

}





// --- FUN_00673220 at 0x00673220 (size: 142) ---


undefined4 __fastcall FUN_00673220(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  int iVar4;

  

  if (*(char *)(*(int *)(param_1 + 0x6d8) + 0x2c) != '\0') {

    FUN_00676ef0();

  }

  iVar3 = 0;

  if (0 < *(int *)(param_1 + 0x6cc)) {

    iVar4 = 0;

    do {

      iVar1 = *(int *)(param_1 + 0x6c8) + iVar4;

      if ((*(int *)(iVar1 + 0x10) != 0) && (*(char *)(iVar1 + 4) != '\0')) {

        FUN_00672e30(iVar1,0);

      }

      iVar3 = iVar3 + 1;

      iVar4 = iVar4 + 0x6c8;

    } while (iVar3 < *(int *)(param_1 + 0x6cc));

  }

  if (*(int *)(*(int *)(param_1 + 0x6d8) + 0x20) != *(int *)(param_1 + 0x10)) {

    *(int *)(*(int *)(param_1 + 0x6d8) + 0x20) = *(int *)(param_1 + 0x10);

  }

  uVar2 = FUN_00674e70();

  FUN_00675680();

  return uVar2;

}





// --- FUN_006732c0 at 0x006732C0 (size: 399) ---


int * __thiscall FUN_006732c0(int *param_1,int param_2,int *param_3)



{

  int *piVar1;

  int iVar2;

  int *piVar3;

  undefined4 *puVar4;

  int iVar5;

  int iVar6;

  int local_1c;

  int local_18;

  undefined4 local_14;

  undefined4 local_10;

  

  piVar3 = (int *)0x0;

  iVar5 = 0;

  local_1c = 0;

  if (param_2 == param_1[4]) {

    piVar3 = param_1;

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

      *param_3 = -1;

    }

  }

  else {

    local_18 = 0;

    iVar6 = 0;

    while (iVar5 < param_1[0x1b3]) {

      iVar2 = param_1[0x1b2];

      piVar1 = (int *)(iVar6 + iVar2);

      if (param_2 == *(int *)(iVar6 + 0x10 + iVar2)) {

        *piVar1 = param_1[0x1b4];

        param_1[0x1b4] = param_1[0x1b4] + 1;

        piVar3 = piVar1;

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

          *param_3 = iVar5;

        }

      }

      else if (*piVar1 < *(int *)(local_18 + iVar2)) {

        local_1c = iVar5;

        local_18 = iVar6;

      }

      iVar5 = iVar5 + 1;

      iVar6 = iVar6 + 0x6c8;

      if (piVar3 != (int *)0x0) {

        return piVar3;

      }

    }

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

      iVar5 = local_1c * 0x6c8;

      if (*(char *)(iVar5 + 4 + param_1[0x1b2]) != '\0') {

        FUN_00672e30(iVar5 + param_1[0x1b2],0);

      }

      if (param_2 == 0) {

        puVar4 = (undefined4 *)(param_1[0x1b2] + iVar5);

        *puVar4 = 0;

        *(undefined1 *)(puVar4 + 1) = 0;

        puVar4[2] = 0;

        puVar4[3] = 0;

        puVar4[4] = 0;

        puVar4[0x43] = 0;

        puVar4[5] = 0;

      }

      else {

        local_14 = 0;

        local_10 = 0;

        FUN_00406d60();

        FUN_004073b0(iVar5 + 0x10 + param_1[0x1b2],0x6b8);

        FUN_00675480(&local_14,param_2,0);

        *(int *)(iVar5 + 0x10 + param_1[0x1b2]) = param_2;

        FUN_00406f90();

        FUN_00406f90();

      }

      piVar3 = (int *)(iVar5 + param_1[0x1b2]);

      *piVar3 = param_1[0x1b4];

      param_1[0x1b4] = param_1[0x1b4] + 1;

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

        *param_3 = local_1c;

        return piVar3;

      }

    }

  }

  return piVar3;

}





// --- FUN_00673450 at 0x00673450 (size: 130) ---


int __fastcall FUN_00673450(int param_1)



{

  int iVar1;

  undefined4 local_14;

  undefined4 local_10;

  

  iVar1 = FUN_006732c0(0,0);

  *(undefined4 *)(iVar1 + 0x10c) = 0;

  *(undefined4 *)(iVar1 + 0x10) = *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x14);

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

  FUN_004073b0((undefined4 *)(iVar1 + 0x10),0x6b8);

  FUN_00675150(&local_14,*(undefined4 *)(iVar1 + 0x10));

  FUN_00406f90();

  FUN_00406f90();

  return iVar1;

}





// --- FUN_006734e0 at 0x006734E0 (size: 371) ---


undefined4 __thiscall FUN_006734e0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  int iVar6;

  undefined4 *puVar7;

  undefined4 *puVar8;

  undefined4 *puVar9;

  int local_c;

  

  iVar1 = *(int *)(param_2 + 0x14);

  iVar2 = FUN_006732c0(*(undefined4 *)(param_2 + 0xc),0);

  iVar3 = FUN_006732c0(*(undefined4 *)(iVar2 + 0x14 + iVar1 * 4),0);

  if (*(int *)(*(int *)(param_1 + 0x6d8) + 0x14) == *(int *)(param_2 + 0x18)) {

    iVar4 = FUN_00673450();

  }

  else {

    iVar4 = FUN_006732c0(*(int *)(param_2 + 0x18),0);

  }

  if (*(int *)(iVar4 + 0x10c) != 0x1e) {

    puVar5 = (undefined4 *)(iVar3 + 0x3f8);

    puVar7 = (undefined4 *)(iVar4 + 0x110);

    for (iVar6 = 0xb4; iVar6 != 0; iVar6 = iVar6 + -1) {

      *puVar7 = *puVar5;

      puVar5 = puVar5 + 1;

      puVar7 = puVar7 + 1;

    }

    if (*(int *)(iVar3 + 0x14) != 0) {

      puVar5 = (undefined4 *)(iVar3 + 0x90);

      puVar7 = (undefined4 *)(iVar4 + 0x14);

      for (iVar6 = 0x1f; iVar6 != 0; iVar6 = iVar6 + -1) {

        *puVar7 = *puVar5;

        puVar5 = puVar5 + 1;

        puVar7 = puVar7 + 1;

      }

    }

    *(undefined4 *)(iVar4 + 0x10c) = 0x1e;

    FUN_00672e30(iVar4,0);

  }

  iVar4 = *(int *)(iVar2 + 0x10c);

  if (iVar4 == *(int *)(param_2 + 0x10)) {

    if (iVar1 < iVar4) {

      puVar5 = (undefined4 *)(iVar2 + 0x18 + iVar4 * 4);

      local_c = iVar4 - iVar1;

      puVar7 = (undefined4 *)(iVar2 + 0x110 + iVar4 * 0x18);

      do {

        *puVar5 = puVar5[-1];

        puVar8 = puVar7 + -6;

        puVar9 = puVar7;

        for (iVar4 = 6; iVar4 != 0; iVar4 = iVar4 + -1) {

          *puVar9 = *puVar8;

          puVar8 = puVar8 + 1;

          puVar9 = puVar9 + 1;

        }

        puVar5 = puVar5 + -1;

        local_c = local_c + -1;

        puVar7 = puVar7 + -6;

      } while (local_c != 0);

    }

    *(undefined4 *)(iVar2 + 0x18 + iVar1 * 4) = *(undefined4 *)(param_2 + 0x18);

    puVar5 = (undefined4 *)(iVar3 + 0x3e0);

    puVar7 = (undefined4 *)(iVar2 + 0x110 + iVar1 * 0x18);

    for (iVar4 = 6; iVar4 != 0; iVar4 = iVar4 + -1) {

      *puVar7 = *puVar5;

      puVar5 = puVar5 + 1;

      puVar7 = puVar7 + 1;

    }

    *(int *)(iVar2 + 0x10c) = *(int *)(iVar2 + 0x10c) + 1;

    FUN_00672e30(iVar2,0);

  }

  if (*(int *)(iVar3 + 0x10c) != 0x1e) {

    *(undefined4 *)(iVar3 + 0x10c) = 0x1e;

    FUN_00672e30(iVar3,0);

  }

  return 0;

}





// --- FUN_00673660 at 0x00673660 (size: 353) ---


undefined4 __thiscall FUN_00673660(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  undefined4 uVar6;

  undefined4 *puVar7;

  

  uVar6 = 0;

  if (*(int *)(param_2 + 0x18) == -2) {

    return 0xffffff9b;

  }

  iVar1 = FUN_006732c0(*(undefined4 *)(param_2 + 0x14),0);

  if (iVar1 == 0) {

    return 0xffffffff;

  }

  if (*(int *)(iVar1 + 0x14) != 0) {

    return 0xffffff9b;

  }

  if (*(int *)(param_2 + 0x28) == *(int *)(iVar1 + 0x10c)) {

    FUN_004074b0(4,1);

    iVar2 = FUN_00406d80();

    if (iVar2 == 0) {

      uVar6 = FUN_00674e90(*(undefined4 *)(param_2 + 0x18),*(undefined4 *)(param_2 + 0x24));

    }

    else {

      iVar2 = *(int *)(iVar1 + 0x10c) + -1;

      if (-1 < iVar2) {

        puVar4 = (undefined4 *)(iVar1 + 0x110 + iVar2 * 0x18);

        do {

          if ((uint)puVar4[1] <= *(uint *)(param_2 + 0x10)) break;

          iVar2 = iVar2 + -1;

          puVar5 = puVar4;

          puVar7 = puVar4 + 6;

          for (iVar3 = 6; iVar3 != 0; iVar3 = iVar3 + -1) {

            *puVar7 = *puVar5;

            puVar5 = puVar5 + 1;

            puVar7 = puVar7 + 1;

          }

          puVar4 = puVar4 + -6;

        } while (-1 < iVar2);

      }

      iVar2 = iVar1 + (iVar2 * 3 + 3) * 8;

      puVar4 = (undefined4 *)(param_2 + 0xc);

      puVar5 = (undefined4 *)(iVar2 + 0x110);

      for (iVar3 = 6; iVar3 != 0; iVar3 = iVar3 + -1) {

        *puVar5 = *puVar4;

        puVar4 = puVar4 + 1;

        puVar5 = puVar5 + 1;

      }

      *(undefined4 *)(iVar2 + 0x118) = *(undefined4 *)(param_2 + 0x24);

      uVar6 = FUN_00417640();

      *(undefined4 *)(iVar2 + 0x11c) = uVar6;

      *(int *)(iVar1 + 0x10c) = *(int *)(iVar1 + 0x10c) + 1;

      uVar6 = FUN_00675150(param_3,*(undefined4 *)(param_2 + 0x24));

      FUN_00672e30(iVar1,0);

      if (*(char *)(*(int *)(param_1 + 0x6d8) + 0x2c) != '\0') {

        FUN_006768f0(*(undefined4 *)(param_2 + 0x10));

        return uVar6;

      }

    }

  }

  return uVar6;

}





// --- FUN_006737d0 at 0x006737D0 (size: 399) ---


undefined4 __thiscall FUN_006737d0(int param_1,int param_2,undefined4 param_3)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  uint uVar6;

  undefined4 uVar7;

  int iVar8;

  undefined4 *puVar9;

  undefined4 *puVar10;

  undefined4 local_c;

  

  local_c = 0;

  iVar4 = FUN_006732c0(*(undefined4 *)(param_2 + 0x14),0);

  iVar2 = *(int *)(param_2 + 0x2c);

  iVar3 = *(int *)(param_2 + 0x24);

  if (iVar4 == 0) {

    return 0xffffffff;

  }

  if (*(int *)(param_2 + 0x18) == -2) {

    *(undefined4 *)(iVar4 + (iVar2 * 3 + 0x24) * 8) = *(undefined4 *)(param_2 + 0x1c);

    iVar5 = iVar4 + iVar2 * 0x18;

    *(undefined4 *)(iVar5 + 0x124) = *(undefined4 *)(param_2 + 0x20);

    *(undefined2 *)(iVar5 + 0x112) = *(undefined2 *)(param_2 + 0xe);

  }

  else {

    FUN_004074b0(4,1);

    iVar5 = FUN_00406d80();

    if (iVar5 == 0) goto LAB_006738fe;

    iVar5 = iVar4 + iVar2 * 0x18;

    puVar9 = (undefined4 *)(param_2 + 0xc);

    puVar10 = (undefined4 *)(iVar5 + 0x110);

    for (iVar8 = 6; iVar8 != 0; iVar8 = iVar8 + -1) {

      *puVar10 = *puVar9;

      puVar9 = puVar9 + 1;

      puVar10 = puVar10 + 1;

    }

    *(int *)(iVar5 + 0x118) = iVar3;

    uVar6 = FUN_00406db0();

    if (uVar6 < 5) {

      iVar8 = 0;

    }

    else {

      iVar8 = FUN_00406db0();

      iVar8 = iVar8 + -4;

    }

    *(int *)(iVar5 + 0x11c) = iVar8;

    local_c = FUN_00675150(param_3,iVar3);

  }

  FUN_00672e30(iVar4,0);

  if (*(char *)(*(int *)(param_1 + 0x6d8) + 0x2c) != '\0') {

    FUN_006771c0(*(undefined4 *)(param_2 + 0x10));

  }

LAB_006738fe:

  piVar1 = (int *)(param_2 + 0x30);

  iVar2 = *(int *)(iVar4 + 0x118 + iVar2 * 0x18);

  if (iVar2 != *piVar1) {

    param_2 = iVar3;

    if (iVar3 == iVar2) {

      param_2 = *piVar1;

    }

    uVar7 = FUN_00674f50(param_2,*(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x18),

                         *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x1c),1);

    return uVar7;

  }

  return local_c;

}





// --- FUN_00673960 at 0x00673960 (size: 601) ---


undefined4 __thiscall FUN_00673960(int param_1,undefined4 *param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  int iVar5;

  uint uVar6;

  undefined4 *puVar7;

  int local_24;

  int local_20;

  int local_1c;

  undefined4 local_18 [6];

  

  iVar5 = (int)param_2;

  local_24 = -1;

  local_20 = -1;

  iVar1 = FUN_006732c0(*(undefined4 *)((int)param_2 + 0xc),&param_2);

  local_1c = iVar1;

  iVar2 = FUN_006732c0(*(undefined4 *)(iVar5 + 0x10),&local_20);

  iVar3 = FUN_006732c0(*(undefined4 *)(iVar5 + 0x14),&local_24);

  param_2 = (undefined4 *)(iVar3 + 0x14);

  if ((iVar1 != -0x14) && (*(int *)(iVar1 + 0x10c) == *(int *)(iVar5 + 0x1c))) {

    local_18[0] = 0;

    local_18[2] = 0;

    local_18[3] = 0;

    local_18[4] = 0;

    local_18[5] = 0;

    local_18[1] = DAT_008f86d8;

    FUN_00672bf0(iVar1,*(undefined4 *)(iVar5 + 0x18),local_18);

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

      *(undefined4 *)(iVar2 + 0x90) = 0;

      puVar4 = local_18;

      puVar7 = (undefined4 *)(iVar2 + 0x3e0);

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

        *puVar7 = *puVar4;

        puVar4 = puVar4 + 1;

        puVar7 = puVar7 + 1;

      }

      *(int *)(iVar2 + 0x10c) = *(int *)(iVar2 + 0x10c) + 1;

      param_2 = (undefined4 *)(iVar3 + 0x14);

      puVar4 = (undefined4 *)(iVar3 + 0x110);

      puVar7 = (undefined4 *)(iVar2 + 0x110 + *(int *)(iVar2 + 0x10c) * 0x18);

      for (uVar6 = (uint)(*(int *)(iVar3 + 0x10c) * 0x18) >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {

        *puVar7 = *puVar4;

        puVar4 = puVar4 + 1;

        puVar7 = puVar7 + 1;

      }

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

        *(undefined1 *)puVar7 = *(undefined1 *)puVar4;

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

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

      }

      puVar4 = param_2;

      puVar7 = (undefined4 *)(iVar2 + 0x14 + *(int *)(iVar2 + 0x10c) * 4);

      for (uVar6 = *(int *)(iVar3 + 0x10c) * 4 + 4U >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {

        *puVar7 = *puVar4;

        puVar4 = puVar4 + 1;

        puVar7 = puVar7 + 1;

      }

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

        *(undefined1 *)puVar7 = *(undefined1 *)puVar4;

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

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

      }

      *(int *)(iVar2 + 0x10c) = *(int *)(iVar2 + 0x10c) + *(int *)(iVar3 + 0x10c);

      FUN_00672e30(iVar2,0);

      FUN_00674f50(*(undefined4 *)(iVar3 + 0x10),*(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x18),

                   *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x1c),0);

      puVar4 = (undefined4 *)(local_24 * 0x6c8 + *(int *)(param_1 + 0x6c8));

      *puVar4 = 0;

      *(undefined1 *)(puVar4 + 1) = 0;

      puVar4[2] = 0;

      puVar4[3] = 0;

      puVar4[4] = 0;

      puVar4[0x43] = 0;

      puVar4[5] = 0;

      iVar1 = local_1c;

    }

    if ((iVar1 + 0x14 == param_1 + 0x14) && (*(int *)(param_1 + 0x10c) == 0)) {

      *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x20) = *(undefined4 *)(iVar2 + 0x10);

      FUN_00674e70();

      FUN_00674f50(*(undefined4 *)(iVar1 + 0x10),*(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x18),

                   *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x1c),0);

      puVar4 = (undefined4 *)(iVar2 + 0x14);

      puVar7 = (undefined4 *)(param_1 + 0x14);

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

        *puVar7 = *puVar4;

        puVar4 = puVar4 + 1;

        puVar7 = puVar7 + 1;

      }

      *(undefined4 *)(param_1 + 0x10) = *(undefined4 *)(iVar2 + 0x10);

      puVar4 = (undefined4 *)(local_20 * 0x6c8 + *(int *)(param_1 + 0x6c8));

      *puVar4 = 0;

      *(undefined1 *)(puVar4 + 1) = 0;

      puVar4[2] = 0;

      puVar4[3] = 0;

      puVar4[4] = 0;

      puVar4[0x43] = 0;

      puVar4[5] = 0;

      return 0;

    }

    FUN_00672e30(iVar1,0);

  }

  return 0;

}





// --- FUN_00673bc0 at 0x00673BC0 (size: 49) ---


void FUN_00673bc0(undefined4 *param_1,int param_2)



{

  int iVar1;

  

  iVar1 = *(int *)(param_2 + 0x14);

  while (iVar1 != 0) {

    param_2 = FUN_006732c0(iVar1,0);

    iVar1 = *(int *)(param_2 + 0x14);

  }

  *param_1 = *(undefined4 *)(param_2 + 0x114);

  return;

}





// --- FUN_00673c00 at 0x00673C00 (size: 69) ---


void FUN_00673c00(undefined4 *param_1,int param_2)



{

  int iVar1;

  

  iVar1 = *(int *)(param_2 + 0x14);

  while (iVar1 != 0) {

    param_2 = FUN_006732c0(*(undefined4 *)(param_2 + 0x14 + *(int *)(param_2 + 0x10c) * 4),0);

    iVar1 = *(int *)(param_2 + 0x14);

  }

  *param_1 = *(undefined4 *)(param_2 + 0xfc + *(int *)(param_2 + 0x10c) * 0x18);

  return;

}





// --- FUN_00673c50 at 0x00673C50 (size: 163) ---


undefined4 __thiscall FUN_00673c50(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  undefined4 uVar4;

  

  iVar3 = FUN_006732c0(*(undefined4 *)(param_2 + 0x10),0);

  iVar2 = *(int *)(param_2 + 0x14);

  if (iVar3 == 0) {

    return 0xffffffff;

  }

  iVar1 = iVar3 + iVar2 * 0x18;

  if (*(int *)(param_2 + 0xc) == *(int *)(iVar1 + 0x114)) {

    if (*(char *)(*(int *)(param_1 + 0x6d8) + 0x2c) != '\0') {

      FUN_00676eb0(*(int *)(param_2 + 0xc));

    }

    FUN_00674f50(*(undefined4 *)(iVar1 + 0x118),*(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x18),

                 *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x1c),1);

    FUN_00672bf0(iVar3,iVar2,0);

    uVar4 = FUN_00672e30(iVar3,0);

    return uVar4;

  }

  return 0;

}





// --- FUN_00673d00 at 0x00673D00 (size: 287) ---


undefined4 __thiscall FUN_00673d00(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 uVar5;

  int iVar6;

  undefined4 *puVar7;

  undefined4 *puVar8;

  

  iVar3 = FUN_006732c0(*(undefined4 *)(param_2 + 0x14),0);

  iVar4 = FUN_006732c0(*(undefined4 *)(param_2 + 0x18),0);

  iVar2 = *(int *)(param_2 + 0x20);

  if ((iVar3 == 0) || (iVar4 == 0)) {

    uVar5 = 0xffffffff;

  }

  else {

    iVar1 = iVar3 + *(int *)(param_2 + 0x1c) * 0x18;

    if (*(int *)(param_2 + 0xc) == *(int *)(iVar3 + 0x114 + *(int *)(param_2 + 0x1c) * 0x18)) {

      if (*(char *)(*(int *)(param_1 + 0x6d8) + 0x2c) != '\0') {

        FUN_00676eb0(*(int *)(param_2 + 0xc));

      }

      FUN_00674f50(*(undefined4 *)(iVar1 + 0x118),*(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x18),

                   *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x1c),1);

      puVar7 = (undefined4 *)(iVar4 + 0x110 + iVar2 * 0x18);

      puVar8 = (undefined4 *)(iVar1 + 0x110);

      for (iVar6 = 6; iVar6 != 0; iVar6 = iVar6 + -1) {

        *puVar8 = *puVar7;

        puVar7 = puVar7 + 1;

        puVar8 = puVar8 + 1;

      }

      uVar5 = FUN_00672e30(iVar3,0);

    }

    else {

      uVar5 = 0;

    }

    if (*(int *)(param_2 + 0x10) == *(int *)(iVar4 + 0x114 + iVar2 * 0x18)) {

      FUN_00672bf0(iVar4,iVar2,0);

      uVar5 = FUN_00672e30(iVar4,0);

      return uVar5;

    }

  }

  return uVar5;

}





// --- FUN_00673e20 at 0x00673E20 (size: 413) ---


undefined4 FUN_00673e20(int param_1)



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  int iVar4;

  int iVar5;

  undefined4 *puVar6;

  undefined4 *puVar7;

  undefined4 local_54;

  int local_50;

  int local_4c;

  undefined4 local_48 [6];

  undefined4 local_30 [6];

  undefined1 local_18 [24];

  

  iVar5 = *(int *)(param_1 + 0x14);

  local_4c = 0;

  iVar2 = FUN_006732c0(*(undefined4 *)(param_1 + 0xc),0);

  local_50 = iVar2;

  local_4c = FUN_006732c0(*(undefined4 *)(iVar2 + 0x14 + iVar5 * 4),0);

  if (*(char *)(param_1 + 0x20) == '\0') {

    iVar2 = FUN_006732c0(*(undefined4 *)(iVar2 + 0x18 + iVar5 * 4),0);

  }

  else {

    iVar2 = FUN_006732c0(*(undefined4 *)(iVar2 + 0x10 + iVar5 * 4),0);

  }

  iVar1 = *(int *)(iVar2 + 0x10c);

  if (*(int *)(param_1 + 0x1c) == iVar1) {

    if (*(char *)(param_1 + 0x20) == '\0') {

      puVar3 = (undefined4 *)FUN_00672da0(local_18,iVar2,&local_54);

    }

    else {

      local_54 = *(undefined4 *)(iVar2 + 0x14 + iVar1 * 4);

      *(int *)(iVar2 + 0x10c) = iVar1 + -1;

      puVar3 = (undefined4 *)(iVar2 + 0x110 + (iVar1 + -1) * 0x18);

      puVar6 = local_48;

      for (iVar4 = 6; iVar4 != 0; iVar4 = iVar4 + -1) {

        *puVar6 = *puVar3;

        puVar3 = puVar3 + 1;

        puVar6 = puVar6 + 1;

      }

      puVar3 = local_48;

    }

    iVar1 = local_4c;

    puVar6 = local_30;

    for (iVar4 = 6; iVar4 != 0; iVar4 = iVar4 + -1) {

      *puVar6 = *puVar3;

      puVar3 = puVar3 + 1;

      puVar6 = puVar6 + 1;

    }

    if (*(int *)(param_1 + 0x10) == *(int *)(local_50 + 0x114 + iVar5 * 0x18)) {

      if (*(char *)(param_1 + 0x20) != '\0') {

        iVar5 = iVar5 + -1;

      }

      puVar3 = (undefined4 *)(local_50 + 0x110 + iVar5 * 0x18);

      puVar6 = puVar3;

      puVar7 = local_48;

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

        *puVar7 = *puVar6;

        puVar6 = puVar6 + 1;

        puVar7 = puVar7 + 1;

      }

      puVar6 = local_30;

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

        *puVar3 = *puVar6;

        puVar6 = puVar6 + 1;

        puVar3 = puVar3 + 1;

      }

      if (*(int *)(param_1 + 0x18) == *(int *)(local_4c + 0x10c)) {

        if (*(char *)(param_1 + 0x20) == '\0') {

          *(int *)(local_4c + 0x10c) = *(int *)(local_4c + 0x10c) + 1;

          puVar3 = local_48;

          puVar6 = (undefined4 *)(local_4c + 0x3e0);

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

            *puVar6 = *puVar3;

            puVar3 = puVar3 + 1;

            puVar6 = puVar6 + 1;

          }

          *(undefined4 *)(local_4c + 0x90) = local_54;

        }

        else {

          FUN_00672c80(local_4c,local_48,local_54);

        }

        FUN_00672e30(iVar1,0);

      }

      FUN_00672e30(local_50,0);

    }

    FUN_00672e30(iVar2,0);

  }

  return 0xffffffff;

}





// --- FUN_00673fc0 at 0x00673FC0 (size: 220) ---


int FUN_00673fc0(int *param_1)



{

  undefined4 uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 local_14;

  undefined4 local_10;

  

  iVar2 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

  switch(param_1[1]) {

  case 0:

    goto switchD_00673fea_caseD_0;

  case 1:

    puVar3 = &local_14;

    uVar1 = (**(code **)(*param_1 + 4))(puVar3);

    iVar2 = FUN_00673660(uVar1,puVar3);

    break;

  case 2:

    uVar1 = (**(code **)(*param_1 + 0xc))();

    iVar2 = FUN_00673c50(uVar1);

    break;

  case 3:

    uVar1 = (**(code **)(*param_1 + 0x14))();

    iVar2 = FUN_00673d00(uVar1);

    break;

  case 4:

    uVar1 = (**(code **)(*param_1 + 0x1c))();

    iVar2 = FUN_00673960(uVar1);

    break;

  case 5:

    puVar3 = &local_14;

    uVar1 = (**(code **)(*param_1 + 0x24))(puVar3);

    iVar2 = FUN_006737d0(uVar1,puVar3);

    break;

  case 6:

    uVar1 = (**(code **)(*param_1 + 0x2c))();

    iVar2 = FUN_006734e0(uVar1);

    break;

  case 7:

    uVar1 = (**(code **)(*param_1 + 0x34))();

    iVar2 = FUN_00673e20(uVar1);

    break;

  default:

    iVar2 = -0x67;

    goto switchD_00673fea_caseD_0;

  }

  if (iVar2 == 0) {

    FUN_00675680();

  }

switchD_00673fea_caseD_0:

  FUN_00406f90();

  FUN_00406f90();

  return iVar2;

}





// --- FUN_006740c0 at 0x006740C0 (size: 144) ---


void __fastcall FUN_006740c0(int *param_1)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  undefined4 local_18 [6];

  

  param_1[2] = 0;

  if ((param_1[1] & 0x80000000U) != 0x80000000) {

    if (*param_1 != 0) {

      uVar1 = param_1[1] & 0x7fffffff;

      if (-1 < (int)(uVar1 - 1)) {

        local_18[0] = 0;

        local_18[2] = 0;

        local_18[3] = 0;

        local_18[4] = 0;

        local_18[5] = 0;

        iVar2 = (uVar1 - 1) * 0x18;

        do {

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

          local_18[1] = DAT_008f86d8;

          iVar2 = iVar2 + -0x18;

          uVar1 = uVar1 - 1;

          puVar4 = local_18;

          for (iVar3 = 6; iVar3 != 0; iVar3 = iVar3 + -1) {

            *puVar5 = *puVar4;

            puVar4 = puVar4 + 1;

            puVar5 = puVar5 + 1;

          }

        } while (uVar1 != 0);

      }

    }

    return;

  }

  if (*param_1 != 0) {

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

  }

  *param_1 = 0;

  param_1[1] = 0;

  return;

}





// --- FUN_00674160 at 0x00674160 (size: 118) ---


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



{

  int *piVar1;

  char cVar2;

  

  piVar1 = param_3;

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

    *param_3 = 0;

  }

  while( true ) {

    if (param_1 == 0) {

      return 0;

    }

    cVar2 = FUN_00672d20(param_2,param_1,&param_3);

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

    if (*(int *)(param_1 + 0x14) == 0) {

      return 0;

    }

    param_1 = FUN_006732c0(*(undefined4 *)(param_1 + 0x14 + (int)param_3 * 4),0);

  }

  if (piVar1 != (int *)0x0) {

    *piVar1 = param_1;

  }

  return param_1 + 0x110 + (int)param_3 * 0x18;

}





// --- FUN_006741e0 at 0x006741E0 (size: 103) ---


void __thiscall FUN_006741e0(int param_1,int param_2,undefined4 param_3)



{

  undefined1 local_1c [12];

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_00677270();

  local_10 = *(undefined4 *)(param_2 + 0x10);

  local_c = *(undefined4 *)(param_2 + 0x10c);

  local_8 = param_3;

  local_4 = *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x14);

  FUN_006755e0(local_1c);

  FUN_006734e0(local_1c);

  FUN_00675680();

  return;

}





// --- FUN_00674250 at 0x00674250 (size: 112) ---


void __thiscall FUN_00674250(int param_1,int param_2,undefined4 *param_3,undefined4 param_4)



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined1 local_2c [12];

  undefined4 local_20 [6];

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_00677a10();

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

  puVar3 = local_20;

  for (iVar2 = 6; iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar3 = *param_3;

    param_3 = param_3 + 1;

    puVar3 = puVar3 + 1;

  }

  local_8 = *(undefined4 *)(iVar1 + 0x14);

  local_4 = *(undefined4 *)(param_2 + 0x10c);

  FUN_006755e0(local_2c);

  FUN_00673660(local_2c,param_4);

  FUN_00675680();

  return;

}





// --- FUN_006742c0 at 0x006742C0 (size: 143) ---


void __thiscall FUN_006742c0(int param_1,int param_2,undefined4 *param_3,undefined4 param_4)



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  undefined1 local_34 [12];

  undefined4 local_28 [6];

  undefined4 local_10;

  int local_8;

  undefined4 local_4;

  

  puVar3 = param_3;

  iVar1 = param_2;

  FUN_00672d20(param_3[1],param_2,&param_2);

  FUN_00677a50();

  puVar4 = local_28;

  for (iVar2 = 6; iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar4 = *puVar3;

    puVar3 = puVar3 + 1;

    puVar4 = puVar4 + 1;

  }

  local_8 = param_2;

  local_4 = *(undefined4 *)(iVar1 + 0x118 + param_2 * 0x18);

  local_10 = *(undefined4 *)(*(int *)(param_1 + 0x6d8) + 0x14);

  FUN_006755e0(local_34);

  FUN_006737d0(local_34,param_4);

  FUN_00675680();

  return;

}





// --- FUN_00674350 at 0x00674350 (size: 424) ---


void __thiscall FUN_00674350(undefined4 *param_1,int param_2,undefined4 param_3)



{

  undefined4 *puVar1;

  uint *puVar2;

  undefined4 *puVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  undefined1 local_6ec [12];

  undefined4 local_6e0;

  undefined4 local_6dc;

  int local_6d8;

  undefined4 local_6d4;

  undefined4 local_6d0 [435];

  

  uVar4 = *(uint *)(param_2 + 4);

  if (param_1[0x43] == 0x3d) {

    puVar1 = (undefined4 *)FUN_00673450();

    puVar6 = param_1;

    puVar3 = local_6d0;

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

      *puVar3 = *puVar6;

      puVar6 = puVar6 + 1;

      puVar3 = puVar3 + 1;

    }

    puVar6 = puVar1;

    puVar3 = param_1;

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

      *puVar3 = *puVar6;

      puVar6 = puVar6 + 1;

      puVar3 = puVar3 + 1;

    }

    puVar6 = local_6d0;

    puVar3 = puVar1;

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

      *puVar3 = *puVar6;

      puVar6 = puVar6 + 1;

      puVar3 = puVar3 + 1;

    }

    param_1[5] = puVar1[4];

    *(undefined4 *)(param_1[0x1b6] + 0x20) = param_1[4];

    FUN_00674e70();

    FUN_006741e0(param_1,0,puVar1);

  }

  iVar5 = param_1[5];

  puVar6 = param_1;

  do {

    if (iVar5 == 0) {

      *(undefined4 *)(param_2 + 8) = puVar6[4];

      uVar4 = FUN_00406db0();

      if (uVar4 < 5) {

        iVar5 = 0;

      }

      else {

        iVar5 = FUN_00406db0();

        iVar5 = iVar5 + -4;

      }

      *(int *)(param_2 + 0xc) = iVar5;

      FUN_00674250(puVar6,param_2,param_3);

      return;

    }

    iVar5 = puVar6[0x43] + -1;

    if (-1 < iVar5) {

      puVar2 = puVar6 + iVar5 * 6 + 0x45;

      do {

        if (*puVar2 <= uVar4) break;

        iVar5 = iVar5 + -1;

        puVar2 = puVar2 + -6;

      } while (-1 < iVar5);

    }

    puVar3 = (undefined4 *)FUN_006732c0(puVar6[iVar5 + 6],0);

    if (puVar3[0x43] == 0x3d) {

      FUN_00677270();

      local_6e0 = puVar6[4];

      local_6dc = puVar6[0x43];

      local_6d4 = *(undefined4 *)(param_1[0x1b6] + 0x14);

      local_6d8 = iVar5 + 1;

      FUN_006755e0(local_6ec);

      FUN_006734e0(local_6ec);

      FUN_00675680();

      if ((uint)puVar6[(iVar5 + 1) * 6 + 0x45] < uVar4) {

        puVar3 = (undefined4 *)FUN_006732c0(puVar6[iVar5 + 7],0);

      }

    }

    iVar5 = puVar3[5];

    puVar6 = puVar3;

  } while( true );

}





// --- FUN_00674500 at 0x00674500 (size: 120) ---


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



{

  int iVar1;

  undefined1 local_20 [12];

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_00677240();

  local_14 = *(undefined4 *)(param_1 + 0x10);

  local_4 = *(undefined4 *)(param_1 + 0x10c);

  local_10 = *(undefined4 *)(param_2 + 0x10);

  local_c = *(undefined4 *)(param_3 + 0x10);

  local_8 = param_4;

  iVar1 = FUN_006755e0(local_20);

  if (iVar1 == 0) {

    iVar1 = FUN_00673960(local_20);

    if (iVar1 == 0) {

      FUN_00675680();

    }

  }

  return;

}





// --- FUN_00674580 at 0x00674580 (size: 94) ---


void FUN_00674580(int param_1,int param_2)



{

  undefined1 local_18 [12];

  undefined4 local_c;

  undefined4 local_8;

  int local_4;

  

  FUN_006773d0();

  local_c = *(undefined4 *)(param_1 + 0x114 + param_2 * 0x18);

  local_8 = *(undefined4 *)(param_1 + 0x10);

  local_4 = param_2;

  FUN_006755e0(local_18);

  FUN_00673c50(local_18);

  FUN_00675680();

  return;

}





// --- FUN_006745e0 at 0x006745E0 (size: 109) ---


void FUN_006745e0(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

                 undefined4 param_5,undefined4 param_6)



{

  undefined1 local_24 [12];

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_00677400();

  local_18 = param_1;

  local_14 = param_2;

  local_c = param_4;

  local_10 = param_3;

  local_8 = param_5;

  local_4 = param_6;

  FUN_006755e0(local_24);

  FUN_00673d00(local_24);

  FUN_00675680();

  return;

}





// --- FUN_00674650 at 0x00674650 (size: 118) ---


void FUN_00674650(int param_1,int param_2,undefined4 param_3,undefined4 param_4,undefined1 param_5)



{

  undefined1 local_24 [12];

  undefined4 local_18;

  undefined4 local_14;

  int local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined1 local_4;

  

  FUN_006777c0();

  local_18 = *(undefined4 *)(param_1 + 0x10);

  local_14 = *(undefined4 *)(param_1 + 0x114 + param_2 * 0x18);

  local_c = param_3;

  local_10 = param_2;

  local_4 = param_5;

  local_8 = param_4;

  FUN_006755e0(local_24);

  FUN_00673e20(local_24);

  FUN_00675680();

  return;

}





// --- FUN_006746d0 at 0x006746D0 (size: 205) ---


undefined4 __thiscall FUN_006746d0(int *param_1,uint param_2)



{

  uint *puVar1;

  uint *puVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  undefined4 *puVar6;

  undefined4 *puVar7;

  

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

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

      return 1;

    }

    if (param_2 == 0) {

      FUN_006740c0();

      return 1;

    }

    puVar2 = (uint *)thunk_FUN_005df0f5(param_2 * 0x18 + 4);

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

      puVar1 = puVar2 + 1;

      *puVar2 = param_2;

      FUN_00401000(puVar1,0x18,param_2,&LAB_00672cf0);

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

        if (*param_1 != 0) {

          iVar5 = param_1[2];

          if (-1 < iVar5 + -1) {

            iVar3 = (iVar5 + -1) * 0x18;

            do {

              puVar6 = (undefined4 *)(*param_1 + iVar3);

              puVar7 = (undefined4 *)(iVar3 + (int)puVar1);

              iVar3 = iVar3 + -0x18;

              iVar5 = iVar5 + -1;

              for (iVar4 = 6; iVar4 != 0; iVar4 = iVar4 + -1) {

                *puVar7 = *puVar6;

                puVar6 = puVar6 + 1;

                puVar7 = puVar7 + 1;

              }

            } while (iVar5 != 0);

          }

          if (((param_1[1] & 0x80000000U) == 0x80000000) && (*param_1 != 0)) {

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

          }

        }

        *param_1 = (int)puVar1;

        param_1[1] = param_2 | 0x80000000;

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_006747a0 at 0x006747A0 (size: 42) ---


undefined4 __thiscall FUN_006747a0(int param_1,int param_2,undefined4 param_3)



{

  undefined4 uVar1;

  

  if ((DAT_008f86d8 != param_2) && (*(int *)(param_1 + 0x10c) != 0)) {

    uVar1 = FUN_00674160(param_1,param_2,param_3);

    return uVar1;

  }

  return 0;

}





// --- FUN_006747d0 at 0x006747D0 (size: 369) ---


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



{

  int iVar1;

  char cVar2;

  int iVar3;

  int iVar4;

  bool bVar5;

  int local_8;

  int local_4;

  

  iVar4 = param_1;

  bVar5 = param_1 != 0;

  param_1 = 0;

  local_4 = 0;

  local_8 = -1;

  if (bVar5) {

    while( true ) {

      cVar2 = FUN_00672d20(param_2,iVar4,&local_8);

      iVar1 = local_8;

      if (cVar2 != '\0') {

        *param_3 = iVar4;

        *param_4 = local_8;

        return 0;

      }

      if (*(int *)(iVar4 + 0x14) == 0) break;

      iVar3 = FUN_006732c0(*(undefined4 *)(iVar4 + 0x14 + local_8 * 4),0);

      if (*(int *)(iVar3 + 0x10c) < 0x1f) {

        if (0 < iVar1) {

          param_1 = FUN_006732c0(*(undefined4 *)(iVar4 + 0x10 + iVar1 * 4),0);

          if (0x1e < *(int *)(param_1 + 0x10c)) {

            FUN_00674650(iVar4,iVar1,*(undefined4 *)(iVar3 + 0x10c),*(int *)(param_1 + 0x10c),1);

            goto LAB_006748ed;

          }

        }

        if (iVar1 < *(int *)(iVar4 + 0x10c)) {

          local_4 = FUN_006732c0(*(undefined4 *)(iVar4 + 0x18 + iVar1 * 4),0);

          if (0x1e < *(int *)(local_4 + 0x10c)) {

            FUN_00674650(iVar4,iVar1,*(undefined4 *)(iVar3 + 0x10c),*(int *)(local_4 + 0x10c),0);

            goto LAB_006748ed;

          }

        }

        if ((local_4 == 0) || (*(int *)(iVar4 + 0x10c) <= iVar1)) {

          if ((param_1 != 0) && (0 < iVar1)) {

            FUN_00674500(iVar4,param_1,iVar3,iVar1 + -1);

            iVar3 = param_1;

          }

        }

        else {

          FUN_00674500(iVar4,iVar3,local_4,iVar1);

        }

      }

LAB_006748ed:

      iVar4 = iVar3;

      if (iVar3 == 0) {

        return 0xffffffff;

      }

    }

    *param_3 = 0;

    *param_4 = -1;

  }

  return 0xffffffff;

}





// --- FUN_00674950 at 0x00674950 (size: 403) ---


int __thiscall FUN_00674950(int param_1,undefined4 param_2,int param_3)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined4 local_10;

  int local_c;

  int local_8;

  int local_4;

  

  local_8 = -1;

  local_10 = 0xffffffff;

  local_4 = 0;

  local_c = 0;

  iVar3 = FUN_006747d0(param_3,param_2,&local_4,&local_8);

  iVar2 = local_4;

  iVar4 = local_8;

  if (iVar3 == 0) {

    if (*(int *)(local_4 + 0x14) == 0) {

      iVar4 = FUN_00674580(local_4,local_8);

      return iVar4;

    }

    iVar3 = FUN_006732c0(*(undefined4 *)(local_4 + 0x14 + local_8 * 4),0);

    param_3 = iVar3;

    if (0x1e < *(int *)(iVar3 + 0x10c)) {

      puVar5 = (undefined4 *)FUN_00673c00(&param_3,iVar3);

      param_3 = *puVar5;

      FUN_006747d0(iVar3,param_3,&local_c,&local_10);

      iVar4 = FUN_006745e0(param_2,param_3,*(undefined4 *)(iVar2 + 0x10),

                           *(undefined4 *)(local_c + 0x10),iVar4,local_10);

      return iVar4;

    }

    iVar3 = FUN_006732c0(*(undefined4 *)(iVar2 + 0x18 + iVar4 * 4),0);

    iVar1 = param_3;

    if (0x1e < *(int *)(iVar3 + 0x10c)) {

      puVar5 = (undefined4 *)FUN_00673bc0(&param_3,iVar3);

      param_3 = *puVar5;

      FUN_006747d0(iVar3,param_3,&local_c,&local_10);

      iVar4 = FUN_006745e0(param_2,param_3,*(undefined4 *)(iVar2 + 0x10),

                           *(undefined4 *)(local_c + 0x10),iVar4,local_10);

      return iVar4;

    }

    iVar3 = FUN_00674500(iVar2,param_3,iVar3,iVar4);

    if (iVar3 == 0) {

      iVar4 = FUN_00674950(param_2,iVar1);

      return iVar4;

    }

  }

  else if (*(char *)(*(int *)(param_1 + 0x6d8) + 0x2c) != '\0') {

    FUN_00676eb0(param_2);

  }

  return iVar3;

}





// --- FUN_00674af0 at 0x00674AF0 (size: 20) ---


undefined4 __thiscall FUN_00674af0(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = FUN_00674950(param_2,param_1);

  return CONCAT31((int3)((uint)-iVar1 >> 8),'\x01' - (iVar1 != 0));

}





// --- FUN_00674b10 at 0x00674B10 (size: 82) ---


undefined4 __thiscall FUN_00674b10(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_006746d0(uVar1);

    if ((char)uVar1 == '\0') {

      return uVar1;

    }

  }

  puVar3 = (undefined4 *)(*param_1 + param_1[2] * 0x18);

  for (iVar2 = 6; 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_00674b70 at 0x00674B70 (size: 71) ---


uint __fastcall FUN_00674b70(int param_1)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  int local_4;

  

  uVar3 = *(uint *)(param_1 + 0x6d8);

  if (*(char *)(uVar3 + 0x2c) != '\0') {

    local_4 = param_1;

    puVar1 = (uint *)FUN_00676460(&local_4);

    uVar3 = *puVar1;

    if (DAT_008f86d8 != uVar3) {

      iVar2 = FUN_00674950(uVar3,param_1);

      return CONCAT31((int3)((uint)-iVar2 >> 8),'\x01' - (iVar2 != 0));

    }

  }

  return uVar3 & 0xffffff00;

}





// --- FUN_00674bc0 at 0x00674BC0 (size: 234) ---


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



{

  uint uVar1;

  undefined4 uVar2;

  int iVar3;

  uint uVar4;

  int iVar5;

  int iVar6;

  

  uVar1 = (uint)param_3;

  if ((param_3 <= param_4) && (iVar5 = *(int *)(param_2 + 0x10c), iVar5 < 0x3e)) {

    param_3 = (undefined4 *)0x0;

    FUN_00672d20(uVar1,param_2,&param_3);

    if ((int)param_3 <= iVar5) {

      iVar3 = param_2 + 0x110 + (int)param_3 * 0x18;

      iVar6 = (int)param_3;

      param_3 = (undefined4 *)(param_2 + 0x14 + (int)param_3 * 4);

      do {

        uVar4 = uVar1;

        if (((iVar6 < iVar5) && (uVar4 = *(uint *)(iVar3 + 4), uVar1 <= uVar4)) &&

           (uVar4 <= param_4)) {

          FUN_00674b10(iVar3);

        }

        if (*(int *)(param_2 + 0x14) != 0) {

          uVar2 = FUN_006732c0(*param_3,0);

          FUN_00674bc0(param_1,uVar2,uVar1,param_4);

        }

        if (param_4 < uVar4) {

          return;

        }

        param_3 = param_3 + 1;

        iVar5 = *(int *)(param_2 + 0x10c);

        iVar6 = iVar6 + 1;

        iVar3 = iVar3 + 0x18;

      } while (iVar6 <= iVar5);

    }

  }

  return;

}





// --- FUN_00674cb0 at 0x00674CB0 (size: 270) ---


void FUN_00674cb0(int *param_1,int param_2)



{

  int *piVar1;

  int iVar2;

  int *piVar3;

  char cVar4;

  undefined4 uVar5;

  int iVar6;

  int iVar7;

  undefined4 *puVar8;

  undefined4 *puVar9;

  

  iVar6 = param_2;

  piVar3 = param_1;

  piVar1 = (int *)(param_2 + 0x10c);

  if (*piVar1 < 0x3e) {

    iVar2 = *(int *)(param_2 + 0x10);

    param_2 = 0;

    if (0 < *piVar1) {

      param_1 = (int *)(iVar6 + 0x110);

      do {

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

LAB_00674d15:

          puVar8 = param_1;

          puVar9 = (undefined4 *)(*piVar3 + piVar3[2] * 0x18);

          for (iVar7 = 6; iVar7 != 0; iVar7 = iVar7 + -1) {

            *puVar9 = *puVar8;

            puVar8 = puVar8 + 1;

            puVar9 = puVar9 + 1;

          }

          piVar3[2] = piVar3[2] + 1;

        }

        else {

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

          cVar4 = FUN_006746d0(uVar5);

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

        }

        param_2 = param_2 + 1;

        param_1 = param_1 + 6;

      } while (param_2 < *(int *)(iVar6 + 0x10c));

    }

    if ((*(int *)(iVar6 + 0x14) != 0) && (param_2 = 0, -1 < *(int *)(iVar6 + 0x10c))) {

      iVar7 = 0x14;

      do {

        uVar5 = FUN_006732c0(*(undefined4 *)(iVar7 + iVar6),0);

        FUN_00674cb0(piVar3,uVar5);

        if (*(int *)(iVar6 + 0x10) != iVar2) {

          iVar6 = FUN_006732c0(iVar2,0);

        }

        param_2 = param_2 + 1;

        iVar7 = iVar7 + 4;

      } while (param_2 <= *(int *)(iVar6 + 0x10c));

    }

  }

  return;

}





// --- FUN_00674dc0 at 0x00674DC0 (size: 28) ---


bool __thiscall FUN_00674dc0(int param_1,undefined4 param_2)



{

  bool bVar1;

  

  bVar1 = *(int *)(param_1 + 0x10c) != 0;

  if (bVar1) {

    FUN_00674cb0(param_2,param_1);

  }

  return bVar1;

}





// --- FUN_00674de0 at 0x00674DE0 (size: 51) ---


undefined4 __thiscall FUN_00674de0(int param_1,int param_2,undefined4 param_3,undefined4 param_4)



{

  *(undefined4 *)(param_2 + 8) = 0;

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

    FUN_00674bc0(param_2,param_1,param_3,param_4);

  }

  return CONCAT31((int3)((uint)*(int *)(param_2 + 8) >> 8),*(int *)(param_2 + 8) != 0);

}





// --- FUN_00674e20 at 0x00674E20 (size: 25) ---


undefined4 * __fastcall FUN_00674e20(undefined4 *param_1)



{

  *param_1 = 0;

  FUN_00677be0();

  *(undefined1 *)(param_1 + 2) = 0;

  return param_1;

}





// --- FUN_00674e40 at 0x00674E40 (size: 8) ---


void FUN_00674e40(void)



{

  FUN_00677ca0();

  return;

}





// --- FUN_00674e50 at 0x00674E50 (size: 19) ---


void __fastcall FUN_00674e50(undefined4 *param_1)



{

  FUN_00677c70();

  *param_1 = 0;

  return;

}





// --- FUN_00674e70 at 0x00674E70 (size: 19) ---


void __fastcall FUN_00674e70(undefined4 *param_1)



{

  FUN_00677d20(*param_1,0x50,0x140);

  return;

}





// --- FUN_00674e90 at 0x00674E90 (size: 178) ---


void __thiscall FUN_00674e90(int *param_1,undefined4 param_2,uint param_3)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  int *local_4;

  

  iVar2 = 1;

  local_4 = param_1;

  iVar1 = FUN_00677cc0(&local_4,4,param_3);

  if (-1 < (int)local_4) {

    iVar2 = 1;

    uVar3 = param_3;

    do {

      if (iVar1 != 0) {

        return;

      }

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

        local_4 = *(int **)(*param_1 + 0x14);

        iVar2 = iVar2 + -1;

      }

      local_4 = (int *)((uint)local_4 | 0x80000000);

      FUN_00677d20(&local_4,4,uVar3);

      uVar3 = (uint)local_4 & 0x7fffffff;

      iVar2 = iVar2 + 1;

      iVar1 = FUN_00677cc0(&local_4,4,uVar3);

    } while (-1 < (int)local_4);

  }

  if ((iVar1 == 0) && (param_3 != *(uint *)(*param_1 + 0x14))) {

    *(uint *)(*param_1 + 0x14) = param_3;

    *(int *)(*param_1 + 0x1c) = *(int *)(*param_1 + 0x1c) + iVar2;

    FUN_00677d20(*param_1,0x50,0x140);

  }

  return;

}





// --- FUN_00674f50 at 0x00674F50 (size: 227) ---


void __thiscall FUN_00674f50(int *param_1,uint param_2,undefined4 param_3,int param_4,char param_5)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  int local_4;

  

  uVar1 = param_2;

  iVar2 = 0;

  local_4 = 0;

  uVar3 = param_2;

  if (param_2 != 0) {

    do {

      uVar3 = param_2;

      if (iVar2 != 0) {

        return;

      }

      iVar2 = FUN_00677cc0(&param_2,4,param_2);

      if (iVar2 == 0) {

        if ((param_5 == '\0') && ((int)param_2 < 0)) {

          iVar2 = -0x65;

        }

        else {

          param_2 = param_2 | 0x80000000;

          iVar2 = FUN_00677d20(&param_2,4,uVar3);

          param_2 = param_2 & 0x7fffffff;

          local_4 = local_4 + 1;

        }

      }

    } while (param_2 != 0);

    if (iVar2 != 0) {

      return;

    }

  }

  param_2 = uVar1 | 0x80000000;

  iVar2 = FUN_00677d20(&param_2,4,param_3);

  if (iVar2 == 0) {

    *(uint *)(*param_1 + 0x18) = uVar3;

    *(int *)(*param_1 + 0x1c) = local_4 + param_4;

    FUN_00677d20(*param_1,0x50,0x140);

  }

  return;

}





// --- FUN_00675040 at 0x00675040 (size: 270) ---


void __thiscall FUN_00675040(int *param_1,uint param_2)



{

  uint uVar1;

  undefined4 uVar2;

  int iVar3;

  uint *puVar4;

  int iVar5;

  uint uVar6;

  uint *puVar7;

  uint uVar8;

  

  iVar5 = *param_1;

  uVar1 = *(uint *)(iVar5 + 4);

  iVar3 = (int)param_2 / (int)uVar1;

  *(int *)(iVar5 + 0x1c) = *(int *)(iVar5 + 0x1c) + iVar3;

  puVar4 = (uint *)thunk_FUN_005df0f5(uVar1);

  puVar7 = puVar4;

  for (uVar6 = uVar1 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {

    *puVar7 = 0;

    puVar7 = puVar7 + 1;

  }

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

    *(undefined1 *)puVar7 = 0;

    puVar7 = (uint *)((int)puVar7 + 1);

  }

  uVar6 = *(uint *)(*param_1 + 8);

  param_2 = 0;

  uVar8 = uVar6;

  if (0 < iVar3) {

    do {

      uVar8 = uVar6;

      uVar6 = uVar8 + uVar1;

      *puVar4 = uVar6 | 0x80000000;

      iVar5 = FUN_00677d20(puVar4,uVar1,uVar8);

      if (iVar5 != 0) goto LAB_00675126;

      param_2 = param_2 + 1;

    } while ((int)param_2 < iVar3);

  }

  *puVar4 = 0x80000000;

  FUN_00677d20(puVar4,4,uVar8);

  iVar5 = *param_1;

  uVar2 = *(undefined4 *)(iVar5 + 0x18);

  param_2 = *(uint *)(iVar5 + 8) | 0x80000000;

  *(uint *)(iVar5 + 8) = uVar6;

  *(uint *)(*param_1 + 0x18) = uVar8;

  FUN_00677d20(&param_2,4,uVar2);

LAB_00675126:

  operator_delete__(puVar4);

  FUN_00677d20(*param_1,0x50,0x140);

  return;

}





// --- FUN_00675150 at 0x00675150 (size: 328) ---


void __thiscall FUN_00675150(int *param_1,undefined4 param_2,uint param_3)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  uint uVar4;

  int iVar5;

  uint *puVar6;

  uint uVar7;

  int local_14;

  uint local_10;

  int local_c;

  

  uVar3 = param_3;

  uVar4 = FUN_00406db0();

  if (uVar4 < 5) {

    uVar4 = 0;

  }

  else {

    iVar5 = FUN_00406db0();

    uVar4 = iVar5 - 4;

  }

  FUN_004074b0(4,1);

  puVar6 = (uint *)FUN_00406d80();

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

  local_10 = local_c - 4;

  local_14 = 1;

  iVar5 = FUN_00677cc0(&param_3,4,uVar3);

  uVar2 = param_3 & 0x7fffffff;

  while ((uVar4 != 0 && (iVar5 == 0))) {

    uVar1 = *puVar6;

    param_3 = uVar2;

    if (local_10 < uVar4) {

      FUN_00677cc0(&param_3,4,uVar2);

      param_3 = param_3 & 0x7fffffff;

      local_14 = local_14 + 1;

      uVar7 = uVar2;

    }

    else {

      local_c = uVar4 + 4;

      *(int *)(*param_1 + 0x1c) = *(int *)(*param_1 + 0x1c) - local_14;

      *(uint *)(*param_1 + 0x14) = uVar2;

      uVar7 = 0;

      FUN_00677d20(*param_1,0x50,0x140);

      local_10 = uVar4;

    }

    *puVar6 = uVar7;

    iVar5 = FUN_00677d20(puVar6,local_c,uVar3);

    uVar2 = param_3;

    if (iVar5 == 0) {

      *puVar6 = uVar1;

      uVar4 = uVar4 - local_10;

      puVar6 = (uint *)((int)puVar6 + local_10);

      uVar3 = uVar7;

    }

  }

  return;

}





// --- FUN_006752a0 at 0x006752A0 (size: 465) ---


uint __thiscall FUN_006752a0(int *param_1,undefined4 param_2,int param_3)



{

  bool bVar1;

  uint uVar2;

  int iVar3;

  int *piVar4;

  uint uVar5;

  int local_18;

  int local_14;

  uint local_10;

  uint local_c;

  int local_8;

  int local_4;

  

  uVar5 = 0;

  local_14 = param_3;

  local_18 = 0;

  uVar2 = FUN_00406db0();

  if (uVar2 < 5) {

    param_2 = 0;

  }

  else {

    iVar3 = FUN_00406db0();

    param_2 = iVar3 - 4;

  }

  FUN_004074b0(4,1);

  piVar4 = (int *)FUN_00406d80();

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

  local_c = local_8 - 4;

  bVar1 = false;

  uVar2 = param_2;

  while ((param_2 != 0 && (uVar5 == 0))) {

    local_4 = *piVar4;

    if (local_c < param_2) {

      if (bVar1) {

        local_10 = uVar5;

        FUN_00677cc0(&local_10,4,*(undefined4 *)(*param_1 + 0x14));

        local_10 = local_10 & 0x7fffffff;

        local_18 = *(int *)(*param_1 + 0x14);

        *(uint *)(*param_1 + 0x14) = local_10;

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

      }

      else {

        FUN_00677cc0(&local_18,4,local_14);

        param_2 = uVar2;

        if (local_18 == 0) {

          local_10 = 0;

          bVar1 = true;

          FUN_00677cc0(&local_10,4,*(undefined4 *)(*param_1 + 0x14));

          local_10 = local_10 & 0x7fffffff;

          local_18 = *(int *)(*param_1 + 0x14);

          *(uint *)(*param_1 + 0x14) = local_10;

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

        }

      }

    }

    else {

      if ((!bVar1) && (FUN_00677cc0(&local_18,4,local_14), local_18 != 0)) {

        FUN_00674f50(local_18,*(undefined4 *)(*param_1 + 0x18),*(undefined4 *)(*param_1 + 0x1c),0);

      }

      local_8 = param_2 + 4;

      local_18 = 0;

      local_c = param_2;

    }

    *piVar4 = local_18;

    uVar5 = FUN_00677d20(piVar4,local_8,local_14);

    if (uVar5 == 0) {

      *piVar4 = local_4;

      param_2 = param_2 - local_c;

      piVar4 = (int *)((int)piVar4 + local_c);

      uVar2 = param_2;

      local_14 = local_18;

    }

  }

  return uVar5;

}





// --- FUN_00675480 at 0x00675480 (size: 223) ---


char __thiscall FUN_00675480(int *param_1,undefined4 param_2,uint param_3,char param_4)



{

  uint *puVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  char local_5;

  

  local_5 = '\x01';

  FUN_004074b0(4,1);

  puVar1 = (uint *)FUN_00406d80();

  uVar2 = FUN_00406db0();

  if (uVar2 < 5) {

    iVar3 = 0;

  }

  else {

    iVar3 = FUN_00406db0();

    iVar3 = iVar3 + -4;

  }

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

  iVar5 = param_2 + -4;

  if (iVar3 == 0) {

    local_5 = '\x01';

  }

  else {

    do {

      if (param_3 == 0) break;

      if (local_5 == '\0') {

        return '\0';

      }

      uVar2 = *puVar1;

      if (iVar3 < iVar5) {

        param_2 = iVar3 + 4;

        iVar5 = iVar3;

      }

      iVar4 = FUN_00677cc0(puVar1,param_2,param_3);

      if (iVar4 == 0) {

        param_3 = *puVar1;

        *puVar1 = uVar2;

        iVar3 = iVar3 - iVar5;

        puVar1 = (uint *)((int)puVar1 + iVar5);

        if ((int)param_3 < 0) {

          param_3 = param_3 & 0x7fffffff;

          goto LAB_0067552c;

        }

      }

      else {

LAB_0067552c:

        local_5 = '\0';

      }

    } while (iVar3 != 0);

    if (local_5 == '\0') {

      return '\0';

    }

  }

  if (((param_3 != 0) || (iVar3 != 0)) && (param_4 == '\0')) {

    local_5 = '\0';

  }

  return local_5;

}





// --- FUN_00675560 at 0x00675560 (size: 117) ---


void FUN_00675560(undefined4 param_1,int *param_2,uint param_3)



{

  uint uVar1;

  byte *pbVar2;

  int iVar3;

  uint uVar4;

  

  uVar1 = param_3;

  uVar4 = param_3;

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

    uVar4 = *(uint *)(*param_2 + 4);

  }

  param_3 = uVar4 & 0xff;

  FUN_0040ad10(1);

  pbVar2 = (byte *)FUN_0040acf0(1);

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

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

      param_3 = (uint)*pbVar2;

    }

    else {

      *pbVar2 = (byte)uVar4;

    }

  }

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

    uVar4 = param_3;

  }

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

    iVar3 = FUN_00677ab0(uVar4);

    *param_2 = iVar3;

  }

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

    (*(code *)**(undefined4 **)*param_2)(uVar1);

  }

  return;

}





// --- FUN_006755e0 at 0x006755E0 (size: 156) ---


undefined4 FUN_006755e0(void)



{

  uint uVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  undefined1 local_34 [4];

  undefined1 local_30 [12];

  undefined1 local_24 [36];

  

  FUN_00401600(0);

  FUN_00675560(local_34,&stack0x00000004,local_24);

  FUN_0040a900(local_30);

  uVar1 = FUN_00406db0();

  if (uVar1 < 0x41) {

    uVar4 = 0x100;

    uVar2 = FUN_00406db0(0x100);

    uVar3 = FUN_00406d80(uVar2);

    uVar2 = FUN_00677d20(uVar3,uVar2,uVar4);

    FUN_00406f90();

    FUN_0040b060();

    return uVar2;

  }

  FUN_00406f90();

  FUN_0040b060();

  return 0xffffff9b;

}





// --- FUN_00675680 at 0x00675680 (size: 32) ---


void FUN_00675680(void)



{

  undefined1 local_c [12];

  

  FUN_00677220();

  FUN_006755e0(local_c);

  return;

}





// --- FUN_006756a0 at 0x006756A0 (size: 212) ---


int FUN_006756a0(int *param_1)



{

  int *piVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  int iVar4;

  undefined4 uVar5;

  undefined1 local_30 [12];

  undefined **local_24;

  uint local_20;

  undefined4 local_1c;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_00406d60();

  FUN_004074b0(0x40,1);

  uVar5 = 0x100;

  uVar2 = FUN_00406db0(0x100);

  uVar3 = FUN_00406d80(uVar2);

  iVar4 = FUN_00677cc0(uVar3,uVar2,uVar5);

  if (iVar4 == 0) {

    local_24 = &PTR_FUN_00793b3c;

    local_20 = 0;

    local_1c = 0;

    FUN_00406d60();

    local_c = 0;

    local_8 = 0;

    local_4 = 0;

    local_24 = &PTR_FUN_00793b50;

    FUN_0040b020(&PTR_PTR_008183b8,local_30);

    piVar1 = param_1;

    FUN_00675560(&param_1,param_1,&local_24);

    if (((local_20 >> 2 & 1) != 0) || (*(int *)(*piVar1 + 8) != 0x4c50)) {

      iVar4 = -0x65;

    }

    FUN_0040b060();

  }

  FUN_00406f90();

  return iVar4;

}





// --- FUN_00675780 at 0x00675780 (size: 398) ---


int __thiscall FUN_00675780(int *param_1,int param_2,uint param_3,int param_4,int param_5)



{

  uint uVar1;

  undefined4 uVar2;

  int iVar3;

  LONG LVar4;

  uint *puVar5;

  uint uVar6;

  undefined4 *puVar7;

  uint *puVar8;

  uint uVar9;

  uint uVar10;

  undefined4 uVar11;

  undefined4 uVar12;

  undefined4 uVar13;

  undefined1 auStack_c [12];

  

  *param_1 = param_2;

  uVar12 = 0;

  *(bool *)(param_1 + 2) = ((byte)param_5 & 2) == 2;

  uVar11 = param_4;

  uVar13 = param_5;

  uVar2 = FUN_00403350(&param_2,0);

  iVar3 = FUN_00677d80(uVar2,uVar11,uVar12,uVar13);

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

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

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

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

  }

  if (iVar3 == 0) {

    iVar3 = *param_1;

    uVar1 = *(uint *)(iVar3 + 4);

    param_4 = (*(int *)(iVar3 + 8) + -0x400) / (int)uVar1;

    *(int *)(iVar3 + 0x1c) = param_4;

    puVar5 = (uint *)thunk_FUN_005df0f5(uVar1);

    puVar8 = puVar5;

    for (uVar6 = uVar1 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {

      *puVar8 = 0;

      puVar8 = puVar8 + 1;

    }

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

      *(undefined1 *)puVar8 = 0;

      puVar8 = (uint *)((int)puVar8 + 1);

    }

    *(undefined4 *)(*param_1 + 0x14) = 0x400;

    uVar9 = 0x400;

    param_5 = 0;

    uVar6 = 0x400;

    uVar10 = uVar9;

    if (0 < param_4) {

      do {

        uVar9 = uVar10 + uVar1;

        *puVar5 = uVar9 | 0x80000000;

        param_3 = uVar10;

        param_2 = FUN_00677d20(puVar5,uVar1,uVar10);

        if (param_2 != 0) {

          operator_delete__(puVar5);

          return param_2;

        }

        param_5 = param_5 + 1;

        param_2 = 0;

        uVar10 = uVar9;

      } while (param_5 < param_4);

      param_2 = 0;

      uVar6 = param_3;

    }

    *(uint *)(*param_1 + 0x18) = uVar6;

    *puVar5 = 0x80000000;

    param_2 = FUN_00677d20(puVar5,4,uVar6);

    *(uint *)(*param_1 + 8) = uVar9;

    operator_delete__(puVar5);

    iVar3 = param_2;

    if ((param_2 == 0) && (iVar3 = FUN_00677d20(*param_1,0x50,0x140), iVar3 == 0)) {

      FUN_00677220();

      FUN_006755e0(auStack_c);

      iVar3 = 0;

    }

    return iVar3;

  }

  return iVar3;

}





// --- FUN_00675920 at 0x00675920 (size: 169) ---


void __thiscall

FUN_00675920(undefined4 *param_1,int *param_2,undefined4 param_3,undefined4 param_4,int param_5,

            undefined4 param_6)



{

  int *piVar1;

  undefined4 uVar2;

  LONG LVar3;

  int iVar4;

  int *piVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined4 uVar8;

  

  piVar1 = param_2;

  uVar7 = 0;

  *param_1 = param_2;

  *(bool *)(param_1 + 2) = ((byte)param_5 & 2) == 2;

  uVar6 = param_4;

  uVar8 = param_5;

  uVar2 = FUN_00403350(&param_2,0);

  param_5 = FUN_00677d80(uVar2,uVar6,uVar7,uVar8);

  piVar5 = param_2 + -5;

  LVar3 = InterlockedDecrement(param_2 + -4);

  if ((LVar3 == 0) && (piVar5 != (int *)0x0)) {

    (**(code **)*piVar5)(1);

  }

  if (param_5 == 0) {

    iVar4 = FUN_00677cc0(piVar1,0x50,0x140);

    if (*piVar1 != 0x5442) {

      FUN_00677c70();

      iVar4 = -0x66;

    }

    if (iVar4 == 0) {

      FUN_006756a0(param_6);

    }

  }

  return;

}





// --- FUN_006759d0 at 0x006759D0 (size: 114) ---


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



{

  undefined4 *puVar1;

  uint uVar2;

  uint uVar3;

  undefined4 *puVar4;

  

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  *param_1 = *param_2;

  param_1[1] = param_2[1];

  param_1[2] = param_2[2];

  param_1[3] = param_2[3];

  param_1[4] = param_2[4];

  if ((param_2[7] != 0) && (param_1[1] != 0)) {

    puVar1 = (undefined4 *)thunk_FUN_005df0f5(param_1[1]);

    uVar3 = param_1[1];

    param_1[7] = puVar1;

    puVar4 = (undefined4 *)param_2[7];

    for (uVar2 = uVar3 >> 2; uVar2 != 0; uVar2 = uVar2 - 1) {

      *puVar1 = *puVar4;

      puVar4 = puVar4 + 1;

      puVar1 = puVar1 + 1;

    }

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

      *(undefined1 *)puVar1 = *(undefined1 *)puVar4;

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

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

    }

    param_1[5] = param_1[7];

    param_1[6] = param_1[7] + 0x10;

  }

  return param_1;

}





// --- FUN_00675a50 at 0x00675A50 (size: 85) ---


void __thiscall FUN_00675a50(int param_1,int param_2)



{

  undefined4 *puVar1;

  

  if ((*(int *)(param_1 + 0x1c) == 0) && (0 < param_2)) {

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

    *(uint *)(param_1 + 8) = param_2 - 0x10U >> 2;

    puVar1 = (undefined4 *)thunk_FUN_005df0f5(param_2);

    *(undefined4 **)(param_1 + 0x1c) = puVar1;

    *(undefined4 **)(param_1 + 0x14) = puVar1;

    *puVar1 = 0;

    puVar1[1] = 0;

    puVar1[2] = 0;

    puVar1[3] = 0;

    *(int *)(param_1 + 0x18) = *(int *)(param_1 + 0x1c) + 0x10;

  }

  return;

}





// --- FUN_00675ab0 at 0x00675AB0 (size: 67) ---


undefined1 __fastcall FUN_00675ab0(char *param_1)



{

  int iVar1;

  undefined1 uVar2;

  

  uVar2 = 0;

  if ((((*param_1 == '\0') && (*(int *)(param_1 + 0xf4) == 0)) && (*(int *)(param_1 + 0xf8) == 0))

     && (((iVar1 = *(int *)(param_1 + 0x100), *(int *)(iVar1 + 0x24) == 0 &&

          (*(int *)(iVar1 + 0x28) == 0)) && (*(char *)(iVar1 + 0x2c) != '\0')))) {

    uVar2 = 1;

    *param_1 = '\x01';

    param_1[1] = '\x01';

  }

  return uVar2;

}





// --- FUN_00675b00 at 0x00675B00 (size: 54) ---


undefined4 * __thiscall FUN_00675b00(undefined4 *param_1,int param_2)



{

  param_1[7] = 0;

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0xffffffff;

  param_1[5] = 0;

  param_1[6] = 0;

  if (0 < param_2) {

    FUN_00675a50(param_2);

  }

  return param_1;

}





// --- FUN_00675b40 at 0x00675B40 (size: 64) ---


void __thiscall FUN_00675b40(int param_1,int *param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  

  iVar3 = *(int *)(param_1 + 0x10);

  iVar2 = DAT_008f86e0;

  while ((-1 < iVar3 && (DAT_008f86e0 == iVar2))) {

    piVar1 = (int *)(*(int *)(param_1 + 0x18) + *(int *)(param_1 + 0x10) * 4);

    iVar2 = *piVar1;

    *piVar1 = DAT_008f86e0;

    iVar3 = *(int *)(param_1 + 0x10) + -1;

    *(int *)(param_1 + 0x10) = iVar3;

  }

  *param_2 = iVar2;

  return;

}





// --- FUN_00675b80 at 0x00675B80 (size: 80) ---


void __thiscall FUN_00675b80(int param_1,int *param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  

  iVar2 = DAT_008f86e0;

  if (*(int *)(param_1 + 0xc) < *(int *)(*(int *)(param_1 + 0x14) + 0xc)) {

    do {

      if (DAT_008f86e0 != iVar2) break;

      piVar1 = (int *)(*(int *)(param_1 + 0x18) + *(int *)(param_1 + 0xc) * 4);

      iVar2 = *piVar1;

      *piVar1 = DAT_008f86e0;

      iVar3 = *(int *)(param_1 + 0xc) + 1;

      *(int *)(param_1 + 0xc) = iVar3;

    } while (iVar3 < *(int *)(*(int *)(param_1 + 0x14) + 0xc));

  }

  *param_2 = iVar2;

  return;

}





// --- FUN_00675bd0 at 0x00675BD0 (size: 93) ---


int * __thiscall FUN_00675bd0(int param_1,int *param_2)



{

  int iVar1;

  

  iVar1 = DAT_008f86e0;

  if (*(int *)(param_1 + 0xc) < *(int *)(*(int *)(param_1 + 0x14) + 0xc)) {

    do {

      if (DAT_008f86e0 != *(int *)(*(int *)(param_1 + 0x18) + *(int *)(param_1 + 0xc) * 4)) break;

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

    } while (*(int *)(param_1 + 0xc) < *(int *)(*(int *)(param_1 + 0x14) + 0xc));

  }

  if (*(int *)(*(int *)(param_1 + 0x14) + 0xc) <= *(int *)(param_1 + 0xc)) {

    *param_2 = iVar1;

    return param_2;

  }

  *param_2 = *(int *)(*(int *)(param_1 + 0x18) + *(int *)(param_1 + 0xc) * 4);

  return param_2;

}





// --- FUN_00675c40 at 0x00675C40 (size: 344) ---


char __fastcall FUN_00675c40(char *param_1)



{

  char cVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 local_14;

  undefined4 local_10;

  

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

  if (((*param_1 == '\0') && (*(int *)(param_1 + 0xf4) == 0)) && (*(int *)(param_1 + 0xf8) == 0)) {

    if (*(int *)(*(int *)(param_1 + 0x100) + 0x24) != 0) {

      iVar2 = FUN_005df0f5(0x20);

      if (iVar2 == 0) {

        puVar3 = (undefined4 *)0x0;

      }

      else {

        puVar3 = (undefined4 *)FUN_00675b00(*(undefined4 *)(*(int *)(param_1 + 0x100) + 4));

      }

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

      *puVar3 = *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x24);

      FUN_004073b0(*(undefined4 *)(*(int *)(param_1 + 0xf4) + 0x1c),

                   *(undefined4 *)(*(int *)(param_1 + 0xf4) + 4));

      FUN_00675480(&local_14,**(undefined4 **)(param_1 + 0xf4),0);

      param_1[1] = '\0';

      if (*(int *)(*(int *)(param_1 + 0x100) + 0x24) != *(int *)(*(int *)(param_1 + 0x100) + 0x28))

      {

        iVar2 = FUN_005df0f5(0x20);

        if (iVar2 == 0) {

          puVar3 = (undefined4 *)0x0;

        }

        else {

          puVar3 = (undefined4 *)FUN_00675b00(*(undefined4 *)(*(int *)(param_1 + 0x100) + 4));

        }

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

        *puVar3 = *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x28);

        FUN_004073b0(*(undefined4 *)(*(int *)(param_1 + 0xf8) + 0x1c),

                     *(undefined4 *)(*(int *)(param_1 + 0xf8) + 4));

        FUN_00675480(&local_14,**(undefined4 **)(param_1 + 0xf8),0);

        *param_1 = '\x01';

        goto LAB_00675d7c;

      }

      *(undefined4 *)(param_1 + 0xf8) = *(undefined4 *)(param_1 + 0xf4);

    }

    *param_1 = '\x01';

  }

  else {

    *param_1 = '\0';

  }

LAB_00675d7c:

  cVar1 = *param_1;

  FUN_00406f90();

  FUN_00406f90();

  return cVar1;

}





// --- FUN_00675da0 at 0x00675DA0 (size: 143) ---


undefined4 __thiscall FUN_00675da0(int param_1,undefined4 param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  undefined4 local_14;

  undefined4 local_10;

  

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

  iVar2 = *(int *)(param_1 + 0xf4);

  if (((*(int *)(iVar2 + 0x14) != 0) && (*(int *)(iVar2 + 0x18) != 0)) &&

     (iVar3 = *(int *)(*(int *)(iVar2 + 0x14) + 0xc), iVar3 < *(int *)(iVar2 + 8))) {

    *(undefined4 *)(*(int *)(iVar2 + 0x18) + iVar3 * 4) = param_2;

    piVar1 = (int *)(*(int *)(iVar2 + 0x14) + 0xc);

    *piVar1 = *piVar1 + 1;

  }

  FUN_004073b0(*(undefined4 *)(*(int *)(param_1 + 0xf4) + 0x1c),

               *(undefined4 *)(*(int *)(param_1 + 0xf4) + 4));

  FUN_006752a0(&local_14,**(undefined4 **)(param_1 + 0xf4));

  FUN_00406f90();

  FUN_00406f90();

  return 1;

}





// --- FUN_00675e30 at 0x00675E30 (size: 308) ---


uint __thiscall FUN_00675e30(int param_1,int param_2)



{

  int *piVar1;

  int iVar2;

  undefined4 *puVar3;

  int iVar4;

  uint uVar5;

  undefined4 local_14;

  undefined4 local_10;

  

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

  iVar2 = **(int **)(param_1 + 0xf4);

  if ((iVar2 != 0) && (*(int *)(param_2 + 0xc) == iVar2)) {

    *(undefined4 *)((*(int **)(param_1 + 0xf4))[5] + 4) = *(undefined4 *)(param_2 + 0x10);

    FUN_004073b0(*(undefined4 *)(*(int *)(param_1 + 0xf4) + 0x1c),

                 *(undefined4 *)(*(int *)(param_1 + 0xf4) + 4));

    FUN_006752a0(&local_14,**(undefined4 **)(param_1 + 0xf4));

  }

  if (*(int *)(*(int *)(param_1 + 0x100) + 0x14) == *(int *)(param_2 + 0x10)) {

    *(int *)(*(int *)(param_1 + 0x100) + 0x24) = *(int *)(param_2 + 0x10);

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

    if (puVar3[7] != 0) {

      *puVar3 = 0;

      puVar3[3] = 0;

      puVar3[4] = 0xffffffff;

      puVar3 = (undefined4 *)puVar3[5];

      *puVar3 = 0;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0;

    }

    iVar2 = *(int *)(param_1 + 0xf4);

    if (((*(int *)(iVar2 + 0x14) != 0) && (*(int *)(iVar2 + 0x18) != 0)) &&

       (iVar4 = *(int *)(*(int *)(iVar2 + 0x14) + 0xc), iVar4 < *(int *)(iVar2 + 8))) {

      *(undefined4 *)(*(int *)(iVar2 + 0x18) + iVar4 * 4) = *(undefined4 *)(param_2 + 0x14);

      piVar1 = (int *)(*(int *)(iVar2 + 0x14) + 0xc);

      *piVar1 = *piVar1 + 1;

    }

    *(undefined4 *)(*(int *)(*(int *)(param_1 + 0xf4) + 0x14) + 8) = *(undefined4 *)(param_2 + 0xc);

    **(undefined4 **)(param_1 + 0xf4) = *(undefined4 *)(param_2 + 0x10);

    FUN_004073b0(*(undefined4 *)(*(int *)(param_1 + 0xf4) + 0x1c),

                 *(undefined4 *)(*(int *)(param_1 + 0xf4) + 4));

    FUN_00675150(&local_14,**(undefined4 **)(param_1 + 0xf4));

  }

  FUN_00406f90();

  uVar5 = FUN_00406f90();

  return uVar5 & 0xffffff00;

}





// --- FUN_00675f70 at 0x00675F70 (size: 358) ---


char __thiscall FUN_00675f70(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  undefined4 local_34;

  undefined4 local_30;

  undefined4 local_20;

  undefined4 local_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  int local_c;

  undefined4 local_8;

  void *local_4;

  

  local_34 = 0;

  local_30 = 0;

  FUN_00406d60();

  iVar2 = *(int *)(*(int *)(param_1 + 0x100) + 4);

  local_4 = (void *)0x0;

  local_20 = 0;

  local_1c = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0xffffffff;

  local_c = 0;

  local_8 = 0;

  if (0 < iVar2) {

    FUN_00675a50(iVar2);

  }

  iVar1 = local_c;

  FUN_004073b0(local_4,local_1c);

  iVar2 = *(int *)(param_2 + 0x10);

  if (iVar2 == 0) {

    if (*(int *)(param_2 + 0xc) == *(int *)(*(int *)(param_1 + 0x100) + 0x28)) {

      *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x28) = *(undefined4 *)(param_2 + 0x14);

    }

  }

  else {

    FUN_00675480(&local_34,iVar2,0);

    if (*(int *)(param_2 + 0xc) == *(int *)(iVar1 + 4)) {

      *(undefined4 *)(iVar1 + 4) = *(undefined4 *)(param_2 + 0x14);

      FUN_006752a0(&local_34,iVar2);

    }

  }

  iVar2 = *(int *)(param_2 + 0x14);

  if (iVar2 == 0) {

    if (*(int *)(param_2 + 0xc) == *(int *)(*(int *)(param_1 + 0x100) + 0x24)) {

      *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x24) = *(undefined4 *)(param_2 + 0x10);

    }

  }

  else {

    FUN_00675480(&local_34,iVar2,0);

    if (*(int *)(param_2 + 0xc) == *(int *)(iVar1 + 8)) {

      *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(param_2 + 0x10);

      FUN_006752a0(&local_34,iVar2);

    }

  }

  iVar2 = FUN_00674f50(*(undefined4 *)(param_2 + 0xc),

                       *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x18),

                       *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x1c),1);

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

    operator_delete__(local_4);

  }

  FUN_00406f90();

  FUN_00406f90();

  return '\x01' - (iVar2 != 0);

}





// --- FUN_006760e0 at 0x006760E0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007fed0c;

  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_00676120 at 0x00676120 (size: 276) ---


uint __thiscall FUN_00676120(int param_1,undefined4 param_2,char param_3)



{

  undefined4 *puVar1;

  int iVar2;

  uint uVar3;

  undefined1 local_18 [12];

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  if (*(int *)(param_1 + 0xf8) == 0) {

    puVar1 = (undefined4 *)FUN_005df0f5(0x20);

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

      puVar1 = (undefined4 *)0x0;

    }

    else {

      iVar2 = *(int *)(*(int *)(param_1 + 0x100) + 4);

      puVar1[7] = 0;

      *puVar1 = 0;

      puVar1[1] = 0;

      puVar1[2] = 0;

      puVar1[3] = 0;

      puVar1[4] = 0xffffffff;

      puVar1[5] = 0;

      puVar1[6] = 0;

      if (0 < iVar2) {

        FUN_00675a50(iVar2);

      }

    }

    *(undefined4 **)(param_1 + 0xf4) = puVar1;

    *(undefined4 **)(param_1 + 0xf8) = puVar1;

    *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x28) =

         *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x14);

    *(undefined1 *)(param_1 + 1) = 0;

  }

  else if (*(int *)(param_1 + 0xf8) == *(int *)(param_1 + 0xf4)) {

    iVar2 = FUN_005df0f5(0x20);

    if (iVar2 == 0) {

      iVar2 = 0;

    }

    else {

      iVar2 = FUN_006759d0(*(undefined4 *)(param_1 + 0xf4));

    }

    *(int *)(param_1 + 0xf8) = iVar2;

    *(undefined4 *)(*(int *)(iVar2 + 0x14) + 4) = *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x14);

  }

  FUN_00677920();

  local_c = **(undefined4 **)(param_1 + 0xf4);

  local_8 = *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x14);

  local_4 = param_2;

  FUN_006755e0(local_18);

  uVar3 = FUN_00675e30(local_18);

  if (param_3 != '\0') {

    uVar3 = FUN_00675680();

  }

  return uVar3 & 0xffffff00;

}





// --- FUN_00676240 at 0x00676240 (size: 535) ---


uint __thiscall FUN_00676240(int param_1,undefined4 *param_2,char param_3)



{

  int iVar1;

  undefined4 *puVar2;

  int *piVar3;

  uint uVar4;

  undefined4 uVar5;

  undefined4 local_2c;

  undefined4 local_28;

  undefined1 local_18 [12];

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  local_2c = 0;

  local_28 = 0;

  FUN_00406d60();

  FUN_006772a0();

  local_c = *param_2;

  local_8 = *(undefined4 *)(param_2[5] + 8);

  local_4 = *(undefined4 *)(param_2[5] + 4);

  FUN_006755e0(local_18);

  FUN_00675f70(local_18);

  if (param_3 != '\0') {

    FUN_00675680();

  }

  iVar1 = *(int *)(param_2[5] + 4);

  if (*(int *)(param_2[5] + 8) == 0) {

    if (iVar1 == 0) {

      puVar2 = *(undefined4 **)(param_1 + 0xf8);

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

        *puVar2 = 0;

        puVar2[1] = 0;

        puVar2[2] = 0;

        puVar2[3] = 0;

        puVar2[4] = 0xffffffff;

        puVar2[5] = 0;

        puVar2[6] = 0;

        if ((void *)puVar2[7] != (void *)0x0) {

          operator_delete__((void *)puVar2[7]);

          puVar2[7] = 0;

        }

        operator_delete(puVar2);

      }

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

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

      goto LAB_006763d1;

    }

    puVar2 = *(undefined4 **)(param_1 + 0xf8);

    if (puVar2[7] != 0) {

      *puVar2 = 0;

      puVar2[3] = 0;

      puVar2[4] = 0xffffffff;

      puVar2 = (undefined4 *)puVar2[5];

      *puVar2 = 0;

      puVar2[1] = 0;

      puVar2[2] = 0;

      puVar2[3] = 0;

    }

    **(undefined4 **)(param_1 + 0xf8) = *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x28);

    FUN_004073b0(*(undefined4 *)(*(int *)(param_1 + 0xf8) + 0x1c),

                 *(undefined4 *)(*(int *)(param_1 + 0xf8) + 4));

    uVar5 = **(undefined4 **)(param_1 + 0xf8);

  }

  else {

    if (iVar1 != 0) goto LAB_006763d1;

    puVar2 = *(undefined4 **)(param_1 + 0xf4);

    if (puVar2[7] != 0) {

      *puVar2 = 0;

      puVar2[3] = 0;

      puVar2[4] = 0xffffffff;

      puVar2 = (undefined4 *)puVar2[5];

      *puVar2 = 0;

      puVar2[1] = 0;

      puVar2[2] = 0;

      puVar2[3] = 0;

    }

    **(undefined4 **)(param_1 + 0xf4) = *(undefined4 *)(*(int *)(param_1 + 0x100) + 0x24);

    FUN_004073b0(*(undefined4 *)(*(int *)(param_1 + 0xf4) + 0x1c),

                 *(undefined4 *)(*(int *)(param_1 + 0xf4) + 4));

    uVar5 = **(undefined4 **)(param_1 + 0xf4);

  }

  FUN_00675480(&local_2c,uVar5,0);

LAB_006763d1:

  if ((*(int **)(param_1 + 0xf4) != (int *)0x0) &&

     (piVar3 = *(int **)(param_1 + 0xf8), **(int **)(param_1 + 0xf4) == *piVar3)) {

    if (piVar3 != (int *)0x0) {

      *piVar3 = 0;

      piVar3[1] = 0;

      piVar3[2] = 0;

      piVar3[3] = 0;

      piVar3[4] = -1;

      piVar3[5] = 0;

      piVar3[6] = 0;

      if ((void *)piVar3[7] != (void *)0x0) {

        operator_delete__((void *)piVar3[7]);

        piVar3[7] = 0;

      }

      operator_delete(piVar3);

    }

    *(int *)(param_1 + 0xf8) = *(int *)(param_1 + 0xf4);

    *(undefined4 *)(*(int *)(*(int *)(param_1 + 0xf4) + 0x14) + 4) = 0;

    *(undefined4 *)(*(int *)(*(int *)(param_1 + 0xf8) + 0x14) + 8) = 0;

  }

  FUN_00406f90();

  uVar4 = FUN_00406f90();

  return uVar4 & 0xffffff00;

}





// --- FUN_00676460 at 0x00676460 (size: 467) ---


uint * __thiscall FUN_00676460(int param_1,uint *param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  bool bVar4;

  uint *puVar5;

  undefined4 *puVar6;

  uint uVar7;

  undefined1 local_20 [4];

  undefined1 local_1c [4];

  undefined1 local_18 [4];

  undefined4 local_14;

  undefined4 local_10;

  

  uVar7 = DAT_008f86e0;

  bVar4 = false;

  local_14 = 0;

  local_10 = 0;

  FUN_00406d60();

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

    do {

      if (DAT_008f86e0 != uVar7) break;

      puVar5 = (uint *)FUN_00675bd0(local_20);

      uVar7 = *puVar5;

      if (DAT_008f86e0 == uVar7) {

        if (bVar4) {

          FUN_004073b0(*(undefined4 *)(*(int *)(param_1 + 0xf4) + 0x1c),

                       *(undefined4 *)(*(int *)(param_1 + 0xf4) + 4));

          FUN_006752a0(&local_14,**(undefined4 **)(param_1 + 0xf4));

          bVar4 = false;

        }

        FUN_00676240(*(undefined4 *)(param_1 + 0xf8),1);

      }

      else {

        for (puVar5 = *(uint **)(*(int *)(param_1 + 0x68) + (uVar7 % *(uint *)(param_1 + 0x70)) * 4)

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

          if (*puVar5 == uVar7) {

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

              puVar6 = (undefined4 *)FUN_00675b80(local_1c);

              iVar2 = *(int *)(param_1 + 0xf4);

              if (((*(int *)(iVar2 + 0x14) == 0) || (*(int *)(iVar2 + 0x18) == 0)) ||

                 (*(int *)(iVar2 + 8) <= *(int *)(*(int *)(iVar2 + 0x14) + 0xc))) {

                FUN_00676120(*puVar6,0);

                bVar4 = false;

                uVar7 = DAT_008f86e0;

              }

              else {

                if (((*(int *)(iVar2 + 0x14) != 0) && (*(int *)(iVar2 + 0x18) != 0)) &&

                   (iVar3 = *(int *)(*(int *)(iVar2 + 0x14) + 0xc), iVar3 < *(int *)(iVar2 + 8))) {

                  *(undefined4 *)(*(int *)(iVar2 + 0x18) + iVar3 * 4) = *puVar6;

                  piVar1 = (int *)(*(int *)(iVar2 + 0x14) + 0xc);

                  *piVar1 = *piVar1 + 1;

                }

                bVar4 = true;

                uVar7 = DAT_008f86e0;

              }

              goto LAB_006765d5;

            }

            break;

          }

        }

        for (puVar5 = *(uint **)(*(int *)(param_1 + 0xe4) + (uVar7 % *(uint *)(param_1 + 0xec)) * 4)

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

          if (*puVar5 == uVar7) {

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

              FUN_00675b80(local_18);

              uVar7 = DAT_008f86e0;

            }

            break;

          }

        }

      }

LAB_006765d5:

    } while (*(int *)(param_1 + 0xf8) != 0);

    if (bVar4) {

      FUN_004073b0(*(undefined4 *)(*(int *)(param_1 + 0xf4) + 0x1c),

                   *(undefined4 *)(*(int *)(param_1 + 0xf4) + 4));

      FUN_006752a0(&local_14,**(undefined4 **)(param_1 + 0xf4));

    }

  }

  *param_2 = uVar7;

  FUN_00406f90();

  FUN_00406f90();

  return param_2;

}





// --- FUN_00676640 at 0x00676640 (size: 143) ---


undefined4 * __thiscall FUN_00676640(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_007fed0c;

  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_006766d0 at 0x006766D0 (size: 202) ---


uint __thiscall FUN_006766d0(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_006768b0(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_0067671e;

      }

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

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

    }

    piVar5 = (int *)0x0;

    iVar4 = 0;

LAB_0067671e:

    iVar3 = *piVar5;

    if (iVar3 == iVar4) {

LAB_00676731:

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

    }

    else {

      do {

        iVar2 = iVar3;

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

      } while (iVar3 != iVar4);

      if (iVar2 == 0) goto LAB_00676731;

      *(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_006767a0 at 0x006767A0 (size: 73) ---


void __fastcall FUN_006767a0(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_006766d0(*puVar2);

  return;

}





// --- FUN_006767f0 at 0x006767F0 (size: 83) ---


uint * __thiscall FUN_006767f0(int param_1,uint *param_2)



{

  uint *puVar1;

  

  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 (uint *)0x0;

      }

    }

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

      FUN_00410880(puVar1 + 2);

      FUN_004171e0(param_2);

    }

  }

  return puVar1;

}





// --- FUN_00676850 at 0x00676850 (size: 81) ---


void __fastcall FUN_00676850(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_005870f0();

  return;

}





// --- FUN_006768b0 at 0x006768B0 (size: 62) ---


void __thiscall FUN_006768b0(int param_1,uint *param_2)



{

  uint *puVar1;

  

  if (*(int *)(param_1 + 0x68) * 2 < *(int *)(param_1 + 0x6c) + 1) {

    FUN_006767a0();

  }

  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_006768f0 at 0x006768F0 (size: 102) ---


uint __thiscall FUN_006768f0(int param_1,undefined4 param_2)



{

  int iVar1;

  void *pvVar2;

  uint uVar3;

  

  pvVar2 = (void *)FUN_004171e0(&param_2);

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

    operator_delete(pvVar2);

  }

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

  if ((((iVar1 != 0) && (*(int *)(iVar1 + 0x14) != 0)) && (*(int *)(iVar1 + 0x18) != 0)) &&

     (*(int *)(*(int *)(iVar1 + 0x14) + 0xc) < *(int *)(iVar1 + 8))) {

    uVar3 = FUN_00675da0(param_2);

    return uVar3 & 0xffffff00;

  }

  uVar3 = FUN_00676120(param_2,0);

  return uVar3 & 0xffffff00;

}





// --- FUN_00676960 at 0x00676960 (size: 627) ---


void __thiscall FUN_00676960(int param_1,uint param_2,int param_3)



{

  int iVar1;

  uint *puVar2;

  int iVar3;

  int *piVar4;

  int *piVar5;

  int *piVar6;

  int *local_58;

  undefined4 local_54;

  undefined4 local_50;

  int local_40;

  undefined4 local_3c;

  undefined4 local_38;

  int local_34;

  int local_30;

  undefined4 local_2c;

  undefined4 local_28;

  void *local_24;

  int local_20;

  undefined4 local_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  void *local_4;

  

  iVar3 = *(int *)(*(int *)(param_1 + 0x100) + 4);

  local_24 = (void *)0x0;

  local_40 = 0;

  local_3c = 0;

  local_38 = 0;

  local_34 = 0;

  local_30 = 0xffffffff;

  local_2c = 0;

  local_28 = 0;

  if (0 < iVar3) {

    FUN_00675a50(iVar3);

  }

  iVar3 = *(int *)(*(int *)(param_1 + 0x100) + 4);

  local_4 = (void *)0x0;

  local_20 = 0;

  local_1c = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0xffffffff;

  local_c = 0;

  local_8 = 0;

  if (0 < iVar3) {

    FUN_00675a50(iVar3);

  }

  local_58 = &local_20;

  piVar5 = &local_40;

  piVar6 = &local_40;

  local_54 = 0;

  local_50 = 0;

  FUN_00406d60();

  iVar3 = param_2;

  local_40 = param_2;

  FUN_004073b0(local_24,local_3c);

  FUN_00675480(&local_54,iVar3,0);

  local_34 = param_3;

  local_30 = param_3 + -1;

  puVar2 = (uint *)FUN_00675b40(&param_2);

  param_2 = *puVar2;

  if (DAT_008f86e0 != param_2) {

    do {

      piVar4 = local_58;

      for (puVar2 = *(uint **)(*(int *)(param_1 + 0xe4) + (param_2 % *(uint *)(param_1 + 0xec)) * 4)

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

        if (*puVar2 == param_2) {

          if (puVar2 != (uint *)0x0) goto LAB_00676ab2;

          break;

        }

      }

      if (0 < piVar6[3]) {

        iVar3 = piVar6[3] + -1;

        piVar6[3] = iVar3;

        *(uint *)(piVar6[6] + iVar3 * 4) = param_2;

      }

      FUN_00587370(&param_2);

LAB_00676ab2:

      if (piVar6[3] < 1) {

        FUN_004073b0(piVar6[7],piVar6[1]);

        FUN_006752a0(&local_54,*piVar6);

      }

      if (piVar5[4] < 0) {

        if (piVar5 == piVar6) {

          local_58 = (int *)0x0;

        }

        else {

          *(undefined4 *)(piVar6[5] + 8) = *(undefined4 *)(piVar5[5] + 8);

          FUN_00676240(piVar5,1);

          piVar4 = piVar5;

        }

        piVar5 = piVar4;

        if (*(int *)(piVar6[5] + 8) != 0) {

          *piVar4 = *(int *)(piVar6[5] + 8);

          FUN_004073b0(piVar4[7],piVar4[1]);

          FUN_00675480(&local_54,*piVar4,0);

          iVar3 = *(int *)(piVar4[5] + 0xc);

          piVar4[4] = iVar3 + -1;

          piVar4[3] = iVar3;

        }

      }

      piVar4 = piVar6;

      if (piVar6[3] < 1) {

        piVar4 = piVar5;

        local_58 = piVar6;

      }

      iVar3 = piVar5[4];

      param_2 = DAT_008f86e0;

      while ((-1 < iVar3 && (DAT_008f86e0 == param_2))) {

        iVar1 = piVar5[4];

        param_2 = *(uint *)(piVar5[6] + iVar1 * 4);

        iVar3 = iVar1 + -1;

        *(uint *)(piVar5[6] + iVar1 * 4) = DAT_008f86e0;

        piVar5[4] = iVar3;

      }

      piVar6 = piVar4;

    } while (DAT_008f86e0 != param_2);

  }

  FUN_00406f90();

  FUN_00406f90();

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

    operator_delete__(local_4);

  }

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

    operator_delete__(local_24);

  }

  return;

}





// --- FUN_00676be0 at 0x00676BE0 (size: 68) ---


undefined4 __fastcall FUN_00676be0(int param_1)



{

  int iVar1;

  void *pvVar2;

  

  if (*(int *)(param_1 + 0x6c) == 0) {

    return 0;

  }

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

  if (iVar1 != 0) {

    FUN_00410880(iVar1);

    if (iVar1 != 0) {

      pvVar2 = (void *)(iVar1 + -8);

      goto LAB_00676c06;

    }

  }

  pvVar2 = (void *)0x0;

LAB_00676c06:

  FUN_004171e0(pvVar2);

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

    operator_delete(pvVar2);

  }

  return 1;

}





// --- FUN_00676c30 at 0x00676C30 (size: 120) ---


uint __thiscall FUN_00676c30(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_00676c5b:

      if ((int)(*(uint *)(param_1 + 0x68) * 2) < *(int *)(param_1 + 0x6c) + 1) {

        FUN_006767a0();

      }

      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_00676c5b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00676cb0 at 0x00676CB0 (size: 124) ---


undefined4 __thiscall FUN_00676cb0(int param_1,uint *param_2)



{

  uint *puVar1;

  undefined3 uVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

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

LAB_00676cdb:

      FUN_00676c30(param_2);

LAB_00676ce3:

      puVar1 = param_2 + 2;

      *puVar1 = *(uint *)(param_1 + 0x70);

      uVar2 = (undefined3)((uint)puVar1 >> 8);

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

        *(uint **)(*(int *)(param_1 + 0x70) + 4) = puVar1;

        *(uint **)(param_1 + 0x70) = puVar1;

        param_2[3] = 0;

        return CONCAT31(uVar2,1);

      }

      *(uint **)(param_1 + 0x74) = puVar1;

      *(uint **)(param_1 + 0x70) = puVar1;

      param_2[3] = 0;

      return CONCAT31(uVar2,1);

    }

    if (*puVar1 == *param_2) {

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

        FUN_00410880(param_2 + 2);

        goto LAB_00676ce3;

      }

      goto LAB_00676cdb;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00676d30 at 0x00676D30 (size: 103) ---


undefined1 * __thiscall FUN_00676d30(undefined1 *param_1,undefined4 param_2,undefined4 param_3)



{

  *param_1 = 0;

  param_1[1] = 1;

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

  FUN_00676640(0x400);

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

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

  *(undefined ***)(param_1 + 0x80) = &PTR_FUN_007e2f20;

  FUN_00587060(0x400);

  *(undefined4 *)(param_1 + 0xfc) = param_2;

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

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

  *(undefined4 *)(param_1 + 0x100) = param_3;

  return param_1;

}





// --- FUN_00676da0 at 0x00676DA0 (size: 268) ---


void __fastcall FUN_00676da0(undefined1 *param_1)



{

  undefined4 *puVar1;

  

  puVar1 = *(undefined4 **)(param_1 + 0xf4);

  *param_1 = 0;

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

    *puVar1 = 0;

    puVar1[1] = 0;

    puVar1[2] = 0;

    puVar1[3] = 0;

    puVar1[4] = 0xffffffff;

    puVar1[5] = 0;

    puVar1[6] = 0;

    if ((void *)puVar1[7] != (void *)0x0) {

      operator_delete__((void *)puVar1[7]);

      puVar1[7] = 0;

    }

    operator_delete(puVar1);

  }

  puVar1 = *(undefined4 **)(param_1 + 0xf8);

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

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

    *puVar1 = 0;

    puVar1[1] = 0;

    puVar1[2] = 0;

    puVar1[3] = 0;

    puVar1[4] = 0xffffffff;

    puVar1[5] = 0;

    puVar1[6] = 0;

    if ((void *)puVar1[7] != (void *)0x0) {

      operator_delete__((void *)puVar1[7]);

      puVar1[7] = 0;

    }

    operator_delete(puVar1);

  }

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

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

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

  *(undefined ***)(param_1 + 0x80) = &PTR_FUN_007e2f20;

  FUN_005870f0();

  *(undefined ***)(param_1 + 0x84) = &PTR_FUN_007e2f1c;

  if (*(undefined1 **)(param_1 + 0xe4) != param_1 + 0x88) {

    operator_delete__(*(undefined1 **)(param_1 + 0xe4));

  }

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

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

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

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

  FUN_00676850();

  *(undefined ***)(param_1 + 8) = &PTR_FUN_007fed0c;

  if (*(undefined1 **)(param_1 + 0x68) != param_1 + 0xc) {

    operator_delete__(*(undefined1 **)(param_1 + 0x68));

  }

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

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

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

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

  return;

}





// --- FUN_00676eb0 at 0x00676EB0 (size: 49) ---


void FUN_00676eb0(void)



{

  void *pvVar1;

  

  pvVar1 = (void *)FUN_006767f0(&stack0x00000004);

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

    operator_delete(pvVar1);

  }

  FUN_00587370(&stack0x00000004);

  return;

}





// --- FUN_00676ef0 at 0x00676EF0 (size: 347) ---


uint __fastcall FUN_00676ef0(int param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  uint *puVar3;

  int iVar4;

  int iVar5;

  uint *puVar6;

  uint *puVar7;

  uint uVar8;

  uint *puVar9;

  uint local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  puVar1 = *(undefined4 **)(param_1 + 0xf4);

  uVar8 = 0;

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

    local_4 = *puVar1;

    local_8 = *(undefined4 *)(puVar1[5] + 0xc);

LAB_00676f20:

    puVar9 = (uint *)0x0;

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

      piVar2 = *(int **)(param_1 + 0x7c);

      if (piVar2 != (int *)0x0) {

        if ((int *)piVar2[1] == (int *)0x0) {

          iVar4 = **(int **)(param_1 + 0x78);

          *(int *)(param_1 + 0x78) = iVar4;

          if (iVar4 != 0) {

            *(undefined4 *)(iVar4 + 4) = 0;

          }

        }

        else {

          *(int *)piVar2[1] = *piVar2;

        }

        if (*piVar2 == 0) {

          puVar1 = *(undefined4 **)(*(int *)(param_1 + 0x7c) + 4);

          *(undefined4 **)(param_1 + 0x7c) = puVar1;

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

            *puVar1 = 0;

          }

        }

        else {

          *(int *)(*piVar2 + 4) = piVar2[1];

        }

        *piVar2 = 0;

        piVar2[1] = 0;

        if (piVar2 != (int *)0x0) {

          puVar9 = (uint *)(piVar2 + -2);

        }

      }

      uVar8 = *puVar9 % *(uint *)(param_1 + 0x70);

      puVar7 = *(uint **)(*(int *)(param_1 + 0x68) + uVar8 * 4);

      for (puVar3 = puVar7; puVar3 != (uint *)0x0; puVar3 = (uint *)puVar3[1]) {

        if (*puVar3 == *puVar9) {

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

            if (puVar7 != puVar3) goto LAB_00676fa5;

            goto LAB_00676fb2;

          }

          break;

        }

      }

      goto LAB_00676fc3;

    }

    uVar8 = FUN_00676960(local_4,local_8);

  }

  return uVar8 & 0xffffff00;

LAB_00676fa5:

  do {

    puVar6 = puVar7;

    puVar7 = (uint *)puVar6[1];

  } while (puVar7 != puVar3);

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

LAB_00676fb2:

    *(uint *)(*(int *)(param_1 + 0x68) + uVar8 * 4) = puVar7[1];

  }

  else {

    puVar6[1] = puVar7[1];

  }

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

LAB_00676fc3:

  uVar8 = *puVar9;

  local_c = uVar8;

  operator_delete(puVar9);

  iVar4 = *(int *)(param_1 + 0xf4);

  if (((*(int *)(iVar4 + 0x14) == 0) || (*(int *)(iVar4 + 0x18) == 0)) ||

     (*(int *)(iVar4 + 8) <= *(int *)(*(int *)(iVar4 + 0x14) + 0xc))) {

    FUN_00676120(uVar8,0);

  }

  else if (((*(int *)(iVar4 + 0x14) != 0) && (*(int *)(iVar4 + 0x18) != 0)) &&

          (iVar5 = *(int *)(*(int *)(iVar4 + 0x14) + 0xc), iVar5 < *(int *)(iVar4 + 8))) {

    *(uint *)(*(int *)(iVar4 + 0x18) + iVar5 * 4) = uVar8;

    piVar2 = (int *)(*(int *)(iVar4 + 0x14) + 0xc);

    *piVar2 = *piVar2 + 1;

  }

  FUN_00587370(&local_c);

  goto LAB_00676f20;

}





// --- FUN_00677050 at 0x00677050 (size: 69) ---


undefined4 __thiscall FUN_00677050(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_00676cb0();

      return uVar2;

    }

  }

  return 0;

}





// --- FUN_006770a0 at 0x006770A0 (size: 117) ---


uint __thiscall FUN_006770a0(int param_1,uint *param_2)



{

  uint *puVar1;

  undefined3 uVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

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

LAB_006770cb:

      FUN_00676c30(param_2);

      puVar1 = param_2 + 2;

      *puVar1 = *(uint *)(param_1 + 0x70);

      uVar2 = (undefined3)((uint)puVar1 >> 8);

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

        *(uint **)(*(int *)(param_1 + 0x70) + 4) = puVar1;

        *(uint **)(param_1 + 0x70) = puVar1;

        param_2[3] = 0;

        return CONCAT31(uVar2,1);

      }

      *(uint **)(param_1 + 0x74) = puVar1;

      *(uint **)(param_1 + 0x70) = puVar1;

      param_2[3] = 0;

      return CONCAT31(uVar2,1);

    }

    if (*puVar1 == *param_2) {

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

        return (uint)puVar1 & 0xffffff00;

      }

      goto LAB_006770cb;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00677120 at 0x00677120 (size: 147) ---


char __thiscall FUN_00677120(int param_1,uint *param_2,undefined1 *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_0067714b:

      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;

        *(undefined1 *)(puVar2 + 4) = *param_3;

      }

      cVar1 = FUN_006770a0(puVar2);

      if ((cVar1 == '\0') && (puVar2 != (uint *)0x0)) {

        operator_delete(puVar2);

      }

      return cVar1;

    }

    if (*puVar2 == *param_2) {

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

        cVar1 = FUN_00677050(param_2);

        return cVar1;

      }

      goto LAB_0067714b;

    }

    puVar2 = (uint *)puVar2[1];

  } while( true );

}





// --- FUN_006771c0 at 0x006771C0 (size: 81) ---


void __fastcall FUN_006771c0(int param_1)



{

  void *pvVar1;

  undefined4 uStack_4;

  

  uStack_4 = param_1;

  pvVar1 = (void *)FUN_004171e0(&stack0x00000004);

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

    operator_delete(pvVar1);

  }

  uStack_4 = CONCAT13(1,(undefined3)uStack_4);

  FUN_00677120(&stack0x00000004,(int)&uStack_4 + 3);

  if (0xfff < *(uint *)(param_1 + 0x74)) {

    FUN_00676be0();

  }

  return;

}





// --- FUN_00677220 at 0x00677220 (size: 23) ---


void __fastcall FUN_00677220(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007fed10;

  param_1[1] = 0;

  param_1[2] = 0x4c50;

  return;

}





// --- FUN_00677240 at 0x00677240 (size: 40) ---


void __fastcall FUN_00677240(undefined4 *param_1)



{

  param_1[1] = 4;

  param_1[2] = 0x4c50;

  *param_1 = &PTR_LAB_007fed60;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  return;

}





// --- FUN_00677270 at 0x00677270 (size: 37) ---


void __fastcall FUN_00677270(undefined4 *param_1)



{

  param_1[1] = 6;

  param_1[2] = 0x4c50;

  *param_1 = &PTR_LAB_007fedb0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  return;

}





// --- FUN_006772a0 at 0x006772A0 (size: 34) ---


void __fastcall FUN_006772a0(undefined4 *param_1)



{

  param_1[1] = 9;

  param_1[2] = 0x4c50;

  *param_1 = &PTR_LAB_007fee00;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  return;

}





// --- FUN_006772d0 at 0x006772D0 (size: 56) ---


void __thiscall FUN_006772d0(int 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 = *(undefined4 *)(param_1 + 8);

      return;

    }

    *(undefined4 *)(param_1 + 8) = *puVar1;

  }

  return;

}





// --- FUN_00677310 at 0x00677310 (size: 186) ---


void __thiscall FUN_00677310(int param_1,int param_2)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  int iVar3;

  undefined4 *puVar4;

  

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

      *(undefined4 *)(param_1 + 8) = *puVar1;

    }

    else {

      *puVar1 = *(undefined4 *)(param_1 + 8);

    }

  }

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

  FUN_0040ad10(0x18);

  puVar2 = (undefined4 *)FUN_0040acf0(0x18);

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

    iVar3 = 6;

    puVar4 = puVar2;

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

      puVar4 = puVar1;

      puVar1 = puVar2;

    }

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

      *puVar1 = *puVar4;

      puVar4 = puVar4 + 1;

      puVar1 = puVar1 + 1;

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

      *(undefined4 *)(param_1 + 0x24) = *puVar1;

    }

    else {

      *puVar1 = *(undefined4 *)(param_1 + 0x24);

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

      *puVar1 = *(undefined4 *)(param_1 + 0x28);

      return;

    }

    *(undefined4 *)(param_1 + 0x28) = *puVar1;

  }

  return;

}





// --- FUN_006773d0 at 0x006773D0 (size: 40) ---


void __fastcall FUN_006773d0(undefined4 *param_1)



{

  param_1[1] = 2;

  param_1[2] = 0x4c50;

  *param_1 = &PTR_LAB_007fee50;

  param_1[3] = DAT_008f86e4;

  param_1[4] = 0;

  param_1[5] = 0;

  return;

}





// --- FUN_00677400 at 0x00677400 (size: 55) ---


void __fastcall FUN_00677400(undefined4 *param_1)



{

  param_1[1] = 3;

  param_1[2] = 0x4c50;

  *param_1 = &PTR_LAB_007feea0;

  param_1[3] = DAT_008f86e4;

  param_1[4] = DAT_008f86e4;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  return;

}





// --- FUN_00677670 at 0x00677670 (size: 102) ---


void __thiscall FUN_00677670(int param_1,int param_2)



{

  undefined4 *puVar1;

  

  FUN_00677310(param_2);

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

      *(undefined4 *)(param_1 + 0x2c) = *puVar1;

    }

    else {

      *puVar1 = *(undefined4 *)(param_1 + 0x2c);

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

      *puVar1 = *(undefined4 *)(param_1 + 0x30);

      return;

    }

    *(undefined4 *)(param_1 + 0x30) = *puVar1;

  }

  return;

}





// --- FUN_006777c0 at 0x006777C0 (size: 49) ---


void __fastcall FUN_006777c0(undefined4 *param_1)



{

  param_1[1] = 7;

  param_1[2] = 0x4c50;

  *param_1 = &PTR_LAB_007feef0;

  param_1[3] = 0;

  param_1[4] = DAT_008f86e4;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  *(undefined1 *)(param_1 + 8) = 0;

  return;

}





// --- FUN_00677920 at 0x00677920 (size: 40) ---


void __fastcall FUN_00677920(undefined4 *param_1)



{

  param_1[1] = 8;

  param_1[2] = 0x4c50;

  *param_1 = &PTR_LAB_007fef40;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = DAT_008f86e4;

  return;

}





// --- FUN_00677a10 at 0x00677A10 (size: 63) ---


void __fastcall FUN_00677a10(undefined4 *param_1)



{

  undefined4 uVar1;

  

  param_1[1] = 1;

  param_1[2] = 0x4c50;

  *param_1 = &PTR_FUN_007fef90;

  uVar1 = DAT_008f86e4;

  param_1[3] = param_1[3] & 0xffff0000;

  *(undefined2 *)((int)param_1 + 0xe) = 0;

  param_1[4] = uVar1;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  return;

}





// --- FUN_00677a50 at 0x00677A50 (size: 82) ---


void __fastcall FUN_00677a50(undefined4 *param_1)



{

  undefined4 uVar1;

  

  param_1[1] = 1;

  *param_1 = &PTR_FUN_007fef90;

  param_1[2] = 0x4c50;

  uVar1 = DAT_008f86e4;

  param_1[3] = param_1[3] & 0xffff0000;

  *(undefined2 *)((int)param_1 + 0xe) = 0;

  param_1[4] = uVar1;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  *param_1 = &PTR_FUN_007fefe0;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  param_1[1] = 5;

  return;

}





// --- FUN_00677ab0 at 0x00677AB0 (size: 263) ---


undefined4 * FUN_00677ab0(undefined4 param_1)



{

  int iVar1;

  undefined4 *puVar2;

  

  switch(param_1) {

  case 0:

    puVar2 = (undefined4 *)FUN_005df0f5(0xc);

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

      *puVar2 = &PTR_FUN_007fed10;

      puVar2[1] = 0;

      puVar2[2] = 0x4c50;

      return puVar2;

    }

    break;

  case 1:

    iVar1 = FUN_005df0f5(0x2c);

    if (iVar1 != 0) {

      puVar2 = (undefined4 *)FUN_00677a10();

      return puVar2;

    }

    break;

  case 2:

    iVar1 = FUN_005df0f5(0x18);

    if (iVar1 != 0) {

      puVar2 = (undefined4 *)FUN_006773d0();

      return puVar2;

    }

    break;

  case 3:

    iVar1 = FUN_005df0f5(0x24);

    if (iVar1 != 0) {

      puVar2 = (undefined4 *)FUN_00677400();

      return puVar2;

    }

    break;

  case 4:

    iVar1 = FUN_005df0f5(0x20);

    if (iVar1 != 0) {

      puVar2 = (undefined4 *)FUN_00677240();

      return puVar2;

    }

    break;

  case 5:

    iVar1 = FUN_005df0f5(0x34);

    if (iVar1 != 0) {

      puVar2 = (undefined4 *)FUN_00677a50();

      return puVar2;

    }

    break;

  case 6:

    iVar1 = FUN_005df0f5(0x1c);

    if (iVar1 != 0) {

      puVar2 = (undefined4 *)FUN_00677270();

      return puVar2;

    }

    break;

  case 7:

    iVar1 = FUN_005df0f5(0x24);

    if (iVar1 != 0) {

      puVar2 = (undefined4 *)FUN_006777c0();

      return puVar2;

    }

    break;

  case 8:

    iVar1 = FUN_005df0f5(0x18);

    if (iVar1 != 0) {

      puVar2 = (undefined4 *)FUN_00677920();

      return puVar2;

    }

    break;

  case 9:

    iVar1 = FUN_005df0f5(0x18);

    if (iVar1 != 0) {

      puVar2 = (undefined4 *)FUN_006772a0();

      return puVar2;

    }

  }

  return (undefined4 *)0x0;

}





// --- FUN_00677be0 at 0x00677BE0 (size: 9) ---


void __fastcall FUN_00677be0(undefined4 *param_1)



{

  *param_1 = 0xffffffff;

  return;

}





// --- FUN_00677bf0 at 0x00677BF0 (size: 113) ---


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



{

  *param_1 = *param_2;

  param_1[1] = param_2[1];

  param_1[2] = param_2[2];

  param_1[3] = param_2[3];

  param_1[4] = param_2[4];

  param_1[5] = param_2[5];

  param_1[6] = param_2[6];

  param_1[7] = param_2[7];

  param_1[8] = param_2[8];

  param_1[9] = param_2[9];

  param_1[10] = param_2[10];

  *(undefined1 *)(param_1 + 0xb) = *(undefined1 *)(param_2 + 0xb);

  param_1[0xc] = param_2[0xc];

  param_1[0xd] = param_2[0xd];

  param_1[0xe] = param_2[0xe];

  FUN_004139a0(param_2 + 0xf);

  return param_1;

}





// --- FUN_00677c70 at 0x00677C70 (size: 43) ---


undefined4 __fastcall FUN_00677c70(undefined4 *param_1)



{

  BOOL BVar1;

  

  if ((HANDLE)*param_1 != (HANDLE)0xffffffff) {

    BVar1 = CloseHandle((HANDLE)*param_1);

    if (BVar1 != 0) {

      *param_1 = 0xffffffff;

      return 0;

    }

  }

  return 0xffffff98;

}





// --- FUN_00677ca0 at 0x00677CA0 (size: 29) ---


void __fastcall FUN_00677ca0(undefined4 *param_1)



{

  BOOL BVar1;

  

  if ((HANDLE)*param_1 != (HANDLE)0xffffffff) {

    BVar1 = CloseHandle((HANDLE)*param_1);

    if (BVar1 != 0) {

      *param_1 = 0xffffffff;

    }

  }

  return;

}





// --- FUN_00677cc0 at 0x00677CC0 (size: 90) ---


uint __thiscall FUN_00677cc0(undefined4 *param_1,LPVOID param_2,DWORD param_3,DWORD param_4)



{

  DWORD DVar1;

  

  DVar1 = SetFilePointer((HANDLE)*param_1,param_4,(PLONG)0x0,0);

  if (DVar1 == 0xffffffff) {

    return 0xffffff97;

  }

  param_4 = 0;

  ReadFile((HANDLE)*param_1,param_2,param_3,&param_4,(LPOVERLAPPED)0x0);

  return (param_4 == param_3) - 1 & 0xffffff9a;

}





// --- FUN_00677d20 at 0x00677D20 (size: 92) ---


uint __thiscall FUN_00677d20(undefined4 *param_1,LPCVOID param_2,DWORD param_3,DWORD param_4)



{

  DWORD DVar1;

  BOOL BVar2;

  

  DVar1 = SetFilePointer((HANDLE)*param_1,param_4,(PLONG)0x0,0);

  if (DVar1 == 0xffffffff) {

    return 0xffffff97;

  }

  BVar2 = WriteFile((HANDLE)*param_1,param_2,param_3,&param_4,(LPOVERLAPPED)0x0);

  if (BVar2 == 0) {

    GetLastError();

  }

  return (param_4 == param_3) - 1 & 0xffffff99;

}





// --- FUN_00677d80 at 0x00677D80 (size: 381) ---


/* WARNING: Removing unreachable block (ram,0x00677e54) */

/* WARNING: Removing unreachable block (ram,0x00677e5f) */



undefined4 __thiscall

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



{

  LONG LVar1;

  int iVar2;

  char *pcVar3;

  char *pcVar4;

  undefined4 uVar5;

  int iVar6;

  int local_194;

  char local_190 [255];

  undefined1 local_91;

  undefined1 auStack_6c [92];

  int iStack_10;

  

  FUN_006713e0();

  pcVar3 = local_190;

  for (iVar2 = 0x40; iVar2 != 0; iVar2 = iVar2 + -1) {

    pcVar3[0] = '\0';

    pcVar3[1] = '\0';

    pcVar3[2] = '\0';

    pcVar3[3] = '\0';

    pcVar3 = pcVar3 + 4;

  }

  local_194 = *param_3;

  pcVar3 = "\nFile Header Structure Default Constructor v1.3\n";

  pcVar4 = local_190;

  for (iVar2 = 0xc; iVar2 != 0; iVar2 = iVar2 + -1) {

    *(undefined4 *)pcVar4 = *(undefined4 *)pcVar3;

    pcVar3 = pcVar3 + 4;

    pcVar4 = pcVar4 + 4;

  }

  *pcVar4 = *pcVar3;

  local_91 = 0x1a;

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

  FUN_0040cc80(&local_194);

  iVar2 = -0x40000000;

  if ((param_5 & 4) != 0) {

    iVar2 = -0x80000000;

  }

  iVar6 = 0;

  iVar2 = (*(code *)PTR_FUN_00837374)(local_194,iVar2,iVar2 < 0,0);

  *param_1 = iVar2;

  if (iVar2 == -1) {

    uVar5 = 0xfffffffe;

  }

  else {

    uVar5 = 0;

    if (iStack_10 != 0) {

      uVar5 = FUN_00677cc0(&stack0xfffffe54,400,0);

      FUN_00677bf0(auStack_6c);

      SetFilePointer((HANDLE)*param_1,0,(PLONG)0x0,2);

    }

  }

  LVar1 = InterlockedDecrement((LONG *)(iVar6 + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(iVar6 + -0x14) != (undefined4 *)0x0)) {

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

  }

  FUN_00695670();

  return uVar5;

}





// --- FUN_00677f00 at 0x00677F00 (size: 61) ---


bool __thiscall FUN_00677f00(int *param_1,undefined4 param_2)



{

  int *piVar1;

  undefined4 uVar2;

  int iVar3;

  

  piVar1 = (int *)*param_1;

  uVar2 = FUN_004220b0(param_2,0x24);

  iVar3 = FUN_00415430(uVar2);

  *param_1 = iVar3;

  if (piVar1 != (int *)0x0) {

    (**(code **)(*piVar1 + 0x14))();

  }

  return *param_1 != 0;

}





// --- FUN_00677f40 at 0x00677F40 (size: 336) ---


undefined1 __thiscall FUN_00677f40(int *param_1,undefined *param_2,uint *param_3)



{

  undefined *puVar1;

  char cVar2;

  int iVar3;

  uint uVar4;

  LONG LVar5;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined1 uVar6;

  undefined *puVar7;

  undefined4 uVar8;

  int *piVar9;

  int local_10 [4];

  

  puVar1 = param_2;

  if (param_2 == (undefined *)0x0) {

    return 0;

  }

  uVar6 = 1;

  if (*param_1 == 0) {

    FUN_00401340("This Enumerated must be initializedprior to reading a filenode.");

    FUN_0065d620(puVar1,param_1);

    return 0;

  }

  *param_3 = 0;

  FUN_0065cf90(param_2);

  iVar3 = FUN_0065c810();

  while (iVar3 != 0) {

    param_2 = PTR_DAT_00818344;

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

    cVar2 = FUN_00426020(&param_2);

    puVar1 = param_2;

    if (cVar2 == '\0') {

      uVar8 = extraout_ECX;

      FUN_00401340("expecting a string node");

      FUN_0065d620(iVar3,uVar8);

      uVar6 = 0;

    }

    else {

      piVar9 = local_10;

      puVar7 = param_2;

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

      cVar2 = FUN_0041b7e0(puVar7,piVar9);

      if (cVar2 == '\0') {

        uVar8 = extraout_ECX_00;

        puVar7 = puVar1;

        FUN_00401340("invalid emp value \'%s\'");

        FUN_0065d620(iVar3,uVar8,puVar7);

        uVar6 = 0;

      }

      else {

        uVar4 = 0;

        if (local_10[0] != 0) {

          uVar4 = 1 << ((char)local_10[0] - 1U & 0x1f);

        }

        *param_3 = *param_3 | uVar4;

      }

    }

    LVar5 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

    if ((LVar5 == 0) && ((undefined4 *)(puVar1 + -0x14) != (undefined4 *)0x0)) {

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

    }

    iVar3 = FUN_0065cb10();

  }

  FUN_0065cae0();

  return uVar6;

}





// --- FUN_00678090 at 0x00678090 (size: 352) ---


undefined1 __thiscall FUN_00678090(int *param_1,int param_2,uint *param_3)



{

  uint *puVar1;

  uint *puVar2;

  char cVar3;

  int iVar4;

  LONG LVar5;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined8 uVar6;

  uint *puVar7;

  undefined4 uVar8;

  int *piVar9;

  int local_10 [4];

  

  puVar1 = param_3;

  iVar4 = param_2;

  if (param_2 != 0) {

    param_2._0_1_ = 1;

    if (*param_1 != 0) {

      *param_3 = 0;

      param_3[1] = 0;

      FUN_0065cf90(iVar4);

      iVar4 = FUN_0065c810();

      while (iVar4 != 0) {

        param_3 = (uint *)PTR_DAT_00818344;

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

        cVar3 = FUN_00426020(&param_3);

        puVar2 = param_3;

        if (cVar3 == '\0') {

          uVar8 = extraout_ECX;

          FUN_00401340("expecting a string node");

          FUN_0065d620(iVar4,uVar8);

          param_2._0_1_ = 0;

        }

        else {

          piVar9 = local_10;

          puVar7 = param_3;

          InterlockedIncrement((LONG *)(param_3 + -4));

          cVar3 = FUN_0041b7e0(puVar7,piVar9);

          if (cVar3 == '\0') {

            uVar8 = extraout_ECX_00;

            puVar7 = puVar2;

            FUN_00401340("invalid emp value \'%s\'");

            FUN_0065d620(iVar4,uVar8,puVar7);

            param_2._0_1_ = 0;

          }

          else {

            if (local_10[0] == 0) {

              uVar6 = 0;

            }

            else {

              uVar6 = __allshl();

            }

            *puVar1 = *puVar1 | (uint)uVar6;

            puVar1[1] = puVar1[1] | (uint)((ulonglong)uVar6 >> 0x20);

          }

        }

        LVar5 = InterlockedDecrement((LONG *)(puVar2 + -4));

        if ((LVar5 == 0) && (puVar2 + -5 != (uint *)0x0)) {

          (**(code **)puVar2[-5])(1);

        }

        iVar4 = FUN_0065cb10();

      }

      FUN_0065cae0();

      return (undefined1)param_2;

    }

    FUN_00401340("This Enumerated must be initializedprior to reading a filenode.");

    FUN_0065d620(iVar4,param_1);

  }

  return 0;

}





// --- FUN_006781f0 at 0x006781F0 (size: 168) ---


undefined1 __thiscall FUN_006781f0(int *param_1,undefined *param_2)



{

  char cVar1;

  LONG LVar2;

  uint uVar3;

  undefined4 *puVar4;

  int iVar5;

  undefined1 local_1;

  

  FUN_00408910(0,1);

  if (*param_1 == 0) {

    return 0;

  }

  local_1 = 1;

  iVar5 = 1;

  for (uVar3 = (uint)param_2; uVar3 != 0; uVar3 = uVar3 >> 1) {

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

      param_2 = PTR_DAT_00818344;

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

      cVar1 = FUN_0041af60(iVar5,&param_2);

      if (cVar1 == '\0') {

        local_1 = 0;

      }

      else {

        FUN_0040c440(&param_2);

      }

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

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

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

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

      }

    }

    iVar5 = iVar5 + 1;

  }

  return local_1;

}





// --- FUN_006782a0 at 0x006782A0 (size: 278) ---


undefined4 __thiscall FUN_006782a0(int *param_1,undefined4 param_2,int param_3)



{

  int *piVar1;

  int iVar2;

  char cVar3;

  int iVar4;

  LONG LVar5;

  int *piVar6;

  int *local_c;

  uint local_8;

  int local_4;

  

  if ((param_3 != 0) && (*param_1 != 0)) {

    local_c = (int *)0x0;

    local_8 = 0;

    local_4 = 0;

    cVar3 = FUN_006781f0(param_2,&local_c);

    if (cVar3 != '\0') {

      piVar1 = local_c + local_4;

      piVar6 = local_c;

      while( true ) {

        if (piVar6 == piVar1) {

          if (((local_8 & 0x80000000) == 0x80000000) && (local_c != (int *)0x0)) {

            FUN_00407920(3);

          }

          return 1;

        }

        iVar2 = *piVar6;

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

        iVar4 = iVar2;

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

        iVar4 = FUN_00426fe0(iVar4);

        LVar5 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

        if ((LVar5 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

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

        }

        if (iVar4 == 0) break;

        piVar6 = piVar6 + 1;

      }

    }

    if (((local_8 & 0x80000000) == 0x80000000) && (local_c != (int *)0x0)) {

      FUN_00407920(3);

    }

  }

  return 0;

}





// --- FUN_006783c0 at 0x006783C0 (size: 200) ---


undefined1 __thiscall FUN_006783c0(int *param_1,undefined *param_2,uint param_3)



{

  char cVar1;

  LONG LVar2;

  uint uVar3;

  int iVar4;

  undefined4 *puVar5;

  uint uVar6;

  undefined1 local_5;

  

  FUN_00408910(0,1);

  if (*param_1 != 0) {

    local_5 = 1;

    iVar4 = 1;

    uVar3 = param_3;

    uVar6 = (uint)param_2;

    if (param_2 != (undefined *)0x0 || param_3 != 0) {

      do {

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

          param_2 = PTR_DAT_00818344;

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

          cVar1 = FUN_0041af60(iVar4,&param_2);

          if (cVar1 == '\0') {

            local_5 = 0;

          }

          else {

            FUN_0040c440(&param_2);

          }

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

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

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

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

          }

        }

        uVar6 = uVar6 >> 1 | uVar3 << 0x1f;

        uVar3 = uVar3 >> 1;

        iVar4 = iVar4 + 1;

      } while (uVar6 != 0 || uVar3 != 0);

    }

    return local_5;

  }

  return 0;

}





// --- FUN_006785b0 at 0x006785B0 (size: 48) ---


void __thiscall FUN_006785b0(int *param_1,int param_2)



{

  int iVar1;

  

  iVar1 = *(int *)(param_2 + 0xc);

  if (iVar1 == 0) {

                    /* WARNING: Could not recover jumptable at 0x006785da. Too many branches */

                    /* WARNING: Treating indirect jump as call */

    (**(code **)(*param_1 + 0x5c))();

    return;

  }

  if (iVar1 != 1) {

    if (iVar1 == 2) {

                    /* WARNING: Could not recover jumptable at 0x006785c8. Too many branches */

                    /* WARNING: Treating indirect jump as call */

      (**(code **)(*param_1 + 0x60))();

      return;

    }

    return;

  }

                    /* WARNING: Could not recover jumptable at 0x006785d1. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  (**(code **)(*param_1 + 100))();

  return;

}





// --- FUN_006785e0 at 0x006785E0 (size: 36) ---


bool __thiscall FUN_006785e0(int *param_1,char param_2)



{

  char cVar1;

  

  (**(code **)(*param_1 + 0x54))();

  cVar1 = FUN_00414620(param_2 == '\0',0);

  return cVar1 == '\0';

}





// --- FUN_00678730 at 0x00678730 (size: 332) ---


void __thiscall FUN_00678730(int *param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int iVar2;

  undefined4 *puVar3;

  bool bVar4;

  

  if (param_1[2] == param_1[1] + -1) {

    iVar2 = 0;

  }

  else {

    iVar2 = param_1[2] + 1;

  }

  if (iVar2 != param_1[3]) {

    bVar4 = true;

    do {

      if (param_1[5] == 0) {

        if (bVar4) {

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

          if (param_1[2] == param_1[1] + -1) {

            param_1[2] = 0;

            return;

          }

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

          return;

        }

        break;

      }

      (**(code **)(param_1[9] + 4))();

      puVar3 = (undefined4 *)param_1[5];

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

        FUN_0065e910();

      }

      else {

        iVar2 = puVar3[1];

        param_1[5] = iVar2;

        if (iVar2 == 0) {

          param_1[6] = 0;

        }

        else {

          *(undefined4 *)(iVar2 + 8) = 0;

        }

        uVar1 = *puVar3;

        operator_delete(puVar3);

        param_1[7] = param_1[7] + -1;

        param_1[8] = param_1[8] + -1;

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

        if (param_1[2] == param_1[1] + -1) {

          iVar2 = 0;

        }

        else {

          iVar2 = param_1[2] + 1;

        }

        param_1[2] = iVar2;

        FUN_0065e910();

        if (param_1[2] == param_1[1] + -1) {

          bVar4 = param_1[3] != 0;

        }

        else {

          bVar4 = param_1[2] + 1 != param_1[3];

        }

      }

    } while (bVar4);

  }

  (**(code **)(param_1[9] + 4))();

  puVar3 = (undefined4 *)FUN_005df0f5(0xc);

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

    *puVar3 = param_2;

    puVar3[1] = 0;

    puVar3[2] = 0;

    if (param_1[5] == 0) {

      param_1[5] = (int)puVar3;

    }

    else {

      iVar2 = param_1[6];

      *(undefined4 **)(iVar2 + 4) = puVar3;

      puVar3[2] = iVar2;

    }

    param_1[6] = (int)puVar3;

    param_1[7] = param_1[7] + 1;

  }

  param_1[8] = param_1[8] + 1;

  FUN_0065e910();

  return;

}





// --- FUN_00678890 at 0x00678890 (size: 200) ---


undefined4 __thiscall FUN_00678890(int *param_1,undefined4 *param_2)



{

  char cVar1;

  

  if (param_1[2] != param_1[3]) {

    *param_2 = *(undefined4 *)(*param_1 + param_1[3] * 4);

    if (param_1[3] == param_1[1] + -1) {

      param_1[3] = 0;

      return 1;

    }

    param_1[3] = param_1[3] + 1;

    return 1;

  }

  if (param_1[5] == 0) {

    return 0;

  }

  (**(code **)(param_1[9] + 4))();

  if (param_1[2] == param_1[3]) {

    cVar1 = FUN_0043c800(param_2);

    if (cVar1 != '\0') {

      param_1[8] = param_1[8] + -1;

      FUN_0065e910();

      return 1;

    }

  }

  *param_2 = *(undefined4 *)(*param_1 + param_1[3] * 4);

  if (param_1[3] == param_1[1] + -1) {

    param_1[3] = 0;

    FUN_0065e910();

    return 1;

  }

  param_1[3] = param_1[3] + 1;

  FUN_0065e910();

  return 1;

}





// --- FUN_006789e0 at 0x006789E0 (size: 46) ---


void FUN_006789e0(int param_1)



{

  InterlockedIncrement((LONG *)(param_1 + 4));

  FUN_00678730(param_1);

  FUN_0065eb20();

  return;

}





// --- FUN_00678a10 at 0x00678A10 (size: 122) ---


void __fastcall FUN_00678a10(int *param_1)



{

  int *piVar1;

  char cVar2;

  DWORD DVar3;

  DWORD DVar4;

  uint uVar5;

  LONG LVar6;

  int *local_4;

  

  local_4 = param_1;

  DVar3 = GetTickCount();

  local_4 = (int *)0x0;

  DVar4 = GetTickCount();

  uVar5 = DVar4 - DVar3;

  while ((uVar5 < 0x19 && (cVar2 = FUN_00678890(&local_4), piVar1 = local_4, cVar2 != '\0'))) {

    (**(code **)(*param_1 + 0x5c))(local_4);

    if (piVar1 != (int *)0x0) {

      LVar6 = InterlockedDecrement(piVar1 + 1);

      if (LVar6 == 0) {

        (**(code **)*piVar1)(1);

      }

      local_4 = (int *)0x0;

    }

    DVar4 = GetTickCount();

    uVar5 = DVar4 - DVar3;

  }

  FUN_00414390();

  return;

}





// --- FUN_00678a90 at 0x00678A90 (size: 189) ---


void __thiscall FUN_00678a90(int param_1,int param_2)



{

  int *piVar1;

  int iVar2;

  char cVar3;

  int iVar4;

  

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

  iVar2 = param_2 + 0x10;

  iVar4 = (**(code **)(*(int *)(param_1 + 4) + 0x84))(iVar2,*(undefined4 *)(param_2 + 0x5c));

  if (iVar4 != 0) {

    *(uint *)(param_2 + 0x60) = *(uint *)(param_2 + 0x60) | 4;

    FUN_00417660(iVar4);

    *(undefined4 *)(param_2 + 8) = 1;

    (**(code **)(*piVar1 + 0x60))(param_2);

    return;

  }

  *(uint *)(param_2 + 0x60) = *(uint *)(param_2 + 0x60) & 0xfffffffb;

  cVar3 = (**(code **)(**(int **)(param_2 + 0x5c) + 0x20))();

  if (cVar3 != '\0') {

    cVar3 = (**(code **)(*piVar1 + 0x3c))(iVar2);

    if (cVar3 != '\0') {

      FUN_006789e0(param_2);

      return;

    }

  }

  cVar3 = (**(code **)(**(int **)(param_2 + 0x5c) + 0x24))();

  if (cVar3 != '\0') {

    cVar3 = (**(code **)(*piVar1 + 0x8c))(iVar2,*(undefined4 *)(param_2 + 0x5c));

    if (cVar3 != '\0') {

      *(uint *)(param_2 + 0x60) = *(uint *)(param_2 + 0x60) & 0xfffffffd;

      return;

    }

  }

  *(undefined4 *)(param_2 + 8) = 3;

  (**(code **)(*piVar1 + 0x5c))(param_2);

  return;

}





// --- FUN_00678b50 at 0x00678B50 (size: 253) ---


undefined4 * __fastcall FUN_00678b50(undefined4 *param_1)



{

  undefined4 uVar1;

  

  FUN_00415320();

  FUN_0065ea90(0);

  param_1[0x4c] = &PTR_LAB_007ff1d8;

  *param_1 = &PTR_LAB_007ff170;

  param_1[1] = &PTR_FUN_007ff0c8;

  param_1[0x52] = 0;

  param_1[0x53] = 0;

  param_1[0x50] = 0;

  param_1[0x51] = 0x400;

  param_1[0x54] = &PTR_FUN_007c6918;

  param_1[0x55] = 0;

  param_1[0x56] = 0;

  param_1[0x57] = 0;

  param_1[0x58] = 0;

  FUN_0065e8b0();

  uVar1 = thunk_FUN_005df0f5(param_1[0x51] << 2);

  param_1[0x50] = uVar1;

  param_1[100] = 0;

  param_1[0x62] = 0;

  param_1[99] = 0x400;

  param_1[0x65] = 0;

  param_1[0x66] = &PTR_FUN_007c6918;

  param_1[0x67] = 0;

  param_1[0x68] = 0;

  param_1[0x69] = 0;

  param_1[0x6a] = 0;

  FUN_0065e8b0();

  uVar1 = thunk_FUN_005df0f5(param_1[99] << 2);

  param_1[0x62] = uVar1;

  FUN_0065eae0();

  return param_1;

}





// --- FUN_00678cb0 at 0x00678CB0 (size: 30) ---


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



{

  FUN_004fa5c0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00678d30 at 0x00678D30 (size: 21) ---


undefined4 * __fastcall FUN_00678d30(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007ff1ec;

  FUN_00670fc0();

  return param_1;

}





// --- FUN_00678d50 at 0x00678D50 (size: 178) ---


void __fastcall FUN_00678d50(int *param_1)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  undefined4 local_20;

  undefined4 local_1c;

  void *local_14;

  uint local_10;

  undefined1 local_8;

  

  param_1[2] = 0;

  if ((param_1[1] & 0x80000000U) != 0x80000000) {

    if (*param_1 != 0) {

      uVar1 = param_1[1] & 0x7fffffff;

      if (-1 < (int)(uVar1 - 1)) {

        iVar3 = (uVar1 - 1) * 0x28;

        do {

          FUN_00670fc0();

          iVar2 = *param_1 + iVar3;

          *(undefined4 *)(iVar2 + 8) = local_20;

          *(undefined4 *)(iVar2 + 0xc) = local_1c;

          FUN_005c0220(&local_14);

          *(undefined1 *)(iVar2 + 0x20) = local_8;

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

            operator_delete__(local_14);

          }

          iVar3 = iVar3 + -0x28;

          uVar1 = uVar1 - 1;

        } while (uVar1 != 0);

      }

    }

    return;

  }

  if (*param_1 != 0) {

    FUN_004f9060(3);

  }

  *param_1 = 0;

  param_1[1] = 0;

  return;

}





// --- FUN_00678e10 at 0x00678E10 (size: 269) ---


undefined4 __thiscall FUN_00678e10(int *param_1,uint param_2)



{

  uint *puVar1;

  int iVar2;

  uint *puVar3;

  int local_8;

  

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

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

      return 1;

    }

    if (param_2 == 0) {

      FUN_00678d50();

      return 1;

    }

    puVar3 = (uint *)thunk_FUN_005df0f5(param_2 * 0x28 + 4);

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

      puVar1 = puVar3 + 1;

      *puVar3 = param_2;

      FUN_00401000(puVar1,0x28,param_2,FUN_00678d30);

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

        if (*param_1 != 0) {

          local_8 = param_1[2];

          if (-1 < local_8 + -1) {

            puVar3 = puVar3 + (local_8 + -1) * 10 + 9;

            do {

              iVar2 = *param_1 + -(int)puVar1 + -0x20;

              puVar3[-6] = *(uint *)((int)puVar3 + *param_1 + -(int)puVar1 + -0x18);

              puVar3[-5] = *(uint *)((int)puVar3 + iVar2 + 0xc);

              FUN_005c0220((undefined1 *)((int)puVar3 + iVar2 + 0x14));

              *(undefined1 *)puVar3 = *(undefined1 *)((int)puVar3 + iVar2 + 0x20);

              puVar3 = puVar3 + -10;

              local_8 = local_8 + -1;

            } while (local_8 != 0);

          }

          if (((param_1[1] & 0x80000000U) == 0x80000000) && (*param_1 != 0)) {

            FUN_004f9060(3);

          }

        }

        *param_1 = (int)puVar1;

        param_1[1] = param_2 | 0x80000000;

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_00678f20 at 0x00678F20 (size: 198) ---


undefined1 __thiscall FUN_00678f20(int *param_1,uint param_2,char param_3)



{

  char cVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  undefined4 local_20;

  undefined4 local_1c;

  void *local_14;

  uint local_10;

  undefined1 local_8;

  

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

    uVar2 = param_2;

    if (param_3 == '\0') {

      uVar2 = FUN_00453850(param_2);

    }

    cVar1 = FUN_00678e10(uVar2);

    if (cVar1 == '\0') {

      return 0;

    }

  }

  else if (param_2 < (uint)param_1[2]) {

    iVar3 = param_2 * 0x28;

    uVar2 = param_2;

    do {

      FUN_00670fc0();

      iVar4 = *param_1 + iVar3;

      *(undefined4 *)(iVar4 + 8) = local_20;

      *(undefined4 *)(iVar4 + 0xc) = local_1c;

      FUN_005c0220(&local_14);

      *(undefined1 *)(iVar4 + 0x20) = local_8;

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

        operator_delete__(local_14);

      }

      uVar2 = uVar2 + 1;

      iVar3 = iVar3 + 0x28;

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

  }

  param_1[2] = param_2;

  return 1;

}





// --- FUN_00678ff0 at 0x00678FF0 (size: 140) ---


void __thiscall FUN_00678ff0(int *param_1,int param_2)



{

  uint *puVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

  uVar3 = param_1[2];

  FUN_0040ad10(4);

  puVar1 = (uint *)FUN_0040acf0(4);

  iVar4 = 0;

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

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

      uVar3 = *puVar1;

    }

    else {

      *puVar1 = uVar3;

    }

  }

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

    uVar2 = FUN_0040a8f0();

    if (uVar2 < uVar3) {

      FUN_0040aa50();

      return;

    }

    param_1[2] = 0;

    FUN_00678f20(uVar3,1);

  }

  uVar3 = 0;

  if (param_1[2] != 0) {

    do {

      (*(code *)**(undefined4 **)(*param_1 + iVar4))(param_2);

      uVar3 = uVar3 + 1;

      iVar4 = iVar4 + 0x28;

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

  }

  return;

}





// --- FUN_00679080 at 0x00679080 (size: 105) ---


undefined4 __thiscall FUN_00679080(int *param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  

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

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

    uVar2 = FUN_00678e10(uVar2);

    if ((char)uVar2 == '\0') {

      return uVar2;

    }

  }

  iVar1 = *param_1 + param_1[2] * 0x28;

  *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(param_2 + 8);

  *(undefined4 *)(iVar1 + 0xc) = *(undefined4 *)(param_2 + 0xc);

  FUN_005c0220(param_2 + 0x14);

  *(undefined1 *)(iVar1 + 0x20) = *(undefined1 *)(param_2 + 0x20);

  iVar1 = param_1[2];

  param_1[2] = iVar1 + 1;

  return CONCAT31((int3)((uint)(iVar1 + 1) >> 8),1);

}





// --- FUN_00679100 at 0x00679100 (size: 112) ---


int __thiscall FUN_00679100(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  int iVar2;

  undefined **local_28 [5];

  void *local_14;

  uint local_10;

  

  local_28[0] = &PTR_LAB_007ff1ec;

  FUN_00670fc0();

  FUN_00679080(local_28);

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

    operator_delete__(local_14);

  }

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

  iVar2 = (*(int *)(param_1 + 0xc) + -1) * 0x28;

  *(undefined4 *)(iVar2 + 8 + iVar1) = param_2;

  *(undefined4 *)(iVar2 + 0xc + iVar1) = param_3;

  return iVar2 + 0x10 + *(int *)(param_1 + 4);

}





// --- FUN_00679170 at 0x00679170 (size: 83) ---


int __thiscall FUN_00679170(int *param_1,undefined1 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_00797010;

    *(undefined1 *)(puVar2 + 1) = param_2;

    *(undefined4 **)(iVar1 + 8) = puVar2;

    return iVar1;

  }

  *(undefined4 *)(iVar1 + 8) = 0;

  return iVar1;

}





// --- FUN_006791d0 at 0x006791D0 (size: 23) ---


void __fastcall FUN_006791d0(undefined4 *param_1)



{

  *param_1 = 0xc0400000;

  param_1[1] = 0xc0400000;

  param_1[2] = 0xc0400000;

  param_1[3] = 0xc0400000;

  *(undefined1 *)(param_1 + 4) = 1;

  return;

}





// --- FUN_006791f0 at 0x006791F0 (size: 46) ---


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



{

  if ((*(int *)(*param_2 + -4) != 1) && (param_3 == 0)) {

    *param_1 = DAT_008f8700;

    return;

  }

  *param_1 = DAT_008f8700;

  return;

}





// --- FUN_00679220 at 0x00679220 (size: 28) ---


undefined4 * FUN_00679220(undefined4 *param_1)



{

  LONG *lpAddend;

  

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

  *param_1 = PTR_DAT_008183b4;

  InterlockedIncrement(lpAddend);

  return param_1;

}





// --- FUN_00679240 at 0x00679240 (size: 77) ---


undefined4 * FUN_00679240(undefined4 *param_1,int param_2)



{

  LONG *pLVar1;

  

  if (param_2 == DAT_008f8700) {

    pLVar1 = (LONG *)(PTR_DAT_008183b4 + -0x10);

    *param_1 = PTR_DAT_008183b4;

    InterlockedIncrement(pLVar1);

    return param_1;

  }

  FUN_0041c280(param_2);

  pLVar1 = (LONG *)(PTR_DAT_008183b4 + -0x10);

  *param_1 = PTR_DAT_008183b4;

  InterlockedIncrement(pLVar1);

  return param_1;

}





// --- FUN_00679290 at 0x00679290 (size: 69) ---


undefined4 * FUN_00679290(undefined4 *param_1,undefined4 param_2)



{

  int iVar1;

  LONG *pLVar2;

  

  iVar1 = FUN_0041c260(param_2);

  if (iVar1 == 0) {

    pLVar2 = (LONG *)(PTR_DAT_008183b4 + -0x10);

    *param_1 = PTR_DAT_008183b4;

    InterlockedIncrement(pLVar2);

    return param_1;

  }

  pLVar2 = (LONG *)(PTR_DAT_008183b4 + -0x10);

  *param_1 = PTR_DAT_008183b4;

  InterlockedIncrement(pLVar2);

  return param_1;

}





// --- FUN_006792e0 at 0x006792E0 (size: 54) ---


void FUN_006792e0(uint *param_1)



{

  uint uVar1;

  undefined8 uVar2;

  

  uVar2 = __allmul(param_1[1],0,0,1);

  uVar1 = (uint)uVar2 + *param_1;

  __aulldiv(uVar1 + 0x2ac18000,

            (int)((ulonglong)uVar2 >> 0x20) + (uint)CARRY4((uint)uVar2,*param_1) + -0x19db1df +

            (uint)(0xd53e7fff < uVar1),10000000,0);

  return;

}





// --- FUN_00679340 at 0x00679340 (size: 84) ---


uint __thiscall FUN_00679340(int *param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  uint uVar2;

  uint *unaff_retaddr;

  undefined4 local_4;

  

  local_4 = 0;

  cVar1 = (**(code **)(*param_1 + 0x58))(param_2,param_3,&local_4);

  if (cVar1 != '\0') {

    uVar2 = (**(code **)(*param_1 + 0x60))(param_3,unaff_retaddr);

    return uVar2;

  }

  uVar2 = FUN_005df4c4();

  *unaff_retaddr = uVar2;

  return uVar2 & 0xffffff00;

}





// --- FUN_006793d0 at 0x006793D0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007ff1f8;

  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_00679410 at 0x00679410 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007ff1fc;

  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_00679450 at 0x00679450 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007ff200;

  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_00679490 at 0x00679490 (size: 26) ---


int * __thiscall FUN_00679490(int param_1,int *param_2)



{

  int iVar1;

  

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

  *param_2 = iVar1;

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

  return param_2;

}





// --- FUN_006794b0 at 0x006794B0 (size: 71) ---


void __thiscall FUN_006794b0(int param_1,int *param_2)



{

  int iVar1;

  LONG LVar2;

  

  iVar1 = *(int *)(param_1 + 8);

  if (iVar1 != *param_2) {

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

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

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

    }

    iVar1 = *param_2;

    *(int *)(param_1 + 8) = iVar1;

                    /* WARNING: Could not recover jumptable at 0x006794ec. Too many branches */

                    /* WARNING: Treating indirect jump as call */

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

    return;

  }

  return;

}





// --- FUN_00679500 at 0x00679500 (size: 71) ---


void __thiscall FUN_00679500(int param_1,int *param_2)



{

  int iVar1;

  LONG LVar2;

  

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

  if (iVar1 != *param_2) {

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

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

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

    }

    iVar1 = *param_2;

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

                    /* WARNING: Could not recover jumptable at 0x0067953c. Too many branches */

                    /* WARNING: Treating indirect jump as call */

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

    return;

  }

  return;

}





// --- FUN_00679550 at 0x00679550 (size: 83) ---


void __fastcall FUN_00679550(undefined4 *param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)(param_1[3] + -0x14);

  *param_1 = &PTR_FUN_007ff204;

  LVar1 = InterlockedDecrement((LONG *)(param_1[3] + -0x10));

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

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

  }

  puVar2 = (undefined4 *)(param_1[2] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(param_1[2] + -0x10));

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

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

  }

  *param_1 = &PTR_LAB_00796c4c;

  return;

}





// --- FUN_006795b0 at 0x006795B0 (size: 30) ---


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



{

  FUN_00679550();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_006795d0 at 0x006795D0 (size: 152) ---


undefined4 * __thiscall FUN_006795d0(undefined4 *param_1,int param_2,int param_3)



{

  undefined4 uVar1;

  LONG LVar2;

  

  param_1[1] = 1;

  *param_1 = &PTR_FUN_007ff204;

  param_1[2] = param_2;

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

  param_1[3] = param_3;

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

  param_1[4] = DAT_008f8704;

  param_1[5] = 0;

  param_1[6] = 0;

  *(undefined1 *)(param_1 + 7) = 1;

  uVar1 = FUN_005df4c4();

  param_1[8] = uVar1;

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

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

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

  }

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

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

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

  }

  return param_1;

}





// --- FUN_00679670 at 0x00679670 (size: 183) ---


undefined4 * __thiscall FUN_00679670(int *param_1,undefined4 param_2,int param_3)



{

  undefined4 *puVar1;

  int iVar2;

  char cVar3;

  LONG LVar4;

  undefined4 *unaff_EBX;

  int unaff_ESI;

  int *piVar5;

  int iVar6;

  int **ppiVar7;

  undefined4 uVar8;

  int *local_4;

  

  iVar2 = param_3;

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

  local_4 = param_1;

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

  thunk_FUN_0040c720(&param_3);

  uVar8 = 1;

  ppiVar7 = &local_4;

  local_4 = (int *)0x0;

  iVar6 = param_3;

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

  cVar3 = (**(code **)(*param_1 + 0x54))(iVar6,ppiVar7,uVar8);

  piVar5 = local_4 + -5;

  if (cVar3 == '\0') {

    *unaff_EBX = DAT_008f8704;

  }

  else {

    *unaff_EBX = *(undefined4 *)(unaff_ESI + 0x10);

  }

  LVar4 = InterlockedDecrement(local_4 + -4);

  if ((LVar4 == 0) && (piVar5 != (int *)0x0)) {

    (**(code **)*piVar5)(1);

  }

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

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

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

  }

  return unaff_EBX;

}





// --- FUN_006797d0 at 0x006797D0 (size: 134) ---


uint __thiscall FUN_006797d0(int *param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  uint uVar2;

  LONG LVar3;

  undefined *puVar4;

  LONG *lpAddend;

  int *unaff_retaddr;

  undefined4 local_4;

  

  local_4 = 0;

  cVar1 = (**(code **)(*param_1 + 0x58))(param_2,param_3,&local_4);

  if (cVar1 != '\0') {

    uVar2 = (**(code **)(*param_1 + 0x5c))(param_3,unaff_retaddr);

    return uVar2;

  }

  puVar4 = (undefined *)*unaff_retaddr;

  if (puVar4 != PTR_DAT_00818344) {

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

    if ((LVar3 == 0) && ((undefined4 *)(puVar4 + -0x14) != (undefined4 *)0x0)) {

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

    }

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

    *unaff_retaddr = (int)PTR_DAT_00818344;

    puVar4 = (undefined *)InterlockedIncrement(lpAddend);

  }

  return (uint)puVar4 & 0xffffff00;

}





// --- FUN_00679ae0 at 0x00679AE0 (size: 267) ---


undefined1 FUN_00679ae0(undefined4 *param_1)



{

  byte bVar1;

  char cVar2;

  byte *pbVar3;

  int iVar4;

  LONG LVar5;

  undefined1 uVar6;

  byte *pbVar7;

  undefined4 *puVar8;

  bool bVar9;

  byte *local_4;

  

  local_4 = PTR_DAT_00818344;

  uVar6 = 0;

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

  puVar8 = param_1;

  cVar2 = FUN_0040dc00(param_1,&local_4);

  if (cVar2 != '\0') {

    thunk_FUN_0040da10(&local_4,1);

    pbVar7 = (byte *)*puVar8;

    pbVar3 = local_4;

    do {

      bVar1 = *pbVar3;

      bVar9 = bVar1 < *pbVar7;

      if (bVar1 != *pbVar7) {

LAB_00679b55:

        iVar4 = (1 - (uint)bVar9) - (uint)(bVar9 != 0);

        goto LAB_00679b5a;

      }

      if (bVar1 == 0) break;

      bVar1 = pbVar3[1];

      bVar9 = bVar1 < pbVar7[1];

      if (bVar1 != pbVar7[1]) goto LAB_00679b55;

      pbVar3 = pbVar3 + 2;

      pbVar7 = pbVar7 + 2;

    } while (bVar1 != 0);

    iVar4 = 0;

LAB_00679b5a:

    if (iVar4 != 0) {

      param_1 = (undefined4 *)PTR_DAT_00818344;

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

      thunk_FUN_0040c780(&param_1,&local_4);

      thunk_FUN_0040c720(&local_4);

      FUN_006794b0(&param_1);

      FUN_00679500(&local_4);

      puVar8 = param_1 + -5;

      uVar6 = 1;

      LVar5 = InterlockedDecrement(param_1 + -4);

      if ((LVar5 == 0) && (puVar8 != (undefined4 *)0x0)) {

        (**(code **)*puVar8)(1);

      }

    }

  }

  pbVar7 = local_4 + -0x14;

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

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

    (*(code *)**(undefined4 **)pbVar7)(1);

  }

  return uVar6;

}





// --- FUN_00679bf0 at 0x00679BF0 (size: 134) ---


bool FUN_00679bf0(char *param_1,char *param_2)



{

  char *pcVar1;

  char cVar2;

  char *pcVar3;

  LONG LVar4;

  char *pcVar5;

  bool bVar6;

  

  bVar6 = false;

  pcVar3 = param_1;

  pcVar5 = param_2;

  if (*param_1 != '\0') {

    do {

      cVar2 = *pcVar3;

      if (cVar2 == ':') {

        bVar6 = bVar6 == false;

      }

      if (pcVar3 == param_1) {

LAB_00679c29:

        if (cVar2 == '/') {

          if (pcVar3[1] == '/') goto LAB_00679c3a;

          *pcVar5 = '\\';

        }

        else {

LAB_00679c37:

          *pcVar5 = cVar2;

        }

        pcVar5 = pcVar5 + 1;

      }

      else {

        if (cVar2 != '/') goto LAB_00679c37;

        if (pcVar3[1] != '/') goto LAB_00679c29;

      }

LAB_00679c3a:

      pcVar1 = pcVar3 + 1;

      pcVar3 = pcVar3 + 1;

    } while (*pcVar1 != '\0');

    if ((param_2 < pcVar5) && (pcVar5[-1] == '\\')) {

      pcVar5 = pcVar5 + -1;

    }

  }

  *pcVar5 = '\0';

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

  if ((LVar4 == 0) && (param_1 + -0x14 != (char *)0x0)) {

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

  }

  return bVar6;

}





// --- FUN_0067a110 at 0x0067A110 (size: 67) ---


undefined4 __thiscall FUN_0067a110(int param_1,uint param_2)



{

  uint *puVar1;

  uint uVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0xdc) + (param_2 % *(uint *)(param_1 + 0xe4)) * 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];

  if (uVar2 == 0) {

    return 0;

  }

  return CONCAT31((int3)(uVar2 >> 8),*(undefined1 *)(uVar2 + 1));

}





// --- FUN_0067a160 at 0x0067A160 (size: 66) ---


undefined4 __thiscall FUN_0067a160(int param_1,uint param_2)



{

  uint *puVar1;

  undefined1 *puVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0xdc) + (param_2 % *(uint *)(param_1 + 0xe4)) * 4);

  while( true ) {

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

      return 0;

    }

    if (*puVar1 == param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

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

    return 0;

  }

  puVar2 = (undefined1 *)puVar1[2];

  if (puVar2 == (undefined1 *)0x0) {

    return 0;

  }

  return CONCAT31((int3)((uint)puVar2 >> 8),*puVar2);

}





// --- FUN_0067a1b0 at 0x0067A1B0 (size: 73) ---


void __fastcall FUN_0067a1b0(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_0067ade0(*puVar2);

  return;

}





// --- FUN_0067a200 at 0x0067A200 (size: 157) ---


void __fastcall FUN_0067a200(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  *(undefined ***)(param_1 + 0x14) = &PTR_FUN_007ff208;

  FUN_005870f0();

  *(undefined ***)(param_1 + 0x18) = &PTR_FUN_007ff1f8;

  if (*(void **)(param_1 + 0x78) != (void *)(param_1 + 0x1c)) {

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

  }

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

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

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

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

  puVar2 = (undefined4 *)(*(int *)(param_1 + 0xc) + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(*(int *)(param_1 + 0xc) + -0x10));

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

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

  }

  puVar2 = (undefined4 *)(*(int *)(param_1 + 8) + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(*(int *)(param_1 + 8) + -0x10));

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

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

  }

  puVar2 = (undefined4 *)(*(int *)(param_1 + 4) + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(*(int *)(param_1 + 4) + -0x10));

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

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

  }

  return;

}





// --- FUN_0067a2f0 at 0x0067A2F0 (size: 73) ---


void __fastcall FUN_0067a2f0(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_0067aca0(*puVar2);

  return;

}





// --- FUN_0067a340 at 0x0067A340 (size: 143) ---


undefined4 * __thiscall FUN_0067a340(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_007ff1f8;

  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_0067a3d0 at 0x0067A3D0 (size: 143) ---


undefined4 * __thiscall FUN_0067a3d0(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_007ff1fc;

  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_0067a460 at 0x0067A460 (size: 77) ---


void __thiscall FUN_0067a460(int param_1,int param_2)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  

  if (*(int *)(param_1 + 0x68) * 2 < *(int *)(param_1 + 0x6c) + 1) {

    FUN_0067a1b0();

  }

  uVar1 = *(uint *)(param_1 + 0x68);

  uVar3 = FUN_0041aa50();

  uVar3 = uVar3 % uVar1;

  iVar2 = *(int *)(param_1 + 0x60);

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

  *(int *)(iVar2 + uVar3 * 4) = param_2;

  uVar1 = iVar2 + uVar3 * 4;

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

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

  }

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

  return;

}





// --- FUN_0067a4b0 at 0x0067A4B0 (size: 143) ---


undefined4 * __thiscall FUN_0067a4b0(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_007ff200;

  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_0067a540 at 0x0067A540 (size: 73) ---


void __fastcall FUN_0067a540(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_0067af20(*puVar2);

  return;

}





// --- FUN_0067abd0 at 0x0067ABD0 (size: 74) ---


void __fastcall FUN_0067abd0(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

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

  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_0067aca0(*puVar2);

  return;

}





// --- FUN_0067ac20 at 0x0067AC20 (size: 120) ---


uint __thiscall FUN_0067ac20(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_0067ac4b:

      if ((int)(*(uint *)(param_1 + 0x68) * 2) < *(int *)(param_1 + 0x6c) + 1) {

        FUN_0067a2f0();

      }

      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_0067ac4b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_0067aca0 at 0x0067ACA0 (size: 310) ---


undefined4 __thiscall FUN_0067aca0(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_0067aca0(*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_0067acef;

      }

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

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

    }

    puVar11 = (uint *)0x0;

    puVar9 = (uint *)0x0;

LAB_0067acef:

    puVar7 = (uint *)*puVar11;

    if (puVar7 == puVar9) {

LAB_0067ad02:

      *puVar11 = puVar7[1];

    }

    else {

      do {

        puVar6 = puVar7;

        puVar7 = (uint *)puVar6[1];

      } while (puVar7 != puVar9);

      if (puVar6 == (uint *)0x0) goto LAB_0067ad02;

      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_0067ade0 at 0x0067ADE0 (size: 320) ---


undefined4 __thiscall FUN_0067ade0(int param_1,int param_2)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  int iVar5;

  int iVar6;

  undefined4 *puVar7;

  uint uVar8;

  int iVar9;

  int *piVar10;

  

  iVar2 = param_2;

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

    return 0;

  }

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

  iVar3 = 0;

  do {

    if (iVar6 == 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;

      iVar2 = param_2;

      while (iVar3 != 0) {

        param_2 = *(int *)(param_1 + 0x68);

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

        PTR_DAT_00818558 = (undefined *)puVar4;

        if (param_2 * 2 < *(int *)(param_1 + 0x6c) + 1) {

          puVar7 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,puVar4,&param_2,param_2,0);

          if ((puVar7 != puVar4) || (puVar7 = puVar7 + -1, puVar7 != puVar4)) {

            puVar7 = puVar7 + 1;

          }

          FUN_0067ade0(*puVar7);

          iVar2 = param_2;

        }

        param_2 = iVar2;

        uVar1 = *(uint *)(param_1 + 0x68);

        uVar8 = FUN_0041aa50();

        uVar8 = uVar8 % uVar1;

        iVar2 = *(int *)(param_1 + 0x60);

        *(undefined4 *)(iVar3 + 4) = *(undefined4 *)(iVar2 + uVar8 * 4);

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

        uVar1 = iVar2 + uVar8 * 4;

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

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

        }

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

        puVar4 = (undefined4 *)PTR_DAT_00818558;

        iVar2 = param_2;

        iVar3 = iVar6;

      }

      PTR_DAT_00818558 = (undefined *)puVar4;

      return 1;

    }

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

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

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

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

        iVar9 = *piVar10;

        goto LAB_0067ae2f;

      }

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

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

    }

    piVar10 = (int *)0x0;

    iVar9 = 0;

LAB_0067ae2f:

    iVar6 = *piVar10;

    if (iVar6 == iVar9) {

LAB_0067ae42:

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

    }

    else {

      do {

        iVar5 = iVar6;

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

      } while (iVar6 != iVar9);

      if (iVar5 == 0) goto LAB_0067ae42;

      *(undefined4 *)(iVar5 + 4) = *(undefined4 *)(iVar6 + 4);

    }

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

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

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

    iVar3 = iVar9;

  } while( true );

}





// --- FUN_0067af20 at 0x0067AF20 (size: 310) ---


undefined4 __thiscall FUN_0067af20(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_0067af20(*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_0067af6f;

      }

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

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

    }

    puVar11 = (uint *)0x0;

    puVar9 = (uint *)0x0;

LAB_0067af6f:

    puVar7 = (uint *)*puVar11;

    if (puVar7 == puVar9) {

LAB_0067af82:

      *puVar11 = puVar7[1];

    }

    else {

      do {

        puVar6 = puVar7;

        puVar7 = (uint *)puVar6[1];

      } while (puVar7 != puVar9);

      if (puVar6 == (uint *)0x0) goto LAB_0067af82;

      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_0067b060 at 0x0067B060 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007ff208;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007ff1f8;

  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_0067b0c0 at 0x0067B0C0 (size: 88) ---


undefined4 FUN_0067b0c0(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_0067ac20(puVar2);

  if (cVar1 == '\0') {

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

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_0067b120 at 0x0067B120 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007ff20c;

  FUN_00433a10();

  param_1[1] = &PTR_FUN_007ff1fc;

  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_0067b180 at 0x0067B180 (size: 157) ---


undefined4 FUN_0067b180(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_0041aeb0(local_c,piVar2);

  if (local_4 == 0) {

    FUN_0067a460(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_0067b220 at 0x0067B220 (size: 120) ---


uint __thiscall FUN_0067b220(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_0067b24b:

      if ((int)(*(uint *)(param_1 + 0x68) * 2) < *(int *)(param_1 + 0x6c) + 1) {

        FUN_0067a540();

      }

      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_0067b24b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_0067b2a0 at 0x0067B2A0 (size: 92) ---


int __fastcall FUN_0067b2a0(int param_1)



{

  LONG *pLVar1;

  

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  *(undefined **)(param_1 + 4) = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  *(undefined **)(param_1 + 8) = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  *(undefined **)(param_1 + 0xc) = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  *(undefined ***)(param_1 + 0x14) = &PTR_FUN_007ff208;

  FUN_0067a340(0x800);

  *(undefined ***)(param_1 + 0x14) = &PTR_FUN_007ff208;

  return param_1;

}





// --- FUN_0067be80 at 0x0067BE80 (size: 88) ---


undefined4 FUN_0067be80(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_0067b220(puVar2);

  if (cVar1 == '\0') {

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

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_0067bee0 at 0x0067BEE0 (size: 402) ---


void __fastcall FUN_0067bee0(int param_1)



{

  int *piVar1;

  undefined4 *puVar2;

  void *pvVar3;

  int *piVar4;

  int iVar5;

  int iVar6;

  int *piStack_14;

  undefined1 local_c [12];

  

  piVar4 = (int *)FUN_0052dcf0(local_c);

  iVar6 = piVar4[2];

  iVar5 = *piVar4;

  piVar4 = (int *)piVar4[1];

  while (iVar6 != 0) {

    do {

      puVar2 = *(undefined4 **)(iVar6 + 8);

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

        piVar1 = puVar2 + 1;

        *piVar1 = *piVar1 + -1;

        if (*piVar1 == 0) {

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

        }

      }

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

    } while (iVar6 != 0);

    do {

      piVar4 = piVar4 + 1;

      if (piVar4 == (int *)(*(int *)(iVar5 + 0x60) + *(int *)(iVar5 + 0x68) * 4)) goto LAB_0067bf43;

      iVar6 = *piVar4;

    } while (iVar6 == 0);

  }

LAB_0067bf43:

  FUN_00433a10();

  piVar4 = *(int **)(param_1 + 0xe0);

  do {

    if (piVar4 == (int *)(*(int *)(param_1 + 0xdc) + *(int *)(param_1 + 0xe4) * 4)) {

      piStack_14 = (int *)0x0;

      iVar5 = 0;

joined_r0x0067bf8a:

      while (iVar5 != 0) {

        do {

          pvVar3 = *(void **)(iVar5 + 8);

          piVar4 = *(int **)((int)pvVar3 + 0x7c);

          while (piVar4 != (int *)(*(int *)((int)pvVar3 + 0x78) + *(int *)((int)pvVar3 + 0x80) * 4))

          {

            if (**(int **)((int)pvVar3 + 0x7c) != 0) {

              piVar4 = *(int **)((int)pvVar3 + 0x7c);

              iVar6 = *piVar4;

              goto joined_r0x0067bfd1;

            }

            piVar4 = *(int **)((int)pvVar3 + 0x7c) + 1;

            *(int **)((int)pvVar3 + 0x7c) = piVar4;

          }

          piVar4 = (int *)0x0;

          iVar6 = 0;

joined_r0x0067bfd1:

          while (iVar6 != 0) {

            do {

              puVar2 = *(undefined4 **)(iVar6 + 8);

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

                piVar1 = puVar2 + 1;

                *piVar1 = *piVar1 + -1;

                if (*piVar1 == 0) {

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

                }

              }

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

            } while (iVar6 != 0);

            do {

              piVar4 = piVar4 + 1;

              if (piVar4 == (int *)(*(int *)((int)pvVar3 + 0x78) + *(int *)((int)pvVar3 + 0x80) * 4)

                 ) goto LAB_0067c008;

              iVar6 = *piVar4;

            } while (iVar6 == 0);

          }

LAB_0067c008:

          FUN_005870f0();

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

            FUN_0067a200();

            operator_delete(pvVar3);

          }

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

        } while (iVar5 != 0);

        do {

          piStack_14 = piStack_14 + 1;

          if (piStack_14 == (int *)(*(int *)(param_1 + 0xdc) + *(int *)(param_1 + 0xe4) * 4))

          goto LAB_0067c063;

          iVar5 = *piStack_14;

        } while (iVar5 == 0);

      }

LAB_0067c063:

      FUN_005870f0();

      return;

    }

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

      piStack_14 = *(int **)(param_1 + 0xe0);

      iVar5 = *piStack_14;

      goto joined_r0x0067bf8a;

    }

    piVar4 = *(int **)(param_1 + 0xe0) + 1;

    *(int **)(param_1 + 0xe0) = piVar4;

  } while( true );

}





// --- FUN_0067c190 at 0x0067C190 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007ff278;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007ff200;

  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_0067c1f0 at 0x0067C1F0 (size: 130) ---


void __fastcall FUN_0067c1f0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007ff210;

  FUN_0067bee0();

  param_1[0x1e] = &PTR_FUN_007ff278;

  FUN_005870f0();

  param_1[0x1f] = &PTR_FUN_007ff200;

  if ((undefined4 *)param_1[0x37] != param_1 + 0x20) {

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

  }

  param_1[0x37] = 0;

  param_1[0x38] = 0;

  param_1[0x39] = 0;

  param_1[0x3a] = 0;

  param_1[1] = &PTR_FUN_007ff20c;

  FUN_00433a10();

  param_1[2] = &PTR_FUN_007ff1fc;

  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_0067c280 at 0x0067C280 (size: 129) ---


undefined4 * __thiscall FUN_0067c280(undefined4 *param_1,int param_2)



{

  undefined *puVar1;

  undefined4 *puVar2;

  

  *param_1 = &PTR_FUN_007ff210;

  param_1[1] = &PTR_FUN_007ff20c;

  FUN_0067a3d0(0);

  param_1[1] = &PTR_FUN_007ff20c;

  param_1[0x1e] = &PTR_FUN_007ff278;

  FUN_0067a4b0(0);

  param_1[0x1e] = &PTR_FUN_007ff278;

  puVar1 = PTR_DAT_00818558;

  if (param_2 != 0) {

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

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

      puVar2 = puVar2 + -1;

    }

    FUN_0067ade0(*puVar2);

  }

  return param_1;

}





// --- FUN_0067c690 at 0x0067C690 (size: 37) ---


undefined4 FUN_0067c690(wchar_t param_1)



{

  wchar_t *pwVar1;

  

  if (param_1 != L'\0') {

    pwVar1 = wcschr(L"[]!{}#\\|^$",param_1);

    if (pwVar1 != (wchar_t *)0x0) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_0067c6c0 at 0x0067C6C0 (size: 86) ---


wchar_t FUN_0067c6c0(wchar_t param_1)



{

  wchar_t *pwVar1;

  

  switch(param_1) {

  case L'\t':

    return L't';

  case L'\n':

    return L'n';

  case L'\r':

    return L'r';

  case L'\"':

    return L'q';

  }

  if ((param_1 != L'\0') && (pwVar1 = wcschr(L"[]!{}#\\|^$",param_1), pwVar1 != (wchar_t *)0x0)) {

    return param_1;

  }

  return L'\0';

}





// --- FUN_0067c750 at 0x0067C750 (size: 79) ---


uint FUN_0067c750(wchar_t param_1)



{

  int iVar1;

  undefined2 uVar3;

  wchar_t *pwVar2;

  

  iVar1 = (ushort)param_1 - 0x6e;

  uVar3 = (undefined2)((uint)iVar1 >> 0x10);

  switch(iVar1) {

  case 0:

    return CONCAT22(uVar3,10);

  case 3:

    return CONCAT22(uVar3,0x22);

  case 4:

    return CONCAT22(uVar3,0xd);

  case 6:

    return CONCAT22(uVar3,9);

  }

  if ((param_1 != L'\0') && (pwVar2 = wcschr(L"[]!{}#\\|^$",param_1), pwVar2 != (wchar_t *)0x0)) {

    return (uint)(ushort)param_1;

  }

  return 0;

}





// --- FUN_0067c7c0 at 0x0067C7C0 (size: 39) ---


uint FUN_0067c7c0(int param_1)



{

  uint uVar1;

  

  if ((DAT_00837cc8 != (int *)0x0) && (*DAT_00837cc8 != 0)) {

    uVar1 = FUN_00422160(param_1);

    return uVar1;

  }

  return (uint)(param_1 == 1);

}





// --- FUN_0067c7f0 at 0x0067C7F0 (size: 443) ---


undefined1 FUN_0067c7f0(int *param_1)



{

  int iVar1;

  uint uVar2;

  undefined *puVar3;

  bool bVar4;

  undefined *_Dest;

  ushort *puVar5;

  LONG LVar6;

  short *psVar7;

  uint uVar8;

  uint uVar9;

  undefined1 local_d;

  uint local_8;

  uint local_4;

  

  _Dest = PTR_DAT_00818340;

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

  uVar9 = *(int *)(*param_1 + -4) - 1;

  local_d = 0;

  bVar4 = false;

  uVar8 = 0;

  local_4 = uVar9;

  if (uVar9 != 0) {

    do {

      iVar1 = *param_1;

      uVar2 = *(uint *)(iVar1 + -4);

      psVar7 = (short *)(iVar1 + -2 + uVar2 * 2);

      if (uVar8 < uVar2) {

        psVar7 = (short *)(iVar1 + uVar8 * 2);

      }

      if (*psVar7 == 0x20) {

LAB_0067c884:

        if (bVar4) {

          local_d = 1;

        }

        else {

          if (uVar8 < uVar2) {

            puVar5 = (ushort *)(iVar1 + uVar8 * 2);

          }

          else {

            puVar5 = (ushort *)(iVar1 + -2 + uVar2 * 2);

          }

          local_8 = (uint)*puVar5;

          if (*puVar5 != 0) {

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

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

              *(uint *)(_Dest + -4) = iVar1 + 1U;

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

            }

            else {

              FUN_004022d0(iVar1);

              wcscpy((wchar_t *)_Dest,(wchar_t *)_Dest);

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

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

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

              }

            }

            wcsncpy((wchar_t *)(_Dest + iVar1 * 2 + -2),(wchar_t *)&local_8,1);

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

            uVar9 = local_4;

          }

        }

        bVar4 = true;

      }

      else {

        psVar7 = (short *)(iVar1 + -2 + uVar2 * 2);

        if (uVar8 < uVar2) {

          psVar7 = (short *)(iVar1 + uVar8 * 2);

        }

        if (*psVar7 == 9) goto LAB_0067c884;

        if (uVar8 < uVar2) {

          puVar5 = (ushort *)(iVar1 + uVar8 * 2);

        }

        else {

          puVar5 = (ushort *)(iVar1 + -2 + uVar2 * 2);

        }

        local_8 = (uint)*puVar5;

        FUN_00402490(&local_8,1);

        bVar4 = false;

      }

      uVar8 = uVar8 + 1;

    } while (uVar8 < uVar9);

  }

  puVar3 = (undefined *)*param_1;

  if (puVar3 != _Dest) {

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

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

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

    }

    *param_1 = (int)_Dest;

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

  }

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

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

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

  }

  return local_d;

}





// --- FUN_0067c9b0 at 0x0067C9B0 (size: 50) ---


void FUN_0067c9b0(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = DAT_00837750;

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

  FUN_004d68c0(1,0,iVar1);

  FUN_0067c7f0(param_1);

  return;

}





// --- FUN_0067c9f0 at 0x0067C9F0 (size: 247) ---


int * FUN_0067c9f0(int *param_1,int *param_2)



{

  int iVar1;

  wint_t wVar2;

  int iVar3;

  wint_t *pwVar4;

  LONG LVar5;

  uint uVar6;

  uint uVar7;

  

  iVar1 = *param_2;

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

  uVar6 = *(int *)(iVar1 + -4) - 1;

  uVar7 = 0;

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

    do {

      if (uVar7 < *(uint *)(iVar1 + -4)) {

        pwVar4 = (wint_t *)(iVar1 + uVar7 * 2);

      }

      else {

        pwVar4 = (wint_t *)(iVar1 + -2 + *(uint *)(iVar1 + -4) * 2);

      }

      wVar2 = *pwVar4;

      iVar3 = iswspace(wVar2);

      if (((((iVar3 == 0) && (iVar3 = iswpunct(wVar2), iVar3 == 0)) && (wVar2 != 0xbf)) &&

          (wVar2 != 0xa1)) || (((wVar2 == 0x5c || (wVar2 == 0x2f)) || (wVar2 == 0x40)))) {

        if (uVar7 < uVar6) {

          if (uVar7 < *(uint *)(iVar1 + -4)) {

            pwVar4 = (wint_t *)(iVar1 + uVar7 * 2);

          }

          else {

            pwVar4 = (wint_t *)(iVar1 + -2 + *(uint *)(iVar1 + -4) * 2);

          }

          wVar2 = towupper(*pwVar4);

          FUN_004089f0(uVar7,wVar2);

        }

        break;

      }

      uVar7 = uVar7 + 1;

    } while (uVar7 < uVar6);

  }

  *param_1 = iVar1;

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

  LVar5 = InterlockedDecrement((LONG *)(iVar1 + -0x10));

  if ((LVar5 == 0) && ((undefined4 *)(iVar1 + -0x14) != (undefined4 *)0x0)) {

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

  }

  return param_1;

}





// --- FUN_0067caf0 at 0x0067CAF0 (size: 198) ---


int * FUN_0067caf0(int *param_1,int *param_2)



{

  int iVar1;

  int iVar2;

  LONG LVar3;

  

  iVar1 = *param_2;

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

  iVar2 = FUN_0040b340(iVar1,0x5b,0x5c);

  if (iVar2 != 0) {

    iVar2 = iVar2 - iVar1 >> 1;

    if (iVar2 != 0) {

      FUN_0040b150(iVar2);

    }

    FUN_0040ba00();

    iVar2 = DAT_00837750;

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

    FUN_004d68c0(0,1,iVar2);

  }

  *param_1 = iVar1;

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

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

  if ((LVar3 == 0) && ((undefined4 *)(iVar1 + -0x14) != (undefined4 *)0x0)) {

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

  }

  return param_1;

}





// --- FUN_0067cbc0 at 0x0067CBC0 (size: 500) ---


undefined4 * FUN_0067cbc0(undefined4 *param_1,int *param_2)



{

  undefined *_Dest;

  int iVar1;

  undefined2 *puVar2;

  uint uVar3;

  ushort *puVar4;

  LONG LVar5;

  uint local_8;

  uint local_4;

  

  _Dest = PTR_DAT_00818340;

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

  iVar1 = *param_2;

  uVar3 = *(uint *)(iVar1 + -4);

  local_8 = 0;

  if (uVar3 != 1) {

    do {

      if (local_8 < uVar3) {

        puVar2 = (undefined2 *)(iVar1 + local_8 * 2);

      }

      else {

        puVar2 = (undefined2 *)(iVar1 + -2 + uVar3 * 2);

      }

      uVar3 = FUN_0067c6c0(*puVar2);

      if ((short)uVar3 == 0) {

        iVar1 = *param_2;

        if (local_8 < *(uint *)(iVar1 + -4)) {

          puVar4 = (ushort *)(iVar1 + local_8 * 2);

        }

        else {

          puVar4 = (ushort *)(iVar1 + -2 + *(uint *)(iVar1 + -4) * 2);

        }

        local_4 = (uint)*puVar4;

        if (*puVar4 != 0) goto LAB_0067ccd6;

      }

      else {

        local_4 = 0x5c;

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

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

          *(uint *)(_Dest + -4) = iVar1 + 1U;

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

        }

        else {

          FUN_004022d0(iVar1);

          wcscpy((wchar_t *)_Dest,(wchar_t *)_Dest);

          LVar5 = InterlockedDecrement((LONG *)(_Dest + -0x10));

          if ((LVar5 == 0) && ((undefined4 *)(_Dest + -0x14) != (undefined4 *)0x0)) {

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

          }

        }

        wcsncpy((wchar_t *)(_Dest + iVar1 * 2 + -2),(wchar_t *)&local_4,1);

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

        local_4 = uVar3;

LAB_0067ccd6:

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

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

          *(uint *)(_Dest + -4) = iVar1 + 1U;

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

        }

        else {

          FUN_004022d0(iVar1);

          wcscpy((wchar_t *)_Dest,(wchar_t *)_Dest);

          LVar5 = InterlockedDecrement((LONG *)(_Dest + -0x10));

          if ((LVar5 == 0) && ((undefined4 *)(_Dest + -0x14) != (undefined4 *)0x0)) {

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

          }

        }

        wcsncpy((wchar_t *)(_Dest + iVar1 * 2 + -2),(wchar_t *)&local_4,1);

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

      }

      iVar1 = *param_2;

      uVar3 = *(uint *)(iVar1 + -4);

      local_8 = local_8 + 1;

    } while (local_8 < uVar3 - 1);

  }

  *param_1 = _Dest;

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

  LVar5 = InterlockedDecrement((LONG *)(_Dest + -0x10));

  if ((LVar5 == 0) && ((undefined4 *)(_Dest + -0x14) != (undefined4 *)0x0)) {

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

  }

  return param_1;

}





// --- FUN_0067cdc0 at 0x0067CDC0 (size: 396) ---


undefined4 * FUN_0067cdc0(undefined4 *param_1,int *param_2)



{

  uint uVar1;

  undefined *_Dest;

  int *piVar2;

  int iVar3;

  undefined2 *puVar4;

  undefined4 uVar5;

  ushort *puVar6;

  LONG LVar7;

  int *piVar8;

  int *piVar9;

  short *psVar10;

  uint uVar11;

  uint local_4;

  

  _Dest = PTR_DAT_00818340;

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

  piVar2 = param_2;

  iVar3 = *param_2;

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

  uVar11 = 0;

  if (piVar8 != (int *)0x1) {

    param_2 = (int *)0x1;

    do {

      piVar9 = param_2;

      if (param_2 < piVar8) {

        puVar4 = (undefined2 *)(iVar3 + 2 + uVar11 * 2);

      }

      else {

        puVar4 = (undefined2 *)(iVar3 + -2 + (int)piVar8 * 2);

      }

      uVar5 = FUN_0067c750(*puVar4);

      iVar3 = *piVar2;

      uVar1 = *(uint *)(iVar3 + -4);

      psVar10 = (short *)(iVar3 + -2 + uVar1 * 2);

      if (uVar11 < uVar1) {

        psVar10 = (short *)(iVar3 + uVar11 * 2);

      }

      if ((*psVar10 == 0x5c) && ((short)uVar5 != 0)) {

        uVar11 = uVar11 + 1;

        param_2 = (int *)uVar5;

        FUN_00402490(&param_2,1);

        piVar9 = (int *)((int)piVar9 + 1);

      }

      else {

        puVar6 = (ushort *)(iVar3 + -2 + uVar1 * 2);

        if (uVar11 < uVar1) {

          puVar6 = (ushort *)(iVar3 + uVar11 * 2);

        }

        local_4 = (uint)*puVar6;

        if (*puVar6 != 0) {

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

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

            *(uint *)(_Dest + -4) = iVar3 + 1U;

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

          }

          else {

            FUN_004022d0(iVar3);

            wcscpy((wchar_t *)_Dest,(wchar_t *)_Dest);

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

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

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

            }

          }

          wcsncpy((wchar_t *)(_Dest + iVar3 * 2 + -2),(wchar_t *)&local_4,1);

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

          piVar9 = param_2;

        }

      }

      iVar3 = *piVar2;

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

      uVar11 = uVar11 + 1;

      param_2 = (int *)((int)piVar9 + 1);

    } while (uVar11 < (int)piVar8 - 1U);

  }

  *param_1 = _Dest;

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

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

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

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

  }

  return param_1;

}





// --- FUN_0067cf50 at 0x0067CF50 (size: 43) ---


undefined4 FUN_0067cf50(undefined4 param_1)



{

  undefined4 uVar1;

  

  if ((DAT_00837cc8 != (int *)0x0) && (*DAT_00837cc8 != 0)) {

    uVar1 = FUN_00422650(param_1);

    return uVar1;

  }

  FUN_00407e40(&DAT_007ff2b8);

  return 1;

}





// --- FUN_0067cf80 at 0x0067CF80 (size: 43) ---


undefined4 FUN_0067cf80(undefined4 param_1)



{

  undefined4 uVar1;

  

  if ((DAT_00837cc8 != (int *)0x0) && (*DAT_00837cc8 != 0)) {

    uVar1 = FUN_004226a0(param_1);

    return uVar1;

  }

  FUN_00407e40(&DAT_007ff2c0);

  return 1;

}





// --- FUN_0067cfb0 at 0x0067CFB0 (size: 81) ---


undefined4 FUN_0067cfb0(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 uVar1;

  

  if ((DAT_00837cc8 != (int *)0x0) && (*DAT_00837cc8 != 0)) {

    uVar1 = FUN_004226f0(param_1,param_2,param_3);

    return uVar1;

  }

  FUN_00407e40(&DAT_007ff2d8);

  FUN_00407e40(L"mfnp");

  FUN_00407e40(&DAT_007ff2c8);

  return 1;

}





// --- FUN_0067d010 at 0x0067D010 (size: 109) ---


uint __thiscall FUN_0067d010(int *param_1,undefined4 *param_2)



{

  wchar_t *_Str2;

  wchar_t *_Str1;

  int iVar1;

  uint uVar2;

  

  uVar2 = 0;

  if (param_1[2] != 0) {

    do {

      _Str2 = (wchar_t *)*param_2;

      _Str1 = *(wchar_t **)(*param_1 + uVar2 * 4);

      if (*(int *)(_Str1 + -2) == *(int *)(_Str2 + -2)) {

        if ((((*(int *)(_Str1 + -4) == *(int *)(_Str2 + -4)) || (*(int *)(_Str1 + -4) == -1)) ||

            (*(int *)(_Str2 + -4) == -1)) && (iVar1 = wcscmp(_Str1,_Str2), iVar1 == 0)) {

          return uVar2;

        }

      }

      uVar2 = uVar2 + 1;

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

  }

  return 0xffffffff;

}





// --- FUN_0067d080 at 0x0067D080 (size: 157) ---


int FUN_0067d080(undefined4 *param_1,int *param_2)



{

  int iVar1;

  uint uVar2;

  wchar_t *pwVar3;

  short *psVar4;

  uint uVar5;

  int iVar6;

  undefined4 local_4;

  

  uVar5 = 0;

  iVar6 = *(int *)(*param_2 + -4) + -1;

  local_4 = 0;

  if (*(int *)(*param_2 + -4) == 1) {

    return 1;

  }

  if (0 < iVar6) {

    do {

      iVar1 = *param_2;

      uVar2 = *(uint *)(iVar1 + -4);

      psVar4 = (short *)(iVar1 + -2 + uVar2 * 2);

      if (uVar5 < uVar2) {

        psVar4 = (short *)(iVar1 + uVar5 * 2);

      }

      if (*psVar4 == 0x21) {

        uVar5 = uVar5 + 1;

        if (uVar5 < uVar2) {

          pwVar3 = (wchar_t *)(iVar1 + uVar5 * 2);

        }

        else {

          pwVar3 = (wchar_t *)(iVar1 + -2 + uVar2 * 2);

        }

        pwVar3 = wcschr((wchar_t *)*param_1,*pwVar3);

        if (pwVar3 == (wchar_t *)0x0) {

LAB_0067d109:

          local_4 = local_4 + 2;

        }

      }

      else {

        if (uVar5 < uVar2) {

          pwVar3 = (wchar_t *)(iVar1 + uVar5 * 2);

        }

        else {

          pwVar3 = (wchar_t *)(iVar1 + -2 + uVar2 * 2);

        }

        pwVar3 = wcschr((wchar_t *)*param_1,*pwVar3);

        if (pwVar3 != (wchar_t *)0x0) goto LAB_0067d109;

      }

      uVar5 = uVar5 + 1;

    } while ((int)uVar5 < iVar6);

  }

  return local_4;

}





// --- FUN_0067d120 at 0x0067D120 (size: 83) ---


void FUN_0067d120(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  DAT_008f87f8 = *param_1;

  DAT_008f87fc = param_1[1];

  if (DAT_008f8800 != param_1[2]) {

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

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

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

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

    }

    DAT_008f8800 = param_1[2];

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

  }

  return;

}





// --- FUN_0067d180 at 0x0067D180 (size: 83) ---


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



{

  undefined4 *puVar1;

  LONG LVar2;

  

  DAT_008f87f8 = param_1;

  DAT_008f87fc = param_2;

  if (DAT_008f8800 != *param_3) {

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

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

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

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

    }

    DAT_008f8800 = *param_3;

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

  }

  return;

}





// --- FUN_0067d1e0 at 0x0067D1E0 (size: 70) ---


int FUN_0067d1e0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  int iVar4;

  

  piVar3 = *(int **)(param_2 + 0xc);

  iVar2 = 0;

  iVar4 = -1;

  if (piVar3 != (int *)0x0) {

    do {

      iVar1 = FUN_0067d080(param_1 + 0x20,*piVar3 + 0x20);

      if ((iVar4 <= iVar1) && (0 < iVar1)) {

        iVar2 = *piVar3;

        iVar4 = iVar1;

      }

      piVar3 = (int *)piVar3[1];

    } while (piVar3 != (int *)0x0);

  }

  return iVar2;

}





// --- FUN_0067d230 at 0x0067D230 (size: 337) ---


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



{

  undefined *_Dest;

  int *piVar1;

  int iVar2;

  wchar_t *pwVar3;

  ushort *puVar4;

  LONG LVar5;

  uint uVar6;

  uint uVar7;

  

  _Dest = PTR_DAT_00818340;

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

  piVar1 = param_3;

  iVar2 = *param_3;

  uVar6 = *(uint *)(iVar2 + -4);

  uVar7 = 0;

  if (uVar6 != 1) {

    do {

      if (uVar7 < uVar6) {

        pwVar3 = (wchar_t *)(iVar2 + uVar7 * 2);

      }

      else {

        pwVar3 = (wchar_t *)(iVar2 + -2 + uVar6 * 2);

      }

      pwVar3 = wcschr((wchar_t *)*param_2,*pwVar3);

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

        iVar2 = *piVar1;

        if (uVar7 < *(uint *)(iVar2 + -4)) {

          puVar4 = (ushort *)(iVar2 + uVar7 * 2);

        }

        else {

          puVar4 = (ushort *)(iVar2 + -2 + *(uint *)(iVar2 + -4) * 2);

        }

        param_3 = (int *)(uint)*puVar4;

        if (*puVar4 != 0) {

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

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

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

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

          }

          else {

            FUN_004022d0(iVar2);

            wcscpy((wchar_t *)_Dest,(wchar_t *)_Dest);

            LVar5 = InterlockedDecrement((LONG *)(_Dest + -0x10));

            if ((LVar5 == 0) && ((undefined4 *)(_Dest + -0x14) != (undefined4 *)0x0)) {

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

            }

          }

          wcsncpy((wchar_t *)(_Dest + iVar2 * 2 + -2),(wchar_t *)&param_3,1);

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

        }

      }

      iVar2 = *piVar1;

      uVar6 = *(uint *)(iVar2 + -4);

      uVar7 = uVar7 + 1;

    } while (uVar7 < uVar6 - 1);

  }

  *param_1 = _Dest;

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

  LVar5 = InterlockedDecrement((LONG *)(_Dest + -0x10));

  if ((LVar5 == 0) && ((undefined4 *)(_Dest + -0x14) != (undefined4 *)0x0)) {

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

  }

  return param_1;

}





// --- FUN_0067d390 at 0x0067D390 (size: 36) ---


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



{

  *param_1 = &PTR_FUN_007ff308;

  FUN_0049f850();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0067d3c0 at 0x0067D3C0 (size: 3452) ---


undefined4

FUN_0067d3c0(undefined **param_1,int *param_2,undefined4 param_3,wchar_t *param_4,wchar_t *param_5,

            wchar_t *param_6)



{

  uint uVar1;

  int *piVar2;

  int *piVar3;

  LONG LVar4;

  size_t sVar5;

  char *pcVar6;

  int iVar7;

  int *piVar8;

  LONG *lpAddend;

  char *pcVar9;

  undefined **ppuVar10;

  char cVar11;

  int unaff_EBX;

  undefined *puVar12;

  wchar_t *pwVar13;

  undefined4 *puVar14;

  code *pcVar15;

  bool bVar16;

  undefined4 uStack_50;

  undefined *local_4c;

  undefined *local_48;

  undefined *local_44;

  undefined **ppuStack_40;

  undefined **ppuStack_3c;

  undefined **ppuStack_38;

  wchar_t *local_34;

  undefined **ppuStack_30;

  undefined **ppuStack_2c;

  int *local_28;

  int iStack_24;

  undefined **local_20;

  undefined **local_1c;

  int *local_18;

  int local_14;

  undefined **local_10;

  int *local_c;

  int *local_8;

  int local_4;

  

  local_20 = &PTR_FUN_007ff308;

  local_10 = &PTR_FUN_007ff308;

  piVar8 = (int *)param_1[3];

  local_1c = (undefined **)0x0;

  local_18 = (int *)0x0;

  local_14 = 0;

  local_c = (int *)0x0;

  local_8 = (int *)0x0;

  local_4 = 0;

  uStack_50 = (uint)(uint3)uStack_50;

  uVar1 = uStack_50;

  for (; piVar3 = (int *)local_1c, piVar8 != (int *)0x0; piVar8 = (int *)piVar8[1]) {

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

    uStack_50 = uVar1;

    if (iVar7 == 3) {

      piVar3 = (int *)FUN_005df0f5(0xc);

      if (piVar3 != (int *)0x0) {

        *piVar3 = *piVar8;

        piVar3[1] = 0;

        piVar3[2] = 0;

        if (local_1c == (undefined **)0x0) {

          local_14 = local_14 + 1;

          local_1c = (undefined **)piVar3;

          local_18 = piVar3;

        }

        else {

          local_18[1] = (int)piVar3;

          piVar3[2] = (int)local_18;

          local_14 = local_14 + 1;

          local_18 = piVar3;

        }

      }

    }

    else if (iVar7 == 4) {

      piVar3 = (int *)FUN_005df0f5(0xc);

      if (piVar3 != (int *)0x0) {

        *piVar3 = *piVar8;

        piVar3[1] = 0;

        piVar3[2] = 0;

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

          local_4 = local_4 + 1;

          local_c = piVar3;

          local_8 = piVar3;

        }

        else {

          local_8[1] = (int)piVar3;

          piVar3[2] = (int)local_8;

          local_4 = local_4 + 1;

          local_8 = piVar3;

        }

      }

    }

    else if (iVar7 == 5) {

      FUN_00402730(L"item");

      pwVar13 = *(wchar_t **)*piVar8;

      if (*(int *)(pwVar13 + -2) == *(int *)(local_34 + -2)) {

        if (((*(int *)(pwVar13 + -4) == *(int *)(local_34 + -4)) || (*(int *)(pwVar13 + -4) == -1))

           || (*(int *)(local_34 + -4) == -1)) {

          iVar7 = wcscmp(pwVar13,local_34);

          cVar11 = '\x01' - (iVar7 != 0);

        }

        else {

          cVar11 = '\0';

        }

      }

      else {

        cVar11 = '\0';

      }

      pwVar13 = local_34 + -10;

      LVar4 = InterlockedDecrement((LONG *)(local_34 + -8));

      if ((LVar4 == 0) && (pwVar13 != (wchar_t *)0x0)) {

        (*(code *)**(undefined4 **)pwVar13)(1);

      }

      if (cVar11 != '\0') {

        uStack_50._0_3_ = (uint3)uVar1;

        uStack_50 = CONCAT13(1,(uint3)uStack_50);

      }

      FUN_00408e40(*piVar8);

    }

    uVar1 = uStack_50;

  }

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

    if ((undefined **)piVar3 != local_1c) {

      piVar8 = (int *)local_1c;

      do {

        if (*(int *)(*piVar8 + 0x18) == *(int *)(*piVar3 + 0x18)) {

          piVar2 = local_c;

          if (*(int *)(*piVar3 + 0x18) != 0) {

            pcVar9 = "multiple variables with the same ID; ambiguity";

            do {

              pcVar6 = pcVar9;

              pcVar9 = pcVar6 + 1;

            } while (*pcVar6 != '\0');

            FUN_00401280(pcVar6 + -0x7ff3a4);

            pcVar9 = "multiple variables with the same ID; ambiguity";

            ppuVar10 = param_1;

            do {

              cVar11 = *pcVar9;

              pcVar9 = pcVar9 + 1;

              *(char *)ppuVar10 = cVar11;

              ppuVar10 = (undefined **)((int)ppuVar10 + 1);

            } while (cVar11 != '\0');

            DAT_008f87f8 = *(undefined4 *)(*piVar3 + 0x24);

            DAT_008f87fc = 2;

            if (DAT_008f8800 != param_1) {

              ppuVar10 = DAT_008f8800 + -5;

              LVar4 = InterlockedDecrement((LONG *)(DAT_008f8800 + -4));

              if ((LVar4 == 0) && (ppuVar10 != (undefined **)0x0)) {

                (**(code **)*ppuVar10)(1);

              }

              DAT_008f8800 = param_1;

              InterlockedIncrement((LONG *)(param_1 + -4));

            }

            LVar4 = InterlockedDecrement((LONG *)(param_1 + -4));

            if ((LVar4 == 0) && (param_1 + -5 != (undefined **)0x0)) {

              (**(code **)param_1[-5])(1);

            }

            local_10 = &PTR_FUN_007ff308;

            while (piVar8 = local_c, local_c != (int *)0x0) {

              piVar3 = (int *)local_c[1];

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

                local_8 = (int *)0x0;

              }

              else {

                piVar3[2] = 0;

              }

              bVar16 = local_c != (int *)0x0;

              local_c = piVar3;

              if (bVar16) {

                operator_delete(piVar8);

              }

              local_4 = local_4 + -1;

            }

            local_20 = &PTR_FUN_007ff308;

            ppuVar10 = local_1c;

            while (ppuVar10 != (undefined **)0x0) {

              local_1c = (undefined **)ppuVar10[1];

              if (local_1c == (undefined **)0x0) {

                local_18 = (int *)0x0;

              }

              else {

                local_1c[2] = (undefined *)0x0;

              }

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

                operator_delete(ppuVar10);

              }

              local_14 = local_14 + -1;

              ppuVar10 = local_1c;

            }

            return 0;

          }

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

            if (*(int *)(*piVar2 + 0x18) == 0) {

              pcVar9 = "multiple un-numbered variables; ambiguity";

              do {

                pcVar6 = pcVar9;

                pcVar9 = pcVar6 + 1;

              } while (*pcVar6 != '\0');

              FUN_00401280(pcVar6 + -0x7ff3d4);

              pcVar9 = "multiple un-numbered variables; ambiguity";

              ppuVar10 = param_1;

              do {

                cVar11 = *pcVar9;

                pcVar9 = pcVar9 + 1;

                *(char *)ppuVar10 = cVar11;

                ppuVar10 = (undefined **)((int)ppuVar10 + 1);

              } while (cVar11 != '\0');

              DAT_008f87f8 = *(undefined4 *)(*piVar3 + 0x24);

              DAT_008f87fc = 2;

              if (DAT_008f8800 != param_1) {

                ppuVar10 = DAT_008f8800 + -5;

                LVar4 = InterlockedDecrement((LONG *)(DAT_008f8800 + -4));

                if ((LVar4 == 0) && (ppuVar10 != (undefined **)0x0)) {

                  (**(code **)*ppuVar10)(1);

                }

                DAT_008f8800 = param_1;

                InterlockedIncrement((LONG *)(param_1 + -4));

              }

              LVar4 = InterlockedDecrement((LONG *)(param_1 + -4));

              if ((LVar4 == 0) && (param_1 + -5 != (undefined **)0x0)) {

                (**(code **)param_1[-5])(1);

              }

              local_10 = &PTR_FUN_007ff308;

              while (piVar8 = local_c, local_c != (int *)0x0) {

                piVar3 = (int *)local_c[1];

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

                  local_8 = (int *)0x0;

                }

                else {

                  piVar3[2] = 0;

                }

                bVar16 = local_c != (int *)0x0;

                local_c = piVar3;

                if (bVar16) {

                  operator_delete(piVar8);

                }

                local_4 = local_4 + -1;

              }

              local_20 = &PTR_FUN_007ff308;

              ppuVar10 = local_1c;

              while (ppuVar10 != (undefined **)0x0) {

                local_1c = (undefined **)ppuVar10[1];

                if (local_1c == (undefined **)0x0) {

                  local_18 = (int *)0x0;

                }

                else {

                  local_1c[2] = (undefined *)0x0;

                }

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

                  operator_delete(ppuVar10);

                }

                local_14 = local_14 + -1;

                ppuVar10 = local_1c;

              }

              return 0;

            }

          }

        }

        piVar8 = (int *)piVar8[1];

      } while (piVar3 != piVar8);

    }

    if (piVar3 == (int *)0x0) break;

  }

  local_44 = PTR_DAT_00818340;

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

  local_48 = PTR_DAT_00818340;

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

  local_4c = PTR_DAT_00818340;

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

  pcVar15 = InterlockedDecrement_exref;

  puVar12 = (undefined *)*param_2;

  local_34 = (wchar_t *)0x0;

  if (puVar12 != PTR_DAT_00818340) {

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

    if ((LVar4 == 0) && ((undefined4 *)(puVar12 + -0x14) != (undefined4 *)0x0)) {

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

    }

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

    *param_2 = (int)PTR_DAT_00818340;

    InterlockedIncrement(lpAddend);

  }

  local_28 = (int *)param_1[3];

  uStack_50._3_1_ = (char)(uVar1 >> 0x18);

  do {

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

      if (uStack_50._3_1_ != '\0') {

        ppuStack_3c = (undefined **)PTR_DAT_00818340;

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

        ppuStack_38 = (undefined **)PTR_DAT_00818340;

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

        local_34 = (wchar_t *)PTR_DAT_00818340;

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

        FUN_0067cfb0(&ppuStack_3c,&ppuStack_38,&local_34);

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

        piVar8 = (int *)FUN_0067d230(&ppuStack_30,&ppuStack_3c,&local_44);

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

        if (iVar7 != 1) {

          FUN_00402490(*piVar8,iVar7 + -1);

        }

        iVar7 = (*pcVar15)(ppuStack_30 + -4);

        if ((iVar7 == 0) && (ppuStack_30 + -5 != (undefined **)0x0)) {

          (**(code **)ppuStack_30[-5])(1);

        }

        piVar8 = (int *)FUN_0067d230(&local_34,&ppuStack_3c,&local_4c);

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

        if (iVar7 != 1) {

          FUN_00402490(*piVar8,iVar7 + -1);

        }

        pwVar13 = local_34 + -10;

        iVar7 = (*pcVar15)(local_34 + -8);

        if ((iVar7 == 0) && (pwVar13 != (wchar_t *)0x0)) {

          (*(code *)**(undefined4 **)pwVar13)(1);

        }

        piVar8 = (int *)FUN_0067d230(&ppuStack_38,&ppuStack_3c,&stack0xffffffac);

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

        if (iVar7 != 1) {

          FUN_00402490(*piVar8,iVar7 + -1);

        }

        ppuVar10 = ppuStack_38 + -5;

        iVar7 = (*pcVar15)(ppuStack_38 + -4);

        if ((iVar7 == 0) && (ppuVar10 != (undefined **)0x0)) {

          (**(code **)*ppuVar10)(1);

        }

        FUN_004300a0(param_2,L"[%ls]",local_8);

        piVar8 = local_8 + -5;

        iVar7 = (*pcVar15)(local_8 + -4);

        if ((iVar7 == 0) && (piVar8 != (int *)0x0)) {

          (**(code **)*piVar8)(1);

        }

        puVar14 = (undefined4 *)(local_44 + -0x14);

        iVar7 = (*pcVar15)(local_44 + -0x10);

        if ((iVar7 == 0) && (puVar14 != (undefined4 *)0x0)) {

          (**(code **)*puVar14)(1);

        }

        puVar14 = (undefined4 *)(local_4c + -0x14);

        iVar7 = (*pcVar15)(local_4c + -0x10);

        if ((iVar7 == 0) && (puVar14 != (undefined4 *)0x0)) {

          (**(code **)*puVar14)(1);

        }

        iVar7 = (*pcVar15)(unaff_EBX + -0x10);

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

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

        }

      }

      puVar14 = (undefined4 *)(local_4c + -0x14);

      iVar7 = (*pcVar15)(local_4c + -0x10);

      if ((iVar7 == 0) && (puVar14 != (undefined4 *)0x0)) {

        (**(code **)*puVar14)(1);

      }

      puVar14 = (undefined4 *)(local_4c + -0x14);

      iVar7 = (*pcVar15)(local_4c + -0x10);

      if ((iVar7 == 0) && (puVar14 != (undefined4 *)0x0)) {

        (**(code **)*puVar14)(1);

      }

      puVar14 = (undefined4 *)(local_4c + -0x14);

      iVar7 = (*pcVar15)(local_4c + -0x10);

      if ((iVar7 == 0) && (puVar14 != (undefined4 *)0x0)) {

        (**(code **)*puVar14)(1);

      }

      local_1c = &PTR_FUN_007ff308;

      while (piVar8 = local_18, local_18 != (int *)0x0) {

        piVar3 = (int *)local_18[1];

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

          local_14 = 0;

        }

        else {

          piVar3[2] = 0;

        }

        bVar16 = local_18 != (int *)0x0;

        local_18 = piVar3;

        if (bVar16) {

          operator_delete(piVar8);

        }

        local_10 = (undefined **)((int)local_10 + -1);

      }

      ppuStack_2c = &PTR_FUN_007ff308;

      piVar8 = local_28;

      while (piVar8 != (int *)0x0) {

        local_28 = (int *)piVar8[1];

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

          iStack_24 = 0;

        }

        else {

          local_28[2] = 0;

        }

        if (piVar8 != (int *)0x0) {

          operator_delete(piVar8);

        }

        local_20 = (undefined **)((int)local_20 + -1);

        piVar8 = local_28;

      }

      return 1;

    }

    piVar8 = (int *)*local_28;

    switch(piVar8[1]) {

    case 2:

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

      if (iVar7 != 1) {

        FUN_00402490(*piVar8,iVar7 + -1);

      }

      break;

    case 3:

      if (-1 < piVar8[6]) {

        if (uStack_50._3_1_ != '\0') {

          if (local_34 == param_4) {

            if (local_44 != (undefined *)piVar8[8]) {

              puVar14 = (undefined4 *)(local_44 + -0x14);

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

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

                (**(code **)*puVar14)(1);

              }

              puVar12 = (undefined *)piVar8[8];

              local_44 = puVar12;

              goto LAB_0067d978;

            }

          }

          else if (local_34 == param_5) {

            if (local_48 != (undefined *)piVar8[8]) {

              puVar14 = (undefined4 *)(local_48 + -0x14);

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

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

                (**(code **)*puVar14)(1);

              }

              puVar12 = (undefined *)piVar8[8];

              local_48 = puVar12;

LAB_0067d978:

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

              pcVar15 = InterlockedDecrement_exref;

            }

          }

          else if ((local_34 == param_6) && (local_4c != (undefined *)piVar8[8])) {

            puVar14 = (undefined4 *)(local_4c + -0x14);

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

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

              (**(code **)*puVar14)(1);

            }

            puVar12 = (undefined *)piVar8[8];

            local_4c = puVar12;

            goto LAB_0067d978;

          }

          local_34 = (wchar_t *)((int)local_34 + 1);

        }

        puVar14 = (undefined4 *)*local_28;

        if (*(char *)(puVar14 + 7) == '\0') {

          pwVar13 = (wchar_t *)*puVar14;

          if ((pwVar13 == (wchar_t *)0x0) || (*pwVar13 == L'\0')) {

            param_1 = (undefined **)PTR_DAT_00818340;

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

          }

          else {

            sVar5 = wcslen(pwVar13);

            FUN_004022d0(sVar5);

            wcscpy((wchar_t *)param_1,pwVar13);

          }

          ppuVar10 = param_1;

          if (param_1[-1] != (undefined *)0x1) {

            FUN_00402490(param_1,param_1[-1] + -1);

          }

        }

        else {

          piVar8 = (int *)FUN_0067c9f0(&ppuStack_30,puVar14);

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

          ppuVar10 = ppuStack_30;

          if (iVar7 != 1) {

            FUN_00402490(*piVar8,iVar7 + -1);

            ppuVar10 = ppuStack_30;

          }

        }

        iVar7 = (*pcVar15)(ppuVar10 + -4);

        if ((iVar7 == 0) && (ppuVar10 + -5 != (undefined **)0x0)) {

          (**(code **)ppuVar10[-5])(1);

        }

      }

      break;

    case 4:

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

        piVar3 = (int *)local_1c;

        do {

          if (*(int *)(*piVar3 + 0x18) == piVar8[6]) {

            piVar8 = (int *)FUN_0067d1e0(*piVar3,piVar8);

            pcVar15 = InterlockedDecrement_exref;

            if (piVar8 != (int *)0x0) {

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

              if (iVar7 != 1) {

                FUN_00402490(*piVar8,iVar7 + -1);

                pcVar15 = InterlockedDecrement_exref;

              }

            }

            goto switchD_0067d644_caseD_5;

          }

          piVar3 = (int *)piVar3[1];

          pcVar15 = InterlockedDecrement_exref;

        } while (piVar3 != (int *)0x0);

      }

      piVar3 = (int *)local_1c;

      if (piVar8[6] != 0) {

LAB_0067da86:

        if (*(int *)(*local_28 + 0x18) == 0) {

          pcVar9 = "no default variable exists to match with this default choice block";

          do {

            pcVar6 = pcVar9;

            pcVar9 = pcVar6 + 1;

          } while (*pcVar6 != '\0');

          FUN_00401280(pcVar6 + -0x7ff360);

          pcVar9 = "no default variable exists to match with this default choice block";

          ppuVar10 = ppuStack_40;

          do {

            cVar11 = *pcVar9;

            pcVar9 = pcVar9 + 1;

            *(char *)ppuVar10 = cVar11;

            ppuVar10 = (undefined **)((int)ppuVar10 + 1);

          } while (cVar11 != '\0');

          DAT_008f87f8 = *(undefined4 *)(*local_28 + 0x24);

          DAT_008f87fc = 1;

          ppuStack_3c = ppuStack_40;

          if (DAT_008f8800 != ppuStack_40) {

            ppuVar10 = DAT_008f8800 + -5;

            iVar7 = (*pcVar15)(DAT_008f8800 + -4);

            if ((iVar7 == 0) && (ppuVar10 != (undefined **)0x0)) {

              (**(code **)*ppuVar10)(1);

            }

            DAT_008f8800 = ppuStack_40;

            InterlockedIncrement((LONG *)(ppuStack_40 + -4));

            ppuStack_3c = ppuStack_40;

          }

        }

        else {

          pcVar9 = "no variable has the same ID as this choice block";

          do {

            pcVar6 = pcVar9;

            pcVar9 = pcVar6 + 1;

          } while (*pcVar6 != '\0');

          FUN_00401280(pcVar6 + -0x7ff32c);

          pcVar9 = "no variable has the same ID as this choice block";

          ppuVar10 = ppuStack_3c;

          do {

            cVar11 = *pcVar9;

            pcVar9 = pcVar9 + 1;

            *(char *)ppuVar10 = cVar11;

            ppuVar10 = (undefined **)((int)ppuVar10 + 1);

          } while (cVar11 != '\0');

          DAT_008f87f8 = *(undefined4 *)(*local_28 + 0x24);

          DAT_008f87fc = 1;

          if (DAT_008f8800 != ppuStack_3c) {

            ppuVar10 = DAT_008f8800 + -5;

            iVar7 = (*pcVar15)(DAT_008f8800 + -4);

            if ((iVar7 == 0) && (ppuVar10 != (undefined **)0x0)) {

              (**(code **)*ppuVar10)(1);

            }

            DAT_008f8800 = ppuStack_3c;

            InterlockedIncrement((LONG *)(ppuStack_3c + -4));

          }

        }

        iVar7 = (*pcVar15)(ppuStack_3c + -4);

        if ((iVar7 == 0) && (ppuStack_3c + -5 != (undefined **)0x0)) {

          (**(code **)ppuStack_3c[-5])(1);

        }

        iVar7 = (*pcVar15)(uVar1 - 0x10);

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

          (*(code *)**(undefined4 **)(uVar1 - 0x14))(1);

        }

        iVar7 = (*pcVar15)(uVar1 - 0x10);

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

          (*(code *)**(undefined4 **)(uVar1 - 0x14))(1);

        }

        iVar7 = (*pcVar15)(uVar1 - 0x10);

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

          (*(code *)**(undefined4 **)(uVar1 - 0x14))(1);

        }

        local_20 = &PTR_FUN_007ff308;

        while (ppuVar10 = local_1c, local_1c != (undefined **)0x0) {

          piVar8 = (int *)local_1c[1];

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

            local_18 = (int *)0x0;

          }

          else {

            piVar8[2] = 0;

          }

          bVar16 = local_1c != (undefined **)0x0;

          local_1c = (undefined **)piVar8;

          if (bVar16) {

            operator_delete(ppuVar10);

          }

          local_14 = local_14 + -1;

        }

        ppuStack_30 = &PTR_FUN_007ff308;

        ppuVar10 = ppuStack_2c;

        while (ppuVar10 != (void *)0x0) {

          ppuStack_2c = *(undefined ***)((int)ppuVar10 + 4);

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

            local_28 = (int *)0x0;

          }

          else {

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

          }

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

            operator_delete(ppuVar10);

          }

          iStack_24 = iStack_24 + -1;

          ppuVar10 = ppuStack_2c;

        }

        return 0;

      }

      while( true ) {

        if (piVar3 == (int *)0x0) goto LAB_0067da86;

        if (*(int *)(*piVar3 + 0x18) == -1) break;

        piVar3 = (int *)piVar3[1];

      }

      piVar8 = (int *)FUN_0067d1e0(*piVar3,piVar8);

      if (piVar8 != (int *)0x0) {

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

        if (iVar7 != 1) {

          FUN_00402490(*piVar8,iVar7 + -1);

        }

      }

      break;

    case 5:

      break;

    default:

      pcVar9 = "unknown node type";

      do {

        pcVar6 = pcVar9;

        pcVar9 = pcVar6 + 1;

      } while (*pcVar6 != '\0');

      FUN_00401280(pcVar6 + -0x7ff318);

      pcVar9 = "unknown node type";

      ppuVar10 = ppuStack_38;

      do {

        cVar11 = *pcVar9;

        pcVar9 = pcVar9 + 1;

        *(char *)ppuVar10 = cVar11;

        ppuVar10 = (undefined **)((int)ppuVar10 + 1);

      } while (cVar11 != '\0');

      DAT_008f87f8 = *(undefined4 *)(*local_28 + 0x24);

      DAT_008f87fc = 4;

      if (DAT_008f8800 != ppuStack_38) {

        ppuVar10 = DAT_008f8800 + -5;

        iVar7 = (*pcVar15)(DAT_008f8800 + -4);

        if ((iVar7 == 0) && (ppuVar10 != (undefined **)0x0)) {

          (**(code **)*ppuVar10)(1);

        }

        DAT_008f8800 = ppuStack_38;

        InterlockedIncrement((LONG *)(ppuStack_38 + -4));

      }

      iVar7 = (*pcVar15)(ppuStack_38 + -4);

      if ((iVar7 == 0) && (ppuStack_38 + -5 != (undefined **)0x0)) {

        (**(code **)ppuStack_38[-5])(1);

      }

      iVar7 = (*pcVar15)(uVar1 - 0x10);

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

        (*(code *)**(undefined4 **)(uVar1 - 0x14))(1);

      }

      iVar7 = (*pcVar15)(uVar1 - 0x10);

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

        (*(code *)**(undefined4 **)(uVar1 - 0x14))(1);

      }

      iVar7 = (*pcVar15)(uVar1 - 0x10);

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

        (*(code *)**(undefined4 **)(uVar1 - 0x14))(1);

      }

      local_20 = &PTR_FUN_007ff308;

      while (ppuVar10 = local_1c, local_1c != (undefined **)0x0) {

        piVar8 = (int *)local_1c[1];

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

          local_18 = (int *)0x0;

        }

        else {

          piVar8[2] = 0;

        }

        bVar16 = local_1c != (undefined **)0x0;

        local_1c = (undefined **)piVar8;

        if (bVar16) {

          operator_delete(ppuVar10);

        }

        local_14 = local_14 + -1;

      }

      ppuStack_30 = &PTR_FUN_007ff308;

      ppuVar10 = ppuStack_2c;

      while (ppuVar10 != (void *)0x0) {

        ppuStack_2c = *(undefined ***)((int)ppuVar10 + 4);

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

          local_28 = (int *)0x0;

        }

        else {

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

        }

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

          operator_delete(ppuVar10);

        }

        iStack_24 = iStack_24 + -1;

        ppuVar10 = ppuStack_2c;

      }

      return 0;

    }

switchD_0067d644_caseD_5:

    local_28 = (int *)local_28[1];

  } while( true );

}





// --- FUN_0067e150 at 0x0067E150 (size: 1338) ---


bool FUN_0067e150(undefined4 param_1,undefined4 param_2,int *param_3,undefined4 param_4,

                 undefined4 param_5,byte param_6,undefined4 *param_7)



{

  wchar_t *pwVar1;

  bool bVar2;

  undefined4 uVar3;

  undefined4 *puVar4;

  char cVar5;

  size_t sVar6;

  LONG LVar7;

  int *piVar8;

  int iVar9;

  undefined4 uVar10;

  code *pcVar11;

  int *piVar12;

  int iVar13;

  uint local_2c;

  uint local_28;

  uint local_24;

  wchar_t *local_20;

  wchar_t *pwStack_1c;

  wchar_t *pwStack_18;

  wchar_t *pwStack_14;

  uint local_10;

  int iStack_c;

  uint uStack_8;

  undefined4 uStack_4;

  

  DAT_008f87f8 = 0xffffffff;

  DAT_008f87fc = 0;

  FUN_00405000(&DAT_007938af);

  piVar12 = param_3;

  local_24 = 0xffffffff;

  local_10 = 0xffffffff;

  local_28 = 0xffffffff;

  local_2c = 0;

  if (param_3[2] != 0) {

    do {

      sVar6 = wcslen(L"PRE");

      FUN_004022d0(sVar6);

      wcscpy(local_20,L"PRE");

      iVar13 = local_2c * 4;

      pwVar1 = *(wchar_t **)(*piVar12 + iVar13);

      if (*(int *)(pwVar1 + -2) == *(int *)(local_20 + -2)) {

        if (((*(int *)(pwVar1 + -4) == *(int *)(local_20 + -4)) || (*(int *)(pwVar1 + -4) == -1)) ||

           (*(int *)(local_20 + -4) == -1)) {

          iVar9 = wcscmp(pwVar1,local_20);

          cVar5 = '\x01' - (iVar9 != 0);

        }

        else {

          cVar5 = '\0';

        }

      }

      else {

        cVar5 = '\0';

      }

      LVar7 = InterlockedDecrement((LONG *)(local_20 + -8));

      if ((LVar7 == 0) && (local_20 + -10 != (wchar_t *)0x0)) {

        (*(code *)**(undefined4 **)(local_20 + -10))(1);

      }

      if (cVar5 == '\0') {

        sVar6 = wcslen(L"MID");

        FUN_004022d0(sVar6);

        wcscpy(pwStack_18,L"MID");

        pwVar1 = *(wchar_t **)(*piVar12 + iVar13);

        if (*(int *)(pwVar1 + -2) == *(int *)(pwStack_18 + -2)) {

          if (((*(int *)(pwVar1 + -4) != *(int *)(pwStack_18 + -4)) && (*(int *)(pwVar1 + -4) != -1)

              ) && (*(int *)(pwStack_18 + -4) != -1)) goto LAB_0067e2ad;

          iVar9 = wcscmp(pwVar1,pwStack_18);

          cVar5 = '\x01' - (iVar9 != 0);

          param_3 = (int *)CONCAT31(param_3._1_3_,cVar5);

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

LAB_0067e33d:

          bVar2 = true;

        }

        else {

LAB_0067e2ad:

          sVar6 = wcslen(L"NAME");

          FUN_004022d0(sVar6);

          wcscpy(pwStack_1c,L"NAME");

          pwVar1 = *(wchar_t **)(*piVar12 + iVar13);

          if (*(int *)(pwVar1 + -2) == *(int *)(pwStack_1c + -2)) {

            if (((*(int *)(pwVar1 + -4) == *(int *)(pwStack_1c + -4)) ||

                (*(int *)(pwVar1 + -4) == -1)) || (*(int *)(pwStack_1c + -4) == -1)) {

              iVar9 = wcscmp(pwVar1,pwStack_1c);

              cVar5 = '\x01' - (iVar9 != 0);

            }

            else {

              cVar5 = '\0';

            }

          }

          else {

            cVar5 = '\0';

          }

          LVar7 = InterlockedDecrement((LONG *)(pwStack_1c + -8));

          if ((LVar7 == 0) && (pwStack_1c + -10 != (wchar_t *)0x0)) {

            (*(code *)**(undefined4 **)(pwStack_1c + -10))(1);

          }

          bVar2 = false;

          if (cVar5 != '\0') goto LAB_0067e33d;

        }

        LVar7 = InterlockedDecrement((LONG *)(pwStack_18 + -8));

        if ((LVar7 == 0) && (pwStack_18 + -10 != (wchar_t *)0x0)) {

          (*(code *)**(undefined4 **)(pwStack_18 + -10))(1);

        }

        if (bVar2) {

          local_10 = local_2c;

        }

        else {

          sVar6 = wcslen(L"POST");

          FUN_004022d0(sVar6);

          wcscpy(pwStack_14,L"POST");

          pwVar1 = *(wchar_t **)(*piVar12 + iVar13);

          if (*(int *)(pwVar1 + -2) == *(int *)(pwStack_14 + -2)) {

            if (((*(int *)(pwVar1 + -4) == *(int *)(pwStack_14 + -4)) ||

                (*(int *)(pwVar1 + -4) == -1)) || (*(int *)(pwStack_14 + -4) == -1)) {

              iVar13 = wcscmp(pwVar1,pwStack_14);

              cVar5 = '\x01' - (iVar13 != 0);

            }

            else {

              cVar5 = '\0';

            }

          }

          else {

            cVar5 = '\0';

          }

          LVar7 = InterlockedDecrement((LONG *)(pwStack_14 + -8));

          if ((LVar7 == 0) && (pwStack_14 + -10 != (wchar_t *)0x0)) {

            (*(code *)**(undefined4 **)(pwStack_14 + -10))(1);

          }

          if (cVar5 != '\0') {

            local_28 = local_2c;

          }

        }

      }

      else {

        local_24 = local_2c;

      }

      local_2c = local_2c + 1;

    } while (local_2c < (uint)piVar12[2]);

    if ((local_10 != 0xffffffff) && ((local_24 != 0xffffffff || (local_28 != 0xffffffff)))) {

      iStack_c = 0;

      uStack_8 = 0;

      uStack_4 = 0;

      FUN_0042d3b0(param_2);

      pcVar11 = InterlockedDecrement_exref;

      if (local_24 != 0xffffffff) {

        piVar12 = (int *)(iStack_c + local_24 * 4);

        piVar8 = (int *)FUN_0067cdc0(&param_3,piVar12);

        pcVar11 = InterlockedDecrement_exref;

        iVar13 = *piVar12;

        if (iVar13 != *piVar8) {

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

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

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

          }

          iVar13 = *piVar8;

          *piVar12 = iVar13;

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

        }

        piVar12 = param_3 + -5;

        LVar7 = InterlockedDecrement(param_3 + -4);

        if ((LVar7 == 0) && (piVar12 != (int *)0x0)) {

          (**(code **)*piVar12)(1);

        }

      }

      if (local_28 != 0xffffffff) {

        piVar12 = (int *)(iStack_c + local_28 * 4);

        piVar8 = (int *)FUN_0067cdc0(&param_3,piVar12);

        iVar13 = *piVar12;

        if (iVar13 != *piVar8) {

          iVar9 = (*pcVar11)(iVar13 + -0x10);

          if ((iVar9 == 0) && ((undefined4 *)(iVar13 + -0x14) != (undefined4 *)0x0)) {

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

          }

          iVar13 = *piVar8;

          *piVar12 = iVar13;

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

        }

        piVar12 = param_3 + -5;

        iVar13 = (*pcVar11)(param_3 + -4);

        if ((iVar13 == 0) && (piVar12 != (int *)0x0)) {

          (**(code **)*piVar12)(1);

        }

      }

      FUN_00680020(param_1,&iStack_c);

      if (((uStack_8 & 0x80000000) == 0x80000000) && (iStack_c != 0)) {

        FUN_00407920(3);

      }

      goto LAB_0067e58a;

    }

  }

  FUN_00680020(param_1,param_2);

  pcVar11 = InterlockedDecrement_exref;

LAB_0067e58a:

  FUN_0067e9b0();

  FUN_0067efe0();

  uVar3 = param_4;

  if (DAT_008f87fc == 0) {

    uVar10 = FUN_0067e690(param_4,param_5,local_24,local_10,local_28);

    FUN_0067d3c0(uVar10);

    if ((DAT_008f87fc == 0) && ((param_6 & 1) != 0)) {

      FUN_00402730(L"keepspaces");

      iVar13 = FUN_0067d010(&param_3);

      piVar12 = param_3 + -5;

      iVar9 = (*pcVar11)(param_3 + -4);

      if ((iVar9 == 0) && (piVar12 != (int *)0x0)) {

        (**(code **)*piVar12)(1);

      }

      if (iVar13 == -1) {

        FUN_0067c9b0(uVar3);

      }

    }

  }

  puVar4 = param_7;

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

    *param_7 = DAT_008f87f8;

    param_7[1] = DAT_008f87fc;

    iVar13 = param_7[2];

    if (iVar13 != DAT_008f8800) {

      iVar9 = (*pcVar11)(iVar13 + -0x10);

      if ((iVar9 == 0) && ((undefined4 *)(iVar13 + -0x14) != (undefined4 *)0x0)) {

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

      }

      iVar13 = DAT_008f8800;

      puVar4[2] = DAT_008f8800;

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

    }

  }

  FUN_0067e9f0();

  return DAT_008f87fc == 0;

}





// --- FUN_0067e690 at 0x0067E690 (size: 6) ---


undefined4 FUN_0067e690(void)



{

  return DAT_008f881c;

}





// --- FUN_0067e6a0 at 0x0067E6A0 (size: 24) ---


undefined4 FUN_0067e6a0(void)



{

  if ((DAT_008f8818 != 0) && (*(int *)(DAT_008f8818 + 4) == 4)) {

    return 1;

  }

  return 0;

}





// --- FUN_0067e6c0 at 0x0067E6C0 (size: 68) ---


void __thiscall FUN_0067e6c0(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)FUN_005df0f5(0xc);

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

    *puVar2 = param_2;

    puVar2[1] = 0;

    puVar2[2] = 0;

    if (*(int *)(param_1 + 0xc) == 0) {

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

      *(undefined4 **)(param_1 + 0x10) = puVar2;

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

      return;

    }

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

    *(undefined4 **)(iVar1 + 4) = puVar2;

    puVar2[2] = iVar1;

    *(undefined4 **)(param_1 + 0x10) = puVar2;

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

  }

  return;

}





// --- FUN_0067e710 at 0x0067E710 (size: 142) ---


void FUN_0067e710(int param_1)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  

  iVar2 = FUN_0067f620();

  *(int *)(param_1 + 0x24) = iVar2 + -1;

  iVar2 = DAT_008f881c;

  DAT_008f8820 = param_1;

  if (DAT_008f8818 == 0) {

    piVar3 = (int *)FUN_005df0f5(0xc);

    if (piVar3 != (int *)0x0) {

      *piVar3 = param_1;

      piVar3[1] = 0;

      piVar3[2] = 0;

      if (*(int *)(iVar2 + 0xc) == 0) {

        *(int **)(iVar2 + 0xc) = piVar3;

        *(int **)(iVar2 + 0x10) = piVar3;

        *(int *)(iVar2 + 0x14) = *(int *)(iVar2 + 0x14) + 1;

        return;

      }

      iVar1 = *(int *)(iVar2 + 0x10);

      *(int **)(iVar1 + 4) = piVar3;

      piVar3[2] = iVar1;

      *(int **)(iVar2 + 0x10) = piVar3;

      *(int *)(iVar2 + 0x14) = *(int *)(iVar2 + 0x14) + 1;

    }

    return;

  }

  if (param_1 == DAT_008f8818) {

    FUN_0067e6c0(param_1);

    DAT_008f8818 = 0;

    return;

  }

  FUN_0067e6c0(param_1);

  return;

}





// --- FUN_0067e7a0 at 0x0067E7A0 (size: 72) ---


void FUN_0067e7a0(int *param_1)



{

  int iVar1;

  LONG LVar2;

  int *piVar3;

  

  iVar1 = *(int *)(DAT_008f8820 + 0x20);

  piVar3 = (int *)(DAT_008f8820 + 0x20);

  if (iVar1 != *param_1) {

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

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

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

    }

    iVar1 = *param_1;

    *piVar3 = iVar1;

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

  }

  return;

}





// --- FUN_0067e7f0 at 0x0067E7F0 (size: 116) ---


uint FUN_0067e7f0(uint param_1)



{

  int *piVar1;

  bool bVar2;

  undefined3 uVar4;

  uint uVar3;

  undefined4 *puVar5;

  

  piVar1 = *(int **)(param_1 + 0xc);

  uVar3 = param_1 & 0xffffff00;

  bVar2 = false;

  do {

    uVar4 = (undefined3)(uVar3 >> 8);

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

      return CONCAT31(uVar4,1);

    }

    if (*(int *)(*(int *)(*piVar1 + 0x20) + -4) == 1) {

      if (bVar2) {

        FUN_00401340("multiple default choices in this block");

        FUN_0067d180(*(undefined4 *)(*piVar1 + 0x24),3,&param_1);

        puVar5 = (undefined4 *)(param_1 - 0x14);

        uVar3 = InterlockedDecrement((LONG *)(param_1 - 0x10));

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

          uVar3 = (**(code **)*puVar5)(1);

        }

        return uVar3 & 0xffffff00;

      }

      uVar3 = CONCAT31(uVar4,1);

      bVar2 = true;

    }

    piVar1 = (int *)piVar1[1];

  } while( true );

}





// --- FUN_0067e870 at 0x0067E870 (size: 95) ---


void __fastcall FUN_0067e870(int param_1)



{

  undefined4 *puVar1;

  void *pvVar2;

  int iVar3;

  

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

  for (puVar1 = *(undefined4 **)(param_1 + 0xc); puVar1 != (undefined4 *)0x0;

      puVar1 = (undefined4 *)puVar1[1]) {

    pvVar2 = (void *)*puVar1;

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

      FUN_0067e950();

      operator_delete(pvVar2);

    }

  }

  while (pvVar2 = *(void **)(param_1 + 0xc), pvVar2 != (void *)0x0) {

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

    *(int *)(param_1 + 0xc) = iVar3;

    if (iVar3 == 0) {

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

    }

    else {

      *(undefined4 *)(iVar3 + 8) = 0;

    }

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

      operator_delete(pvVar2);

    }

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

  }

  return;

}





// --- FUN_0067e8d0 at 0x0067E8D0 (size: 27) ---


void FUN_0067e8d0(void)



{

  FUN_0067e7f0(DAT_008f8818);

  FUN_0067e710(DAT_008f8818);

  return;

}





// --- FUN_0067e8f0 at 0x0067E8F0 (size: 84) ---


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



{

  LONG *pLVar1;

  

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

  *param_1 = PTR_DAT_00818340;

  InterlockedIncrement(pLVar1);

  param_1[1] = param_2;

  param_1[2] = &PTR_FUN_007ff308;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  *(undefined1 *)(param_1 + 7) = 0;

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

  param_1[8] = PTR_DAT_00818340;

  InterlockedIncrement(pLVar1);

  param_1[9] = 0;

  return param_1;

}





// --- FUN_0067e950 at 0x0067E950 (size: 89) ---


void __fastcall FUN_0067e950(int *param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  FUN_0067e870();

  puVar2 = (undefined4 *)(param_1[8] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(param_1[8] + -0x10));

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

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

  }

  param_1[2] = (int)&PTR_FUN_007ff308;

  FUN_0049f850();

  puVar2 = (undefined4 *)(*param_1 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(*param_1 + -0x10));

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

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

  }

  return;

}





// --- FUN_0067e9b0 at 0x0067E9B0 (size: 59) ---


void FUN_0067e9b0(void)



{

  int iVar1;

  

  DAT_008f8820 = 0;

  DAT_008f8818 = 0;

  DAT_008f881c = 0;

  iVar1 = FUN_005df0f5(0x28);

  if (iVar1 != 0) {

    DAT_008f881c = FUN_0067e8f0(1);

    return;

  }

  DAT_008f881c = 0;

  return;

}





// --- FUN_0067e9f0 at 0x0067E9F0 (size: 77) ---


void FUN_0067e9f0(void)



{

  void *pvVar1;

  

  pvVar1 = DAT_008f881c;

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

    FUN_0067e950();

    operator_delete(pvVar1);

  }

  pvVar1 = DAT_008f8818;

  DAT_008f881c = (void *)0x0;

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

    FUN_0067e950();

    operator_delete(pvVar1);

  }

  DAT_008f8818 = (void *)0x0;

  DAT_008f8820 = 0;

  return;

}





// --- FUN_0067ea40 at 0x0067EA40 (size: 98) ---


void FUN_0067ea40(int *param_1)



{

  int iVar1;

  int *piVar2;

  LONG LVar3;

  

  iVar1 = FUN_005df0f5(0x28);

  if (iVar1 == 0) {

    piVar2 = (int *)0x0;

  }

  else {

    piVar2 = (int *)FUN_0067e8f0(2);

  }

  iVar1 = *piVar2;

  if (iVar1 != *param_1) {

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

    if ((LVar3 == 0) && ((undefined4 *)(iVar1 + -0x14) != (undefined4 *)0x0)) {

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

    }

    iVar1 = *param_1;

    *piVar2 = iVar1;

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

  }

  FUN_0067e710(piVar2);

  return;

}





// --- FUN_0067eab0 at 0x0067EAB0 (size: 1140) ---


void FUN_0067eab0(wchar_t *param_1,undefined *param_2,wchar_t *param_3)



{

  char cVar1;

  wchar_t wVar2;

  int iVar3;

  int *piVar4;

  wchar_t *pwVar5;

  undefined4 uVar6;

  LONG LVar7;

  size_t sVar8;

  int *piVar9;

  long lVar10;

  wchar_t *pwVar11;

  undefined4 *puVar12;

  wchar_t *pwVar13;

  code *pcVar14;

  wchar_t *pwStack_10;

  int local_c;

  int iStack_8;

  wchar_t *local_4;

  

  iVar3 = FUN_005df0f5(0x28);

  if (iVar3 == 0) {

    piVar4 = (int *)0x0;

  }

  else {

    piVar4 = (int *)FUN_0067e8f0(3);

  }

  pwVar13 = param_1;

  piVar4[6] = (int)param_2;

  *(undefined1 *)(piVar4 + 7) = param_3._0_1_;

  pwVar5 = (wchar_t *)FUN_0040b340(*(int *)param_1,0x5b,0x5c);

  param_3 = pwVar5;

  if (pwVar5 == (wchar_t *)0x0) {

    iVar3 = *piVar4;

    if (iVar3 != *(int *)pwVar13) {

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

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

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

      }

      iVar3 = *(int *)pwVar13;

      *piVar4 = iVar3;

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

    }

    param_3 = (wchar_t *)0x0;

    lVar10 = wcstol(*(wchar_t **)pwVar13,&param_3,10);

    if (((param_3 != (wchar_t *)0x0) && (*param_3 == L'\0')) &&

       (cVar1 = FUN_0067c7c0(lVar10), cVar1 != '\0')) {

      param_1 = (wchar_t *)0x31;

      FUN_00402490(&param_1,1);

    }

    if (*(int *)(*(int *)pwVar13 + -4) == 1) {

      param_1 = (wchar_t *)0x62;

      FUN_00402490(&param_1,1);

    }

  }

  else {

    pwVar11 = *(wchar_t **)pwVar13;

    if (pwVar11 != pwVar5) {

      do {

        param_2 = (undefined *)(uint)(ushort)*pwVar11;

        if (*pwVar11 != L'\0') {

          pwVar13 = (wchar_t *)*piVar4;

          iVar3 = *(int *)(pwVar13 + -2);

          if ((*(int *)(pwVar13 + -8) == 1) && (iVar3 + 1U <= *(uint *)(pwVar13 + -6))) {

            *(uint *)(pwVar13 + -2) = iVar3 + 1U;

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

          }

          else {

            FUN_004022d0(iVar3);

            wcscpy((wchar_t *)*piVar4,pwVar13);

            LVar7 = InterlockedDecrement((LONG *)(pwVar13 + -8));

            if ((LVar7 == 0) && (pwVar13 + -10 != (wchar_t *)0x0)) {

              (*(code *)**(undefined4 **)(pwVar13 + -10))(1);

            }

          }

          wcsncpy((wchar_t *)(*piVar4 + -2 + iVar3 * 2),(wchar_t *)&param_2,1);

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

          pwVar5 = param_3;

          pwVar13 = param_1;

        }

        pwVar11 = pwVar11 + 1;

      } while (pwVar11 != pwVar5);

    }

    iVar3 = DAT_00837750;

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

    FUN_004d68c0(0,1,iVar3);

    pwVar5 = pwVar5 + 1;

    param_3 = pwVar5;

    local_4 = (wchar_t *)FUN_0040b340(*(int *)pwVar13,0x5d,0x5c);

    if (local_4 == (wchar_t *)0x0) {

      FUN_00401340("variable-substitution string is missing \']\'");

      uVar6 = FUN_0067f620(1,&param_3);

      FUN_0067d180(uVar6);

      pwVar13 = param_3 + -10;

      LVar7 = InterlockedDecrement((LONG *)(param_3 + -8));

      if (LVar7 != 0) {

        return;

      }

      if (pwVar13 == (wchar_t *)0x0) {

        return;

      }

      (*(code *)**(undefined4 **)pwVar13)(1);

      return;

    }

    if (pwVar5 != local_4) {

      do {

        wVar2 = *pwVar5;

        if (wVar2 == L'M') {

          param_2 = PTR_DAT_00818340;

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

          FUN_0067cf50(&param_2);

          sVar8 = wcslen(L"M");

          FUN_004022d0(sVar8);

          wcscpy(param_1,L"M");

          piVar9 = (int *)FUN_004086c0(&local_c,&param_1);

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

          if (iVar3 != 1) {

            FUN_00402490(*piVar9,iVar3 + -1);

          }

          pcVar14 = InterlockedDecrement_exref;

          puVar12 = (undefined4 *)(local_c + -0x14);

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

          pwVar13 = param_1;

          if ((LVar7 == 0) && (puVar12 != (undefined4 *)0x0)) {

            (**(code **)*puVar12)(1);

            pwVar13 = param_1;

          }

LAB_0067ecf2:

          iVar3 = (*pcVar14)(pwVar13 + -8);

          if ((iVar3 == 0) && (pwVar13 + -10 != (wchar_t *)0x0)) {

            (*(code *)**(undefined4 **)(pwVar13 + -10))(1);

          }

          pwVar13 = param_1 + -10;

          iVar3 = (*pcVar14)(param_1 + -8);

          if ((iVar3 == 0) && (pwVar13 != (wchar_t *)0x0)) {

            (*(code *)**(undefined4 **)pwVar13)(1);

          }

        }

        else {

          if (wVar2 == L'F') {

            param_2 = PTR_DAT_00818340;

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

            FUN_0067cf80(&param_2);

            FUN_00402730(&DAT_007ff2dc);

            piVar9 = (int *)FUN_004086c0(&iStack_8,&pwStack_10);

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

            if (iVar3 != 1) {

              FUN_00402490(*piVar9,iVar3 + -1);

            }

            pcVar14 = InterlockedDecrement_exref;

            puVar12 = (undefined4 *)(iStack_8 + -0x14);

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

            pwVar13 = pwStack_10;

            if ((LVar7 == 0) && (puVar12 != (undefined4 *)0x0)) {

              (**(code **)*puVar12)(1);

              pwVar13 = pwStack_10;

            }

            goto LAB_0067ecf2;

          }

          if (wVar2 != L' ') {

            param_2 = (undefined *)CONCAT22((short)((uint)local_4 >> 0x10),wVar2);

            FUN_00402490(&param_2,1);

          }

        }

        pwVar5 = param_3 + 1;

        param_3 = pwVar5;

      } while (pwVar5 != local_4);

    }

    wVar2 = pwVar5[1];

    param_3 = pwVar5 + 1;

    if (wVar2 != L'\0') {

      do {

        if ((wVar2 != L' ') && (wVar2 != L'\t')) {

          FUN_00401340("there is text after the \']\' in a variable-substitution string");

          uVar6 = FUN_0067f620(1,&param_1);

          FUN_0067d180(uVar6);

          pwVar13 = param_1 + -10;

          LVar7 = InterlockedDecrement((LONG *)(param_1 + -8));

          if ((LVar7 == 0) && (pwVar13 != (wchar_t *)0x0)) {

            (*(code *)**(undefined4 **)pwVar13)(1);

          }

        }

        param_3 = param_3 + 1;

        wVar2 = *param_3;

      } while (wVar2 != L'\0');

      FUN_0067e710(piVar4);

      return;

    }

  }

  FUN_0067e710(piVar4);

  return;

}





// --- FUN_0067ef30 at 0x0067EF30 (size: 51) ---


void FUN_0067ef30(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_005df0f5(0x28);

  if (iVar1 != 0) {

    DAT_008f8818 = FUN_0067e8f0(4);

    *(undefined4 *)(DAT_008f8818 + 0x18) = param_1;

    return;

  }

  DAT_008f8818 = 0;

  uRam00000018 = param_1;

  return;

}





// --- FUN_0067ef70 at 0x0067EF70 (size: 98) ---


void FUN_0067ef70(int *param_1)



{

  int iVar1;

  int *piVar2;

  LONG LVar3;

  

  iVar1 = FUN_005df0f5(0x28);

  if (iVar1 == 0) {

    piVar2 = (int *)0x0;

  }

  else {

    piVar2 = (int *)FUN_0067e8f0(5);

  }

  iVar1 = *piVar2;

  if (iVar1 != *param_1) {

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

    if ((LVar3 == 0) && ((undefined4 *)(iVar1 + -0x14) != (undefined4 *)0x0)) {

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

    }

    iVar1 = *param_1;

    *piVar2 = iVar1;

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

  }

  FUN_0067e710(piVar2);

  return;

}





// --- FUN_0067efe0 at 0x0067EFE0 (size: 1452) ---


/* WARNING: Function: __chkstk replaced with injection: alloca_probe */

/* WARNING (jumptable): Unable to track spacebase fully for stack */

/* WARNING: Unable to track spacebase fully for stack */

/* WARNING: Type propagation algorithm not settling */



undefined4 FUN_0067efe0(void)



{

  undefined *puVar1;

  int iVar2;

  int iVar3;

  short *psVar4;

  LONG *lpAddend;

  LONG LVar5;

  long lVar6;

  undefined1 *puVar7;

  int *piVar8;

  int iVar9;

  int iVar10;

  undefined4 *puVar11;

  int iVar12;

  short *psVar13;

  int *piVar14;

  wchar_t *_Str;

  short local_4d0 [200];

  int local_340 [199];

  int local_24;

  short *local_20;

  int local_1c;

  int local_18;

  undefined4 *local_14;

  int *local_10;

  int *local_c;

  int *local_8;

  

  piVar8 = local_340;

  iVar12 = 200;

  do {

    *piVar8 = (int)PTR_DAT_00818340;

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

    piVar8 = piVar8 + 1;

    iVar12 = iVar12 + -1;

  } while (iVar12 != 0);

  local_14 = (undefined4 *)PTR_DAT_00818340;

  local_c = local_340;

  local_18 = 200;

  local_20 = local_4d0;

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

  local_10 = (int *)0x0;

  local_1c = 0;

  DAT_008f88a0 = 0;

  DAT_008f88a4 = 0xfffffffe;

  psVar4 = (short *)&stack0xfffffb2e;

  piVar8 = local_340;

  psVar13 = local_4d0;

LAB_0067f065:

  piVar14 = local_10;

  iVar10 = local_18;

  psVar4 = psVar4 + 1;

  iVar12 = local_18 + -1;

  *psVar4 = (short)local_10;

  if (psVar13 + iVar12 <= psVar4) {

    iVar12 = (int)psVar4 - (int)psVar13 >> 1;

    iVar9 = iVar12 + 1;

    local_8 = local_c;

    if (9999 < iVar10) {

      local_c = (int *)psVar13;

      FUN_0067f8c0();

      puVar11 = (undefined4 *)((int)local_14 + -0x14);

      LVar5 = InterlockedDecrement((LONG *)((int)local_14 + -0x10));

      if ((LVar5 == 0) && (puVar11 != (undefined4 *)0x0)) {

        (**(code **)*puVar11)();

      }

      piVar8 = (int *)&local_20;

      local_c = (int *)0xc8;

      do {

        piVar14 = piVar8 + 0xffffffff;

        piVar8 = piVar8 + 0xffffffff;

        puVar11 = (undefined4 *)(*piVar14 + -0x14);

        LVar5 = InterlockedDecrement((LONG *)(*piVar14 + -0x10));

        if ((LVar5 == 0) && (puVar11 != (undefined4 *)0x0)) {

          (**(code **)*puVar11)();

        }

        local_c = (int *)((int)local_c + -1);

      } while (local_c != (int *)0x0);

      return 2;

    }

    local_18 = iVar10 * 2;

    if (10000 < local_18) {

      local_18 = 10000;

    }

    iVar3 = local_18;

    iVar10 = -6 - local_18;

    psVar4 = local_4d0 + (-6 - local_18);

    iVar2 = -6 - local_18;

    local_c = (int *)(iVar9 * 2);

    local_20 = local_4d0 + (-6 - local_18);

    if (0 < (int)local_c) {

      do {

        *(undefined1 *)psVar4 =

             *(undefined1 *)((int)psVar4 + ((int)psVar13 - (int)(local_4d0 + iVar10)));

        psVar4 = (short *)((int)psVar4 + 1);

        local_c = (int *)((int)local_c + -1);

      } while (local_c != (int *)0x0);

    }

    (local_4d0 + (-8 - iVar3))[0] = -0xf10;

    (local_4d0 + (-8 - iVar3))[1] = 0x67;

    puVar7 = &stack0xfffffb24;

    piVar8 = (int *)(iVar9 * 4);

    local_c = (int *)&stack0xfffffb24;

    if (0 < (int)piVar8) {

      iVar10 = (int)local_8 - (int)&stack0xfffffb24;

      local_8 = piVar8;

      do {

        *puVar7 = puVar7[iVar10];

        puVar7 = puVar7 + 1;

        local_8 = (int *)((int)local_8 + -1);

      } while (local_8 != (int *)0x0);

    }

    psVar4 = local_4d0 + ((iVar12 + -6) - iVar3);

    piVar8 = (int *)((int)(piVar8 + -1) + (int)local_c);

    piVar14 = local_10;

    psVar13 = local_4d0 + iVar2;

    if (local_4d0 + ((local_18 + -7) - iVar3) <= psVar4) goto LAB_0067f535;

  }

  local_8 = (int *)(int)*(short *)(&DAT_007ff6b8 + (int)piVar14 * 2);

  if (local_8 != (int *)0xffff8000) {

    if (DAT_008f88a4 == 0xfffffffe) {

      DAT_008f88a4 = thunk_FUN_0067fac0();

      piVar14 = local_10;

    }

    if ((int)DAT_008f88a4 < 1) {

      iVar12 = 0;

      DAT_008f88a4 = 0;

    }

    else if (DAT_008f88a4 < 0x106) {

      iVar12 = (int)(char)(&DAT_007ff4f0)[DAT_008f88a4];

    }

    else {

      iVar12 = 0x18;

    }

    iVar10 = (int)local_8 + iVar12;

    if (((iVar10 < 0) || (0x16 < iVar10)) || (*(short *)(&DAT_007ff744 + iVar10 * 2) != iVar12))

    goto LAB_0067f287;

    local_8 = (int *)(int)*(short *)(&DAT_007ff714 + iVar10 * 2);

    if ((int)local_8 < 0) {

      if (local_8 == (int *)0xffff8000) goto LAB_0067f29a;

      local_8 = (int *)-(int)local_8;

      goto LAB_0067f1d1;

    }

    if (local_8 == (int *)0x0) goto LAB_0067f29a;

    if (local_8 == (int *)0x21) {

LAB_0067f506:

      FUN_004011b0();

      FUN_00401030(local_340,4,200);

      return 0;

    }

    if (DAT_008f88a4 != 0) {

      DAT_008f88a4 = 0xfffffffe;

    }

    piVar8 = piVar8 + 1;

    FUN_00402070();

    if (local_1c != 0) {

      local_1c = local_1c + -1;

    }

    local_10 = local_8;

    goto LAB_0067f065;

  }

LAB_0067f287:

  local_8 = (int *)(int)*(short *)(&DAT_007ff658 + (int)piVar14 * 2);

  if ((int *)(int)*(short *)(&DAT_007ff658 + (int)piVar14 * 2) == (int *)0x0) {

LAB_0067f29a:

    if (local_1c == 0) {

      DAT_008f88a0 = DAT_008f88a0 + 1;

      FUN_0067f8c0();

      piVar14 = local_10;

    }

    else if (local_1c == 3) {

      if (DAT_008f88a4 == 0) {

LAB_0067f535:

        puVar11 = (undefined4 *)((int)local_14 + -0x14);

        LVar5 = InterlockedDecrement((LONG *)((int)local_14 + -0x10));

        if ((LVar5 == 0) && (puVar11 != (undefined4 *)0x0)) {

          (**(code **)*puVar11)();

        }

        piVar8 = (int *)&local_20;

        local_c = (int *)0xc8;

        do {

          piVar14 = piVar8 + 0xffffffff;

          piVar8 = piVar8 + 0xffffffff;

          puVar11 = (undefined4 *)(*piVar14 + -0x14);

          LVar5 = InterlockedDecrement((LONG *)(*piVar14 + -0x10));

          if ((LVar5 == 0) && (puVar11 != (undefined4 *)0x0)) {

            (**(code **)*puVar11)();

          }

          local_c = (int *)((int)local_c + -1);

        } while (local_c != (int *)0x0);

        return 1;

      }

      DAT_008f88a4 = 0xfffffffe;

    }

    local_1c = 3;

    do {

      if (((*(short *)(&DAT_007ff6b8 + (int)piVar14 * 2) != -0x8000) &&

          (iVar12 = *(short *)(&DAT_007ff6b8 + (int)piVar14 * 2) + 1, -1 < iVar12)) &&

         ((iVar12 < 0x17 && (*(short *)(&DAT_007ff744 + iVar12 * 2) == 1)))) {

        piVar14 = (int *)(int)*(short *)(&DAT_007ff714 + iVar12 * 2);

        if ((int)piVar14 < 0) {

          if (piVar14 != (int *)0xffff8000) goto code_r0x0067f326;

        }

        else if (piVar14 != (int *)0x0) {

          if (piVar14 == (int *)0x21) goto LAB_0067f506;

          piVar8 = piVar8 + 1;

          FUN_00402070();

          local_10 = piVar14;

          psVar13 = local_20;

          goto LAB_0067f065;

        }

      }

      if (psVar4 == local_20) goto LAB_0067f535;

      piVar14 = (int *)(int)psVar4[-1];

      piVar8 = piVar8 + -1;

      psVar4 = psVar4 + -1;

    } while( true );

  }

LAB_0067f1d1:

  iVar12 = (int)*(short *)(&DAT_007ff628 + (int)local_8 * 2);

  local_10 = (int *)iVar12;

  if ((0 < iVar12) && (local_14 != (undefined4 *)piVar8[1 - iVar12])) {

    lpAddend = (LONG *)((int)local_14 + -0x10);

    local_14 = (undefined4 *)((int)local_14 + -0x14);

    LVar5 = InterlockedDecrement(lpAddend);

    if ((LVar5 == 0) && (local_14 != (undefined4 *)0x0)) {

      (**(code **)*local_14)();

    }

    local_14 = (undefined4 *)piVar8[1 - iVar12];

    InterlockedIncrement((LONG *)((int)local_14 + -0x10));

  }

  switch(local_8) {

  case (int *)0x9:

    _Str = (wchar_t *)piVar8[-1];

    goto LAB_0067f382;

  case (int *)0xa:

    _Str = (wchar_t *)piVar8[-2];

LAB_0067f382:

    lVar6 = wcstol(_Str,(wchar_t **)0x0,10);

    FUN_0067eab0(piVar8,lVar6);

    break;

  case (int *)0xb:

    FUN_0067eab0(piVar8,0);

    break;

  case (int *)0xc:

    FUN_0067eab0(piVar8,0);

    break;

  case (int *)0xd:

    FUN_0067ef30();

    break;

  case (int *)0xe:

  case (int *)0x10:

    FUN_0067e8d0();

    break;

  case (int *)0xf:

    lVar6 = wcstol((wchar_t *)piVar8[-1],(wchar_t **)0x0,10);

    FUN_0067ef30(lVar6);

    break;

  case (int *)0x11:

    FUN_0067ef70();

    break;

  case (int *)0x16:

    FUN_0067ea40();

    break;

  case (int *)0x17:

    FUN_0067e7a0();

  }

  piVar8 = piVar8 + (1 - (int)local_10);

  puVar1 = (undefined *)*piVar8;

  psVar4 = psVar4 + -(int)local_10;

  if ((undefined4 *)puVar1 != local_14) {

    LVar5 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

    if ((LVar5 == 0) && ((undefined4 *)(puVar1 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(puVar1 + -0x14))();

    }

    puVar11 = local_14;

    *piVar8 = (int)local_14;

    InterlockedIncrement((LONG *)((int)puVar11 + -0x10));

  }

  iVar12 = (int)*(short *)(&DAT_007ff6e4 + *(short *)(&DAT_007ff5f8 + (int)local_8 * 2) * 2) +

           (int)*psVar4;

  psVar13 = local_20;

  if (((iVar12 < 0) || (0x16 < iVar12)) || (*(short *)(&DAT_007ff744 + iVar12 * 2) != *psVar4)) {

    local_10 = (int *)(int)*(short *)(&DAT_007ff684 +

                                     *(short *)(&DAT_007ff5f8 + (int)local_8 * 2) * 2);

  }

  else {

    local_10 = (int *)(int)*(short *)(&DAT_007ff714 + iVar12 * 2);

  }

  goto LAB_0067f065;

code_r0x0067f326:

  local_8 = (int *)-(int)piVar14;

  goto LAB_0067f1d1;

}





// --- FUN_0067f5e0 at 0x0067F5E0 (size: 53) ---


undefined4 FUN_0067f5e0(void)



{

  char cVar1;

  short unaff_SI;

  

  cVar1 = FUN_0067e6a0();

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

    if (cVar1 == '\0') {

      return 0;

    }

  }

  else if (unaff_SI == 0x7b) {

    if (cVar1 != '\0') {

      return 0;

    }

  }

  else {

    if (unaff_SI != 0x5e) {

      return 0;

    }

    if (cVar1 != '\0') {

      return 0;

    }

  }

  return 1;

}





// --- FUN_0067f620 at 0x0067F620 (size: 6) ---


undefined4 FUN_0067f620(void)



{

  return DAT_008f8928;

}





// --- FUN_0067f630 at 0x0067F630 (size: 652) ---


undefined4 FUN_0067f630(long *param_1)



{

  uint uVar1;

  char cVar2;

  uint in_EAX;

  int iVar3;

  wint_t *pwVar4;

  int iVar5;

  long lVar6;

  short *psVar7;

  wchar_t *pwVar8;

  uint uVar9;

  uint *unaff_EDI;

  wchar_t local_800;

  wchar_t local_7fe [1023];

  

  cVar2 = FUN_0067e6a0();

  if (cVar2 != '\0') {

    return 0;

  }

  *unaff_EDI = in_EAX;

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

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

    psVar7 = (short *)(DAT_008f8990 + in_EAX * 2);

  }

  if (*psVar7 == 0x23) {

    *unaff_EDI = in_EAX + 1;

    while( true ) {

      uVar9 = *unaff_EDI;

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

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

        psVar7 = (short *)(DAT_008f8990 + uVar9 * 2);

      }

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

      *unaff_EDI = uVar9 + 1;

    }

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

    uVar1 = *unaff_EDI;

    psVar7 = (short *)(DAT_008f8990 + -2 + uVar9 * 2);

    if (uVar1 < uVar9) {

      psVar7 = (short *)(DAT_008f8990 + uVar1 * 2);

    }

    if (*psVar7 != 0x2d) {

      if (uVar1 < uVar9) {

        pwVar4 = (wint_t *)(DAT_008f8990 + uVar1 * 2);

      }

      else {

        pwVar4 = (wint_t *)(DAT_008f8990 + -2 + uVar9 * 2);

      }

      iVar3 = iswdigit(*pwVar4);

      if (iVar3 == 0) {

        return 0;

      }

    }

    uVar9 = *unaff_EDI;

    pwVar8 = &local_800;

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

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

      psVar7 = (short *)(DAT_008f8990 + uVar9 * 2);

    }

    if (*psVar7 == 0x2d) {

      *unaff_EDI = uVar9 + 1;

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

        pwVar8 = (wchar_t *)(DAT_008f8990 + uVar9 * 2);

      }

      else {

        pwVar8 = (wchar_t *)(DAT_008f8990 + -2 + *(uint *)(DAT_008f8990 + -4) * 2);

      }

      local_800 = *pwVar8;

      pwVar8 = local_7fe;

    }

    while( true ) {

      uVar9 = *unaff_EDI;

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

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

        psVar7 = (short *)(DAT_008f8990 + uVar9 * 2);

      }

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

      *unaff_EDI = uVar9 + 1;

    }

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

      pwVar4 = (wint_t *)(DAT_008f8990 + *unaff_EDI * 2);

    }

    else {

      pwVar4 = (wint_t *)(DAT_008f8990 + -2 + *(uint *)(DAT_008f8990 + -4) * 2);

    }

    iVar3 = iswdigit(*pwVar4);

    if (iVar3 != 0) {

      iVar3 = (int)pwVar8 - (int)&local_800;

      while( true ) {

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

          pwVar4 = (wint_t *)(DAT_008f8990 + *unaff_EDI * 2);

        }

        else {

          pwVar4 = (wint_t *)(DAT_008f8990 + -2 + *(uint *)(DAT_008f8990 + -4) * 2);

        }

        iVar5 = iswdigit(*pwVar4);

        if ((iVar5 == 0) || (0x7ff < iVar3)) break;

        uVar9 = *unaff_EDI;

        *unaff_EDI = uVar9 + 1;

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

          *pwVar8 = *(wchar_t *)(DAT_008f8990 + uVar9 * 2);

          pwVar8 = pwVar8 + 1;

          iVar3 = iVar3 + 2;

        }

        else {

          *pwVar8 = *(wchar_t *)(DAT_008f8990 + -2 + *(uint *)(DAT_008f8990 + -4) * 2);

          pwVar8 = pwVar8 + 1;

          iVar3 = iVar3 + 2;

        }

      }

      *pwVar8 = L'\0';

      lVar6 = wcstol(&local_800,(wchar_t **)0x0,10);

      *param_1 = lVar6;

      while( true ) {

        uVar9 = *unaff_EDI;

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

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

          psVar7 = (short *)(DAT_008f8990 + uVar9 * 2);

        }

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

        *unaff_EDI = uVar9 + 1;

      }

      uVar9 = *unaff_EDI;

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

        psVar7 = (short *)(DAT_008f8990 + uVar9 * 2);

      }

      else {

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

      }

      if (*psVar7 == 0x3a) {

        do {

          uVar9 = uVar9 + 1;

          *unaff_EDI = uVar9;

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

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

            psVar7 = (short *)(DAT_008f8990 + uVar9 * 2);

          }

        } while ((*psVar7 == 0x20) || (*psVar7 == 9));

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

          psVar7 = (short *)(DAT_008f8990 + uVar9 * 2);

        }

        else {

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

        }

        if (((*psVar7 == 1) || (psVar7 = (short *)FUN_004075c0(uVar9), *psVar7 == 0x5e)) ||

           (psVar7 = (short *)FUN_004075c0(uVar9), *psVar7 == 0x7b)) {

          return 1;

        }

      }

    }

  }

  return 0;

}





// --- FUN_0067f8c0 at 0x0067F8C0 (size: 105) ---


void FUN_0067f8c0(undefined4 param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  undefined4 local_c;

  undefined4 local_8;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818344;

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

  local_c = DAT_008f8928;

  local_8 = 1;

  FUN_00405000(param_1);

  FUN_0067d120(&local_c);

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

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

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

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

  }

  return;

}





// --- FUN_0067f930 at 0x0067F930 (size: 390) ---


uint FUN_0067f930(uint param_1)



{

  int iVar1;

  undefined *puVar2;

  uint uVar3;

  wchar_t *_Source;

  uint uVar4;

  LONG LVar5;

  short *psVar6;

  short *psVar7;

  ushort *puVar8;

  LONG *lpAddend;

  uint *unaff_EBX;

  int *unaff_EDI;

  uint uStack_8;

  uint local_4;

  

  uVar4 = FUN_0067e6a0();

  if ((char)uVar4 == '\0') {

    return uVar4;

  }

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

  *unaff_EBX = param_1;

  puVar2 = (undefined *)*unaff_EDI;

  uVar4 = iVar1 - 1;

  local_4 = uVar4;

  if (puVar2 != PTR_DAT_00818340) {

    LVar5 = InterlockedDecrement((LONG *)(puVar2 + -0x10));

    if ((LVar5 == 0) && ((undefined4 *)(puVar2 + -0x14) != (undefined4 *)0x0)) {

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

    }

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

    *unaff_EDI = (int)PTR_DAT_00818340;

    InterlockedIncrement(lpAddend);

  }

  psVar6 = (short *)*unaff_EBX;

  psVar7 = (short *)(DAT_008f8990 + -2 + (int)*(short **)(DAT_008f8990 + -4) * 2);

  if (psVar6 < *(short **)(DAT_008f8990 + -4)) {

    psVar7 = (short *)(DAT_008f8990 + (int)psVar6 * 2);

  }

  if (*psVar7 == 0x5b) {

    *unaff_EBX = (int)psVar6 + 1;

    while( true ) {

      uVar3 = *unaff_EBX;

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

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

        psVar7 = (short *)(DAT_008f8990 + uVar3 * 2);

      }

      if ((*psVar7 == 0x5d) || (uVar4 <= uVar3)) break;

      *unaff_EBX = uVar3 + 1;

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

        puVar8 = (ushort *)(DAT_008f8990 + uVar3 * 2);

      }

      else {

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

      }

      uStack_8 = (uint)*puVar8;

      if (*puVar8 != 0) {

        _Source = (wchar_t *)*unaff_EDI;

        iVar1 = *(int *)(_Source + -2);

        if ((*(int *)(_Source + -8) == 1) && (iVar1 + 1U <= *(uint *)(_Source + -6))) {

          *(uint *)(_Source + -2) = iVar1 + 1U;

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

        }

        else {

          FUN_004022d0(iVar1);

          wcscpy((wchar_t *)*unaff_EDI,_Source);

          LVar5 = InterlockedDecrement((LONG *)(_Source + -8));

          if ((LVar5 == 0) && (_Source + -10 != (wchar_t *)0x0)) {

            (*(code *)**(undefined4 **)(_Source + -10))(1);

          }

        }

        wcsncpy((wchar_t *)(*unaff_EDI + -2 + iVar1 * 2),(wchar_t *)&uStack_8,1);

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

        uVar4 = local_4;

      }

    }

    uVar4 = *unaff_EBX;

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

      psVar6 = (short *)(DAT_008f8990 + uVar4 * 2);

    }

    else {

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

    }

    if (*psVar6 == 0x5d) {

      *unaff_EBX = uVar4 + 1;

      return CONCAT31((int3)((uint)psVar6 >> 8),1);

    }

  }

  return (uint)psVar6 & 0xffffff00;

}





// --- FUN_0067fac0 at 0x0067FAC0 (size: 1351) ---


uint 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 local_c;

  uint local_8;

  uint local_4;

  

  puVar5 = PTR_DAT_00818340;

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

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

  uVar15 = uVar4 - 1;

  local_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(&local_8);

    if (cVar6 != '\0') {

      DAT_008f8928 = local_c;

      FUN_0040b220();

      FUN_0047b520(local_8);

      FUN_004011b0();

      return 0x103;

    }

    cVar6 = FUN_0067f930(DAT_008f8928);

    if (cVar6 != '\0') {

      DAT_008f8928 = local_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;

            }

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

            FUN_00402490(&local_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(&local_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;

            local_8 = 0x5c;

            FUN_00402490(&local_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);

        }

        local_8 = (uint)*puVar14;

        DAT_008f8928 = DAT_008f8928 + 1;

        FUN_00402490(&local_8,1);

        if (local_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;

}





