clean up the following decompiled C code: 
/* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

void IppSendError(undefined param_1,undefined1 *param_2,longlong param_3,undefined param_4,
                 undefined param_5,undefined4 param_6,char param_7)

{
  longlong lVar1;
  code *pcVar2;
  undefined auVar3 [16];
  longlong lVar4;
  undefined8 uVar5;
  char cVar6;
  undefined uVar7;
  undefined4 uVar8;
  uint uVar9;
  int iVar10;
  undefined4 uVar11;
  longlong *plVar12;
  char *pcVar13;
  int *piVar14;
  int **ppiVar15;
  longlong lVar16;
  ulonglong uVar17;
  int **ppiVar18;
  uint uVar19;
  int iVar20;
  undefined1 *puVar21;
  int **ppiVar22;
  longlong unaff_GS_OFFSET;
  bool bVar23;
  undefined auStack_208 [32];
  undefined8 local_1e8;
  undefined8 local_1e0;
  undefined8 local_1d8;
  char *local_1d0;
  uint *local_1c8;
  undefined8 local_1c0;
  undefined4 local_1b8;
  char local_1a8;
  undefined local_1a7;
  undefined local_1a6;
  undefined1 *local_1a0;
  undefined4 local_198;
  uint local_194;
  uint local_190;
  undefined4 local_18c;
  int **local_188;
  longlong local_180;
  uint local_178 [2];
  int **local_170;
  longlong local_168;
  int *local_160;
  longlong local_158;
  int *local_150;
  int *local_148 [2];
  longlong local_138;
  undefined local_128 [32];
  longlong *local_108;
  int *local_100;
  int *local_b8;
  undefined8 local_98;
  undefined local_60;
  undefined local_5f;
  undefined4 local_5c;
  undefined8 local_58;
  ulonglong local_50;
  
  local_50 = __security_cookie ^ (ulonglong)auStack_208;
  local_1a7 = param_1;
  local_1a6 = param_4;
  local_1a0 = param_2;
  local_180 = param_3;
  memset(local_128,0,0xd0);
  ppiVar15 = (int **)0x0;
  lVar16 = *(longlong *)(param_3 + 8);
  local_5f = param_5;
  local_5c = param_6;
  local_160 = (int *)0x0;
  lVar1 = *(longlong *)(lVar16 + 8);
  local_170 = (int **)0x0;
  local_158 = 0;
  local_198 = 0;
  local_190 = 0;
  local_18c = 0;
  local_168 = lVar16;
  local_138 = lVar1;
  local_60 = param_4;
  if ((*(byte *)(param_3 + 0xb0) & 1) == 0) {
    bVar23 = false;
    local_194 = 0;
    local_58 = 0;
    local_1a8 = '\0';
    ppiVar18 = ppiVar15;
    if ((*(byte *)(param_3 + 0xb1) & 0x40) == 0) {
      ppiVar18 = (int **)(ulonglong)*(uint *)(param_3 + 0x30);
    }
    uVar9 = (uint)ppiVar18;
    NetioRetreatNetBufferList(lVar16,ppiVar18,0);
    local_1b8 = 0;
    local_1c0 = 0;
    local_1c8 = &local_194;
    local_1d0 = &local_1a8;
    local_1d8 = (int **)0x0;
    local_1e0 = (int **)0x0;
    local_1e8 = (int **)0x0;
    iVar10 = (**(code **)(local_1a0 + 0x100))(lVar1,1,0,0);
    if ((-1 < iVar10) &&
       (((local_1a8 == '\x01' || (local_1a8 == ':')) && (7 < *(uint *)(lVar1 + 0x18))))) {
      local_1e8 = (int **)((ulonglong)local_1e8 & 0xffffffff00000000);
      pcVar13 = (char *)NdisGetDataBuffer(lVar1,8,&local_58);
      if (pcVar13 != (char *)0x0) {
        cVar6 = *pcVar13;
        if (local_1a8 == '\x01') {
          if (((byte)(cVar6 - 3U) < 3) || ((byte)(cVar6 - 0xbU) < 2)) {
            bVar23 = true;
          }
        }
        else {
          bVar23 = -1 < cVar6;
        }
      }
    }
    if (local_194 < uVar9 || local_194 == uVar9) {
      if (local_194 < uVar9) {
        NetioAdvanceNetBufferList(*(undefined8 *)(param_3 + 8),uVar9 - local_194);
      }
    }
    else {
      NetioRetreatNetBufferList(*(undefined8 *)(param_3 + 8),local_194 - uVar9,0);
    }
    if (bVar23) goto LAB_1c00d71aa;
    if ((param_7 != '\0') ||
       ((1 < *(int *)(param_3 + 0xf8) - 3U && ((*(uint *)(lVar16 + 0x88) & 0x40000000) == 0)))) {
      local_98 = *(undefined8 *)(param_3 + 0x100);
      ppiVar18 = *(int ***)(param_3 + 0xd0);
      ppiVar22 = ppiVar15;
      if ((ppiVar18 != (int **)0x0) &&
         ((ppiVar22 = (int **)0x0, *(int *)ppiVar18 == 0x616c7049 &&
          (ppiVar22 = ppiVar15, local_170 = ppiVar15, *(int *)(ppiVar18 + 3) == 1)))) {
        ppiVar22 = ppiVar18;
        local_170 = ppiVar18;
      }
      ppiVar15 = *(int ***)(*(longlong *)(param_3 + 0xd8) + 8);
      local_188 = ppiVar15;
      cVar6 = IppRateLimitIcmpOnInterface();
      puVar21 = local_1a0;
      if (cVar6 != '\0') {
        uVar11 = 0xb;
LAB_1c00d7089:
        iVar10 = -0x3ffffde5;
        *(undefined4 *)(lVar16 + 0x8c) = 0xc000021b;
        goto LAB_1c00752ed;
      }
      iVar10 = (**(code **)(local_1a0 + 0xa8))();
      if (iVar10 == 0) {
        uVar11 = 0xd;
        goto LAB_1c00d7089;
      }
      if ((ppiVar22 != (int **)0x0) && (ppiVar15 != (int **)ppiVar22[1])) {
        local_170 = (int **)0x0;
      }
      uVar8 = IppGetScopeId(ppiVar15,local_98);
      uVar5 = local_98;
      piVar14 = *ppiVar15;
      uVar19 = (uint)*(ushort *)(*(longlong *)(*(longlong *)(piVar14 + 10) + 0x10) + 6);
      uVar9 = RtlCompute37Hash(g_37HashSeed,local_98,uVar19);
      uVar7 = KfRaiseIrql(2);
      uVar11 = *(undefined4 *)(unaff_GS_OFFSET + 0x1a4);
      RtlAcquireScalableReadLockAtDpcLevel(piVar14 + 0xc0,uVar11);
      ppiVar18 = local_170;
      local_1d8 = (int **)CONCAT44(local_1d8._4_4_,uVar19);
      local_1e0 = local_170;
      local_1e8 = local_188;
      plVar12 = (longlong *)IppFindPathUnderLock(piVar14,uVar9 | 0x80000000,uVar5,uVar8);
      RtlReleaseScalableReadLock(piVar14 + 0xc0,uVar11,uVar7);
      ppiVar15 = local_188;
      local_108 = plVar12;
      if (plVar12 == (longlong *)0x0) {
        local_150 = (int *)0x0;
        local_148[0] = (int *)0x0;
        uVar11 = IppGetScopeId(local_188,local_98);
        local_1c8 = local_178;
        local_1d0 = (char *)0x0;
        local_1d8 = local_148;
        local_1e0 = &local_150;
        local_1e8 = ppiVar18;
        iVar10 = IppFindNextHopAndSource(*ppiVar15,ppiVar15,local_98,uVar11);
        if (-1 < iVar10) {
          local_100 = local_150;
          local_b8 = local_148[0];
          goto LAB_1c0075499;
        }
        uVar11 = 0xd;
        *(undefined4 *)(local_168 + 0x8c) = 0xc000021b;
        puVar21 = local_1a0;
      }
      else {
        cVar6 = IppRateLimitIcmp(plVar12);
        ppiVar15 = local_188;
        if (cVar6 != '\0') {
          uVar11 = 0xc;
          *(undefined4 *)(local_168 + 0x8c) = 0xc000021b;
          goto LAB_1c00752e6;
        }
LAB_1c0075499:
        lVar16 = local_180;
        if ((*(byte *)(local_180 + 0xb1) & 0x40) == 0) {
          NetioRetreatNetBufferList(local_168,*(undefined4 *)(local_180 + 0x30),0);
          local_198 = *(undefined4 *)(lVar16 + 0x30);
          *(undefined4 *)(lVar16 + 0x30) = 0;
        }
        puVar21 = local_1a0;
        uVar9 = IppComputeIcmpPayloadSize(lVar16,local_1a0,local_198,&local_190);
        iVar10 = IppAllocateIcmpError(local_128,&local_158,*(ushort *)(puVar21 + 0x28) + 0x18,uVar9)
        ;
        lVar4 = local_138;
        lVar1 = local_158;
        uVar11 = local_18c;
        if (iVar10 < 0) goto LAB_1c00752ed;
        local_1e8 = &local_160;
        if (*(char *)(lVar16 + 0xb1) < '\0') {
          uVar17 = (ulonglong)local_190;
          RtlCopyMdlToBuffer(*(undefined8 *)(local_138 + 0x20),*(undefined4 *)(local_138 + 0x28),
                             local_158,local_190);
          NetioAdvanceNetBuffer(lVar4,local_198);
          local_1e8 = &local_160;
          RtlCopyMdlToBuffer(*(undefined8 *)(lVar4 + 0x20),*(undefined4 *)(lVar4 + 0x28),
                             uVar17 + lVar1,uVar9 - uVar17);
          if (local_1a0 == &Ipv4Global) {
            *(undefined *)(lVar1 + 9) = *(undefined *)(lVar16 + 0x2c);
          }
          else {
            *(undefined *)(lVar1 + 6) = *(undefined *)(lVar16 + 0x2c);
          }
        }
        else {
          RtlCopyMdlToBuffer(*(undefined8 *)(local_138 + 0x20),*(undefined4 *)(local_138 + 0x28),
                             local_158,(ulonglong)uVar9);
        }
        puVar21 = local_1a0;
        IppSendControl(local_1a7,local_1a0,local_128);
        uVar11 = local_18c;
      }
      goto LAB_1c007555b;
    }
    uVar11 = 10;
    *(undefined4 *)(lVar16 + 0x8c) = 0xc000021b;
LAB_1c00752e6:
    iVar10 = -0x3ffffde5;
    puVar21 = local_1a0;
  }
  else {
LAB_1c00d71aa:
    uVar11 = 9;
    iVar10 = -0x3ffffde5;
    *(undefined4 *)(lVar16 + 0x8c) = 0xc000021b;
    puVar21 = local_1a0;
LAB_1c007555b:
    if (-1 < iVar10) goto LAB_1c00752fa;
  }
LAB_1c00752ed:
  if ((DAT_1c0208d8a & 8) != 0) {
    local_1d0 = (char *)0x0;
    iVar20 = 0;
    if (local_108 == (longlong *)0x0) {
      piVar14 = local_b8;
      if ((local_b8 != (int *)0x0) ||
         ((piVar14 = *(int **)(local_180 + 0xd0), piVar14 != (int *)0x0 && (*piVar14 == 0x616c7049))
         )) {
        local_1d0 = **(char ***)(piVar14 + 4);
      }
    }
    else {
      local_1d0 = **(char ***)(*local_108 + 0x10);
    }
    if (ppiVar15 != (int **)0x0) {
      iVar20 = **ppiVar15;
    }
    local_1c8 = *(uint **)(local_180 + 0x100);
    local_1d8 = (int **)CONCAT44(local_1d8._4_4_,iVar20);
    local_1e0 = (int **)CONCAT44(local_1e0._4_4_,iVar10);
    local_1e8 = (int **)CONCAT44(local_1e8._4_4_,uVar11);
    LogEtwIcmpDrop(puVar21,0,local_1a6,param_5);
  }
LAB_1c00752fa:
  if (local_108 != (longlong *)0x0) {
    auVar3._8_8_ = 0;
    auVar3._0_8_ = _DAT_fffff78000000008 / 10000;
    lVar16 = SUB168(ZEXT816(0x624dd2f1a9fbe77) * auVar3,8);
    *(int *)((longlong)local_108 + 0x54) =
         (int)((_DAT_fffff78000000008 / 10000 - lVar16 >> 1) + lVar16 >> 8);
    if (*(int *)(local_108 + 10) == 0) {
      KeBugCheck(0x1c);
      pcVar2 = (code *)swi(3);
      (*pcVar2)();
      return;
    }
    LOCK();
    plVar12 = local_108 + 10;
    iVar10 = *(int *)plVar12;
    *(int *)plVar12 = *(int *)plVar12 + -1;
    UNLOCK();
    if (iVar10 == 1) {
      FUN_1c00d726d();
      return;
    }
  }
  if (local_100 != (int *)0x0) {
    if (*local_100 == 0x616c7049) {
      IppDereferenceLocalAddress();
    }
    else if (*local_100 == 0x656e7049) {
      IppDereferenceNeighbor();
    }
  }
  if (local_b8 != (int *)0x0) {
    IppDereferenceLocalAddress();
  }
  __security_check_cookie(local_50 ^ (ulonglong)auStack_208);
  return;
}