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

void IppFlcReceivePacketsCore(longlong *param_1,longlong **param_2,char param_3,char param_4)

{
  int *piVar1;
  uint uVar2;
  longlong *plVar3;
  longlong *plVar4;
  code *pcVar5;
  undefined auVar6 [16];
  bool bVar7;
  char cVar8;
  int iVar9;
  ulonglong uVar10;
  int *piVar11;
  longlong lVar12;
  longlong **pplVar13;
  char *pcVar14;
  longlong **pplVar15;
  longlong lVar16;
  int iVar17;
  longlong *plVar18;
  uint uVar19;
  longlong unaff_GS_OFFSET;
  char local_res18;
  uint in_stack_ffffffffffffff08;
  char local_d8;
  undefined4 local_c8;
  uint local_c4;
  longlong *local_c0;
  longlong **local_b8;
  undefined4 local_b0;
  longlong *local_a8;
  longlong **local_a0;
  longlong local_98;
  longlong local_90;
  longlong *local_88;
  longlong *local_80;
  longlong **local_78;
  longlong local_70;
  longlong *local_68;
  longlong *local_60;
  longlong **local_58;
  
  pplVar15 = (longlong **)param_1[1];
  local_80 = (longlong *)0x0;
  local_c8 = 0;
  local_d8 = '\0';
  local_a8 = *pplVar15;
  lVar12 = local_a8[5];
  local_res18 = param_3;
  local_a0 = pplVar15;
  if (param_3 == '\0') {
    local_d8 = KfRaiseIrql(2);
    local_res18 = local_d8 == '\x02';
  }
  local_c4 = KeGetCurrentProcessorNumberEx(&local_c8);
  uVar10 = (ulonglong)local_c4;
  lVar16 = *(longlong *)(DAT_1c020bc00 + uVar10 * 8);
  plVar18 = (longlong *)(uVar10 * 0xc0 + *(longlong *)(lVar12 + 0x4f60));
  local_98 = *(longlong *)(param_1[0xc] + uVar10 * 8);
  if (((*(byte *)(pplVar15 + 0x33) & 1) != 0) || (*(int *)(lVar16 + 0x5004) == 3)) {
    if (local_res18 == '\0') {
      KeLowerIrql(local_d8);
    }
    lVar16 = local_98;
    pplVar15 = param_2;
    if (param_2 != (longlong **)0x0) {
      do {
        plVar4 = pplVar15[1];
        plVar3 = (longlong *)(lVar16 + 0x30);
        *plVar3 = *plVar3 + 1;
        *plVar18 = *plVar18 + 1;
        plVar3 = (longlong *)(lVar16 + 0x38);
        *plVar3 = *plVar3 + (ulonglong)*(uint *)(plVar4 + 3);
        plVar18[1] = plVar18[1] + (ulonglong)*(uint *)(plVar4 + 3);
        IppDiscardReceivedPackets(lVar12,10,0,param_1);
        *(undefined4 *)((longlong)pplVar15 + 0x8c) = 0xc000021b;
        pplVar15 = (longlong **)*pplVar15;
      } while (pplVar15 != (longlong **)0x0);
    }
    NetioDereferenceNetBufferListChain(param_2,local_res18);
    return;
  }
  iVar9 = KeGetCurrentProcessorNumberEx(0);
  piVar11 = *(int **)((ulonglong)(uint)(iVar9 * 0x48) + gWfpPerProContext);
  iVar9 = *piVar11;
  if (iVar9 == 0) {
    iVar9 = KeQueryDpcWatchdogInformation(piVar11 + 2);
    if (iVar9 == 0) {
      *piVar11 = 1;
      memset(piVar11 + 8,0,0x60);
      piVar11[0x20] = 1;
    }
    else {
      *(ulonglong *)(piVar11 + 2) = _DAT_fffff78000000008;
      *piVar11 = 2;
      memset(piVar11 + 4,0,0x60);
    }
    piVar11[0x1c] = 1;
  }
  else if (iVar9 == 1) {
    piVar11[0x20] = piVar11[0x20] + 1;
  }
  else if (iVar9 == 2) {
    piVar11[0x1c] = piVar11[0x1c] + 1;
  }
  *(int *)(lVar16 + 0x5004) = *(int *)(lVar16 + 0x5004) + 1;
  do {
    uVar19 = 0;
    local_b8 = &local_c0;
    local_88 = &local_90;
    local_c0 = (longlong *)0x0;
    local_68 = &local_70;
    local_58 = &local_60;
    local_90 = 0;
    local_70 = 0;
    local_60 = (longlong *)0x0;
    plVar3 = pplVar15[0xc];
    if ((plVar3 == (longlong *)0x0) || (*(char *)(plVar3 + 5) != '\0')) {
LAB_1c00438d0:
      bVar7 = false;
    }
    else {
      cVar8 = ExAcquireRundownProtectionCacheAwareEx(plVar3[2],1);
      bVar7 = true;
      if (cVar8 == '\0') goto LAB_1c00438d0;
    }
    iVar9 = 0x20;
    iVar17 = 1 << ((char)*(undefined4 *)(lVar16 + 0x5004) - 1U & 0x1f);
    if (iVar17 != 1) {
      iVar9 = (int)(0x20 / (longlong)iVar17);
    }
    local_b0 = *(undefined4 *)(lVar16 + 0x5000);
    pplVar15 = param_2;
    do {
      uVar2 = *(uint *)(lVar16 + 0x5000);
      param_2 = pplVar15;
      if (uVar2 == 0x40U - iVar9) break;
      pplVar13 = (longlong **)((ulonglong)uVar2 * 0x140 + lVar16);
      *(uint *)(lVar16 + 0x5000) = uVar2 + 1;
      memset(pplVar13,0,0x140);
      param_2 = (longlong **)*pplVar15;
      *pplVar15 = (longlong *)0x0;
      if ((param_4 == '\0') && ((*(uint *)(pplVar15 + 0x1b) & 0xffff00) != 0)) {
        piVar11 = (int *)((ulonglong)local_c8._2_1_ * 0x440 +
                         (&IpRssActivityBlocks)[(ushort)local_c8]);
        if (*(int *)(pplVar15 + 0x22) == *piVar11) {
          uVar2 = *(uint *)(pplVar15 + 0x1a);
          *(longlong *)(piVar11 + 2) = *(longlong *)(piVar11 + 2) + 1;
          *(longlong *)(piVar11 + (ulonglong)(uVar2 & 0x7f) * 2 + 6) =
               *(longlong *)(piVar11 + (ulonglong)(uVar2 & 0x7f) * 2 + 6) + 1;
        }
        else {
          *(longlong *)(piVar11 + 4) = *(longlong *)(piVar11 + 4) + 1;
        }
      }
      plVar3 = pplVar15[1];
      pplVar13[0x1b] = param_1;
      pplVar13[1] = (longlong *)pplVar15;
      *(byte *)((longlong)pplVar13 + 0xb2) =
           *(byte *)((longlong)pplVar13 + 0xb2) & 0x7f | param_4 << 7;
      pplVar13[0x18] = local_a8;
      local_80 = pplVar15[0x12];
      *(longlong *)(local_98 + 0x30) = *(longlong *)(local_98 + 0x30) + 1;
      *plVar18 = *plVar18 + 1;
      *(longlong *)(local_98 + 0x38) =
           *(longlong *)(local_98 + 0x38) + (ulonglong)*(uint *)(plVar3 + 3);
      plVar18[1] = plVar18[1] + (ulonglong)*(uint *)(plVar3 + 3);
      local_78 = pplVar15;
      iVar17 = (**(code **)(lVar12 + 0x50))(pplVar13);
      if (iVar17 < 0) {
        *local_58 = (longlong *)pplVar13;
        local_58 = pplVar13;
      }
      else if ((bVar7) && (param_4 == '\0')) {
        in_stack_ffffffffffffff08 = in_stack_ffffffffffffff08 & 0xffffff00;
        IppIndicatePacketsToIpsServiceChain(param_1,&local_78,pplVar15,0,in_stack_ffffffffffffff08);
        pplVar15 = local_78;
        if (local_78 == (longlong **)0x0) {
          pplVar13[1] = (longlong *)0x0;
          IppCompleteAndFreePacketList(pplVar13);
          *(int *)(lVar16 + 0x5000) = *(int *)(lVar16 + 0x5000) + -1;
        }
        else {
          if (*local_78 == (longlong *)0x0) {
            pplVar13[1] = (longlong *)local_78;
            goto LAB_1c0043a0f;
          }
          pplVar13[1] = (longlong *)0x0;
          IppCompleteAndFreePacketList(pplVar13,1);
          *(int *)(lVar16 + 0x5000) = *(int *)(lVar16 + 0x5000) + -1;
          IppFlcReceivePacketsCore(param_1,pplVar15,local_res18);
        }
      }
      else {
LAB_1c0043a0f:
        if ((local_c0 != (longlong *)0x0) &&
           (iVar17 = memcmp(local_c0[0x1e],pplVar13[0x1e],
                            *(undefined2 *)(*(longlong *)(lVar12 + 0x10) + 6)), iVar17 != 0)) {
          in_stack_ffffffffffffff08 = uVar19;
          IppDispatchReceivePacketHelper
                    (lVar12,local_a8,local_a0,&local_c0,uVar19,&local_90,&local_70);
          uVar19 = 0;
          local_b8 = &local_c0;
          local_c0 = (longlong *)0x0;
        }
        *local_b8 = (longlong *)pplVar13;
        uVar19 = uVar19 + 1;
        local_b8 = pplVar13;
      }
      pplVar15 = param_2;
    } while (param_2 != (longlong **)0x0);
    pplVar15 = local_a0;
    if (local_c0 != (longlong *)0x0) {
      IppDispatchReceivePacketHelper(lVar12,local_a8,local_a0,&local_c0,uVar19,&local_90,&local_70);
      local_b8 = &local_c0;
      local_c0 = (longlong *)0x0;
      in_stack_ffffffffffffff08 = uVar19;
    }
    if (local_90 != 0) {
      IppReceiveHeaderBatch(lVar12,&local_90);
    }
    if (bVar7) {
      ExReleaseRundownProtectionCacheAwareEx(pplVar15[0xc][2],1);
    }
    if (local_70 != 0) {
      IppFragmentPackets(lVar12);
    }
    if (local_60 != (longlong *)0x0) {
      IppCompleteAndFreePacketList();
    }
    *(undefined4 *)(lVar16 + 0x5000) = local_b0;
    if (local_res18 == '\0') {
      if (param_2 == (longlong **)0x0) break;
      IppDequeueForwardInjectedPacketsAtDpc(local_c4);
      *(int *)(lVar16 + 0x5004) = *(int *)(lVar16 + 0x5004) + -1;
      iVar9 = KeGetCurrentProcessorNumberEx(0);
      piVar11 = *(int **)((ulonglong)(uint)(iVar9 * 0x48) + gWfpPerProContext);
      if (*piVar11 == 1) {
        piVar1 = piVar11 + 0x20;
        *piVar1 = *piVar1 + -1;
        iVar9 = *piVar1;
joined_r0x0001c00c54ca:
        if (iVar9 == 0) {
          *piVar11 = 0;
        }
      }
      else if (*piVar11 == 2) {
        piVar1 = piVar11 + 0x1c;
        *piVar1 = *piVar1 + -1;
        iVar9 = *piVar1;
        goto joined_r0x0001c00c54ca;
      }
      KeLowerIrql(local_d8);
      local_d8 = KfRaiseIrql(2);
      iVar9 = KeGetCurrentProcessorNumberEx(0);
      piVar11 = *(int **)((ulonglong)(uint)(iVar9 * 0x48) + gWfpPerProContext);
      iVar9 = *piVar11;
      if (iVar9 == 0) {
        iVar9 = KeQueryDpcWatchdogInformation(piVar11 + 2);
        if (iVar9 == 0) {
          *piVar11 = 1;
          memset(piVar11 + 8,0,0x60);
          piVar11[0x20] = 1;
        }
        else {
          *(ulonglong *)(piVar11 + 2) = _DAT_fffff78000000008;
          *piVar11 = 2;
          memset(piVar11 + 4,0,0x60);
        }
        piVar11[0x1c] = 1;
      }
      else if (iVar9 == 1) {
        piVar11[0x20] = piVar11[0x20] + 1;
      }
      else if (iVar9 == 2) {
        piVar11[0x1c] = piVar11[0x1c] + 1;
      }
      local_c4 = *(uint *)(unaff_GS_OFFSET + 0x1a4);
      uVar10 = (ulonglong)local_c4;
      lVar16 = *(longlong *)(DAT_1c020bc00 + uVar10 * 8);
      *(int *)(lVar16 + 0x5004) = *(int *)(lVar16 + 0x5004) + 1;
      plVar18 = (longlong *)(uVar10 * 0xc0 + *(longlong *)(lVar12 + 0x4f60));
      local_98 = *(longlong *)(param_1[0xc] + uVar10 * 8);
    }
  } while (param_2 != (longlong **)0x0);
  uVar10 = (ulonglong)local_c4;
  plVar18 = (longlong *)(ForwardInjectionPerProcessorState + 0x50 + uVar10 * 0x70);
  if (*plVar18 != 0) {
    IppFragmentPackets(&Ipv4Global);
    plVar18[1] = (longlong)plVar18;
    *plVar18 = 0;
  }
  plVar18 = (longlong *)(uVar10 * 0x70 + ForwardInjectionPerProcessorState + 0x60);
  if (*plVar18 != 0) {
    IppFragmentPackets(&Ipv6Global);
    *plVar18 = 0;
    plVar18[1] = (longlong)plVar18;
  }
  pcVar14 = (char *)((ulonglong)*(uint *)(unaff_GS_OFFSET + 0x1a4) * 0x70 +
                    ForwardInjectionPerProcessorState);
  if (*pcVar14 != '\0') {
    if (*(longlong *)(pcVar14 + 0x28) != 0) {
      IppDereferenceCompartment();
    }
    if (*(longlong *)(pcVar14 + 0x30) != 0) {
      IppDereferenceInterface();
    }
    if (*(longlong *)(pcVar14 + 0x38) != 0) {
      IppDereferenceSubInterface();
    }
    plVar18 = *(longlong **)(pcVar14 + 0x40);
    if (plVar18 != (longlong *)0x0) {
      auVar6._8_8_ = 0;
      auVar6._0_8_ = _DAT_fffff78000000008 / 10000;
      lVar12 = SUB168(ZEXT816(0x624dd2f1a9fbe77) * auVar6,8);
      *(int *)((longlong)plVar18 + 0x54) =
           (int)((_DAT_fffff78000000008 / 10000 - lVar12 >> 1) + lVar12 >> 8);
      if (*(int *)(plVar18 + 10) == 0) {
        KeBugCheck(0x1c);
        pcVar5 = (code *)swi(3);
        (*pcVar5)();
        return;
      }
      LOCK();
      plVar3 = plVar18 + 10;
      iVar9 = *(int *)plVar3;
      *(int *)plVar3 = *(int *)plVar3 + -1;
      UNLOCK();
      if (iVar9 == 1) {
        lVar12 = plVar18[0x14];
        if (lVar12 != 0) {
          if (*(uint *)(plVar18 + 0x13) != 0) {
            if (((*(char *)(plVar18 + 9) == '\0') && (*(int *)(lVar12 + 0x74) == 0)) &&
               (*(uint *)(lVar12 + 0x78) < *(uint *)(plVar18 + 0x13))) {
              *(int *)(lVar12 + 0x84) = *(int *)(lVar12 + 0x84) + -1;
              lVar12 = plVar18[0x14];
            }
            *(int *)(lVar12 + 0x7c) = *(int *)(lVar12 + 0x7c) + -1;
            lVar12 = plVar18[0x14];
          }
          IppDereferenceRoute(lVar12);
          plVar18[0x14] = 0;
        }
        if ((int *)plVar18[0x15] != (int *)0x0) {
          iVar9 = *(int *)plVar18[0x15];
          if (iVar9 == 0x616c7049) {
            IppDereferenceLocalAddress();
          }
          else if (iVar9 == 0x656e7049) {
            IppDereferenceNeighbor();
          }
          plVar18[0x15] = 0;
        }
        if (*plVar18 != 0) {
          IppDereferenceLocalAddress();
        }
        if (plVar18[0x16] != 0) {
          ExFreePoolWithTag(plVar18[0x16],0x676e7049);
        }
        FsbFree(plVar18);
      }
    }
    if (*(longlong *)(pcVar14 + 0x48) != 0) {
      IppDereferenceNeighbor();
    }
    memset(pcVar14,0,0x50);
  }
  *(int *)(lVar16 + 0x5004) = *(int *)(lVar16 + 0x5004) + -1;
  iVar9 = KeGetCurrentProcessorNumberEx(0);
  piVar11 = *(int **)((ulonglong)(uint)(iVar9 * 0x48) + gWfpPerProContext);
  if (*piVar11 == 1) {
    piVar1 = piVar11 + 0x20;
    *piVar1 = *piVar1 + -1;
    iVar9 = *piVar1;
  }
  else {
    if (*piVar11 != 2) goto LAB_1c0043b6b;
    piVar1 = piVar11 + 0x1c;
    *piVar1 = *piVar1 + -1;
    iVar9 = *piVar1;
  }
  if (iVar9 == 0) {
    *piVar11 = 0;
  }
LAB_1c0043b6b:
  if (local_res18 == '\0') {
    KeLowerIrql(local_d8);
  }
  return;
}