clean up the following decompiled C code. use context clues to properly name variables. 
/* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */
/* WARNING: Type propagation algorithm not settling */

void IppReceiveHeaderBatch(undefined1 *Protocol,undefined8 *Packet)

{
  longlong *plVar1;
  int iVar2;
  Packet_t *pPVar3;
  longlong ********pppppppplVar4;
  longlong ********pppppppplVar5;
  uint *puVar6;
  longlong ******pppppplVar7;
  longlong *******ppppppplVar8;
  Packet_t *Packet_00;
  uint uVar9;
  ulonglong uVar10;
  char *pcVar11;
  longlong *******ppppppplVar12;
  longlong lVar13;
  ulonglong uVar14;
  longlong ********pppppppplVar15;
  undefined **ppuVar16;
  uint uVar17;
  longlong ******pppppplVar18;
  undefined8 uVar19;
  ulonglong uVar20;
  uint uVar21;
  undefined auStackY_f8 [32];
  longlong *******local_c8;
  longlong ********local_c0;
  uint local_b8 [2];
  longlong ********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;
  int *local_68;
  longlong *****local_60;
  undefined local_58 [16];
  ulonglong local_48;
  
  local_48 = __security_cookie ^ (ulonglong)auStackY_f8;
  uVar20 = 0;
  local_a8 = (longlong ********)&local_b0;
  local_98 = &local_a0;
  local_78 = (longlong ********)&local_80;
  local_c0 = &local_c8;
  local_b0 = (longlong ********)0x0;
  local_a0 = (longlong *******)0x0;
  local_80 = (longlong ********)0x0;
  local_c8 = (longlong *******)0x0;
  Packet_00 = (Packet_t *)*Packet;
  while (pppppppplVar4 = local_b0, Packet_00 != (Packet_t *)0x0) {
    pPVar3 = Packet_00->Next;
    Packet_00->Next = (Packet_t *)0x0;
    IppReceiveHeadersHelper
              (Packet_00,Protocol,(longlong)&local_b0,(longlong)&local_a0,(longlong)&local_80,
               (longlong)&local_c8);
    Packet_00 = pPVar3;
  }
joined_r0x0001c00443af:
  do {
    if (pppppppplVar4 == (longlong ********)0x0) break;
    ppppppplVar12 = pppppppplVar4[1];
    if ((ppppppplVar12 != (longlong *******)0x0) &&
       (*(int *)((longlong)ppppppplVar12 + 0x8c) == 0x105)) {
      iVar2 = *(int *)((longlong)pppppppplVar4 + 0x2c);
      if ((iVar2 == 0x11) && (*(short *)(*(longlong *)(Protocol + 0x10) + 4) == 2)) {
        pppppplVar18 = ppppppplVar12[1];
        local_68 = (int *)0x0;
        uVar19 = 0;
        local_b8[0] = 0;
        local_70 = NdisGetDataBuffer(pppppplVar18,8);
        if (((((local_70 != 0) && (*(short *)(local_70 + 2) != -0x6bef)) ||
             (uVar10 = IppDecomposeUdpPacket
                                 ((longlong)pppppplVar18,(longlong)local_58,uVar19,&local_70,
                                  &local_68,local_b8), (int)uVar10 < 0)) ||
            (*(short *)(local_70 + 2) != -0x6bef)) || ((3 < local_b8[0] && (*local_68 == 0))))
        goto LAB_1c0044481;
        ppuVar16 = &PTR_IppReceiveUdpEspList_1c0200508;
        pcVar11 = &DAT_1c0200530;
      }
      else {
LAB_1c0044481:
        ppuVar16 = (undefined **)(Protocol + (longlong)iVar2 * 0x48 + 0x1f8);
        pcVar11 = Protocol + (longlong)iVar2 * 0x48 + 0x220;
      }
      if (*pcVar11 != '\0') {
        (*(code *)*ppuVar16)(pppppppplVar4);
        goto joined_r0x0001c00443af;
      }
      IppValidateHeaderChain(Protocol,(longlong *)pppppppplVar4);
    }
    pppppppplVar4 = (longlong ********)*pppppppplVar4;
  } while( true );
  local_88 = &local_90;
  local_90 = (longlong *******)0x0;
  uVar10 = uVar20;
  do {
    while( true ) {
      pppppppplVar4 = local_b0;
      uVar21 = (uint)uVar10;
      if (local_b0 == (longlong ********)0x0) {
        if (local_90 != (longlong *******)0x0) {
          IppProcessDeliverList
                    (Protocol,uVar21,(longlong **)&local_90,(longlong)&local_a0,(longlong)&local_80,
                     (longlong)&local_c8);
        }
        ppppppplVar12 = local_c8;
        if (local_a0 != (longlong *******)0x0) {
          IppProcessDeliverList
                    (Protocol,0x101,(longlong **)&local_a0,0,(longlong)&local_80,(longlong)&local_c8
                    );
          ppppppplVar12 = local_c8;
        }
        for (; ppppppplVar12 != (longlong *******)0x0;
            ppppppplVar12 = (longlong *******)*ppppppplVar12) {
          uVar20 = (ulonglong)((int)uVar20 + 1);
        }
        plVar1 = (longlong *)
                 ((ulonglong)SystemReserved1[0x12]._4_4_ * 0xc0 + *(longlong *)(Protocol + 0x4f60) +
                 0x18);
        *plVar1 = *plVar1 + uVar20;
        pppppppplVar4 = local_80;
        while (pppppppplVar4 != (longlong ********)0x0) {
          pppppppplVar5 = (longlong ********)*pppppppplVar4;
          *pppppppplVar4 = (longlong *******)0x0;
          *(undefined4 *)((longlong)pppppppplVar4[1] + 0x8c) = 0;
          IppSendErrorListForDiscardReason
                    (0,Protocol,(longlong *)pppppppplVar4,*(int *)(pppppppplVar4 + 0x25),
                     *(undefined4 *)((longlong)pppppppplVar4 + 300));
          if (pppppppplVar4[1] != (longlong *******)0x0) {
            *(undefined4 *)((longlong)pppppppplVar4[1] + 0x8c) = 0;
          }
          *local_c0 = (longlong *******)pppppppplVar4;
          local_c0 = pppppppplVar4;
          pppppppplVar4 = pppppppplVar5;
        }
        if (local_c8 != (longlong *******)0x0) {
          local_60 = (longlong *****)0x0;
          pppppplVar18 = &local_60;
          ppppppplVar12 = local_c8;
          do {
            pppppplVar7 = ppppppplVar12[1];
            ppppppplVar8 = (longlong *******)*ppppppplVar12;
            if (pppppplVar7 != (longlong ******)0x0) {
              *pppppplVar18 = (longlong *****)pppppplVar7;
              pppppplVar18 = pppppplVar7;
            }
            IppFreePacket((longlong)ppppppplVar12);
            ppppppplVar12 = ppppppplVar8;
          } while (ppppppplVar8 != (longlong *******)0x0);
          if (local_60 != (longlong *****)0x0) {
            NetioDereferenceNetBufferListChain(local_60,0);
          }
        }
        __security_check_cookie(local_48 ^ (ulonglong)auStackY_f8);
        return;
      }
      pppppppplVar5 = (longlong ********)*local_b0;
      *local_b0 = (longlong *******)0x0;
      pppppppplVar15 = (longlong ********)&local_b0;
      if (local_a8 != local_b0) {
        pppppppplVar15 = local_a8;
      }
      ppppppplVar12 = local_b0[1];
      local_a8 = pppppppplVar15;
      if (ppppppplVar12 != (longlong *******)0x0) break;
LAB_1c004451e:
      *local_c0 = (longlong *******)local_b0;
      local_b0 = pppppppplVar5;
      local_c0 = pppppppplVar4;
    }
    if ((*(int *)((longlong)ppppppplVar12 + 0x8c) != 0x105) &&
       (*(int *)((longlong)ppppppplVar12 + 0x8c) != -0x3ffffdc2)) {
      *(undefined4 *)((longlong)ppppppplVar12 + 0x8c) = 0;
      goto LAB_1c004451e;
    }
    *(undefined4 *)((longlong)ppppppplVar12 + 0x8c) = 0;
    *(undefined *)((longlong)local_b0 + 0x11) = 0;
    if ((*(byte *)(local_b0 + 0x16) & 4) == 0) {
      pppppppplVar15 = local_b0 + 0x1a;
      pppppplVar18 = (*pppppppplVar15)[1];
      if (((*(int *)(pppppplVar18 + 0x36) != 0) ||
          ((local_b0 = pppppppplVar5, *(int *)(*pppppppplVar15 + 3) == 3 &&
           (*(int *)(pppppplVar18 + 0x37) != 0)))) &&
         (local_b0 = pppppppplVar5,
         ppppppplVar12 =
              (longlong *******)IppCreateClonePacketForRaw((longlong *)pppppppplVar4,Protocol,0),
         ppppppplVar12 != (longlong *******)0x0)) {
        *(byte *)(ppppppplVar12 + 0x16) = *(byte *)(ppppppplVar12 + 0x16) | 4;
        *(undefined4 *)((longlong)ppppppplVar12[1] + 0x8c) = 0xc000023e;
        pppppppplVar4[0x24] = ppppppplVar12;
      }
      uVar17 = *(uint *)((longlong)pppppppplVar4 + 0x2c);
      lVar13 = WfpNblInfoGet(pppppppplVar4[1]);
      if ((((lVar13 != 0) && (lVar13 != *(longlong *)MmBadPointer_exref)) &&
          (puVar6 = *(uint **)(lVar13 + 0x18), puVar6 != (uint *)0x0)) &&
         ((uVar9 = IPSecIsOutboundContextTunnel(puVar6), uVar9 != 0 &&
          (uVar14 = IPSecPacketIsContextRcvPass1(), (char)uVar14 != '\0')))) {
        puVar6[0x78] = uVar17;
        uVar17 = 0x102;
      }
      if (uVar17 != uVar21) {
        if (local_90 != (longlong *******)0x0) {
          IppProcessDeliverList
                    (Protocol,uVar21,(longlong **)&local_90,(longlong)&local_a0,(longlong)&local_80,
                     (longlong)&local_c8);
        }
        uVar10 = (ulonglong)uVar17;
      }
      *(undefined4 *)(pppppppplVar4 + 0x27) = *(undefined4 *)(pppppppplVar4 + 6);
      *local_88 = (longlong *******)pppppppplVar4;
      local_88 = pppppppplVar4;
    }
    else {
      *(undefined4 *)((longlong)local_b0[1] + 0x8c) = 0xc000023e;
      *local_98 = (longlong *******)local_b0;
      local_b0 = pppppppplVar5;
      local_98 = pppppppplVar4;
    }
  } while( true );
}