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

void Ipv4pReceiveRoutingHeader(longlong *param_1)

{
  int *piVar1;
  char *pcVar2;
  int *piVar3;
  ushort uVar4;
  byte *pbVar5;
  code *pcVar6;
  undefined auVar7 [16];
  char cVar8;
  int iVar9;
  undefined4 uVar10;
  longlong lVar11;
  longlong *plVar12;
  longlong lVar13;
  longlong *plVar14;
  undefined8 uVar15;
  longlong lVar16;
  int iVar17;
  uint uVar18;
  longlong *plVar20;
  longlong unaff_GS_OFFSET;
  undefined auStack_e8 [32];
  undefined8 local_c8;
  undefined8 local_c0;
  byte local_b8;
  int *local_b0;
  int local_a8;
  uint local_a4;
  longlong local_a0;
  longlong *local_98;
  longlong local_90;
  longlong local_80;
  longlong local_78;
  ulonglong local_70;
  longlong local_68;
  longlong local_60;
  undefined local_58 [16];
  undefined local_48 [16];
  undefined8 local_38;
  ulonglong local_30;
  ulonglong uVar19;
  
  local_30 = __security_cookie ^ (ulonglong)auStack_e8;
  local_80 = param_1[0x18];
  local_a0 = 0;
  local_98 = (longlong *)0x0;
  local_38 = 0;
  local_a8 = 0;
  local_58 = ZEXT816(0);
  local_48 = ZEXT816(0);
  plVar12 = (longlong *)0x0;
  do {
    lVar13 = param_1[1];
    plVar14 = plVar12;
    if (((lVar13 != 0) && (-1 < *(int *)(lVar13 + 0x8c))) &&
       ((&DAT_1c01fac90)[(ulonglong)*(uint *)((longlong)param_1 + 0x2c) * 0x48] != '\0')) {
      if (*(uint *)((longlong)param_1 + 0x2c) != 0x2b) break;
      pbVar5 = (byte *)param_1[0x22];
      if ((pbVar5[9] == 0x2b) || (*(uint *)(param_1 + 6) != (uint)(byte)((*pbVar5 & 0xf) << 2))) {
        *(undefined4 *)(lVar13 + 0x8c) = 0xc000023e;
      }
      else {
        if (DAT_1c01ff754 == 2) goto LAB_1c0190b8b;
        uVar15 = *(undefined8 *)(lVar13 + 8);
        iVar17 = *(uint *)(param_1 + 6) - (uint)*(byte *)(param_1 + 0x26);
        NetioRetreatNetBufferList(lVar13,iVar17,0);
        local_c8 = (longlong *)((ulonglong)local_c8 & 0xffffffff00000000);
        lVar11 = NdisGetDataBuffer(uVar15,*(undefined4 *)((longlong)param_1 + 0x134),local_58,1);
        local_78 = lVar11;
        NetioAdvanceNetBufferList(lVar13,iVar17);
        uVar18 = *(byte *)(lVar11 + 2) - 1;
        uVar19 = (ulonglong)uVar18;
        local_a4 = (uint)*(byte *)(param_1 + 0x26);
        if ((*(byte *)(lVar11 + 1) < 7) ||
           (local_70 = uVar19, (ulonglong)*(byte *)(lVar11 + 1) - 4 < uVar19)) {
          uVar4 = *(ushort *)(pbVar5 + 6);
          if (((ushort)(uVar4 >> 8 | (uVar4 & 0xff1f) << 8) == 0) && ((uVar4 & 0x20) == 0)) {
            uVar18 = (uint)pbVar5[9];
          }
          else {
            uVar18 = 0x2c;
          }
          *(uint *)((longlong)param_1 + 0x2c) = uVar18;
          goto LAB_1c0190e7f;
        }
        if (*(int *)(param_1 + 0x1f) != 1) goto LAB_1c0190b8b;
        piVar3 = (int *)(uVar19 + lVar11);
        cVar8 = IppIsInvalidSourceAddressStrict(&Ipv4Global,piVar3);
        if (cVar8 == '\0') {
          iVar17 = Ipv4UnicastAddressScope(piVar3);
          iVar9 = Ipv4UnicastAddressScope(param_1[0x1e]);
          if (iVar17 < iVar9) goto LAB_1c0190e0f;
          lVar11 = param_1[0x1a];
          local_c8 = &local_a0;
          lVar16 = *(longlong *)(lVar11 + 8);
          if (*(int *)(lVar11 + 0x18) != 1) {
            lVar11 = 0;
          }
          local_90 = lVar16;
          iVar17 = IppRouteToDestinationInternal(local_80,piVar3,lVar16,lVar11);
          if (iVar17 < 0) {
            plVar12 = (longlong *)0x0;
          }
          else {
            plVar12 = (longlong *)IppGetNextHopFromPath(local_a0);
            auVar7._8_8_ = 0;
            auVar7._0_8_ = _DAT_fffff78000000008 / 10000;
            lVar11 = SUB168(ZEXT816(0x624dd2f1a9fbe77) * auVar7,8);
            *(int *)(local_a0 + 0x54) =
                 (int)((_DAT_fffff78000000008 / 10000 - lVar11 >> 1) + lVar11 >> 8);
            if (*(int *)(local_a0 + 0x50) == 0) {
              KeBugCheck(0x1c);
              pcVar6 = (code *)swi(3);
              (*pcVar6)();
              return;
            }
            LOCK();
            piVar1 = (int *)(local_a0 + 0x50);
            iVar17 = *piVar1;
            *piVar1 = *piVar1 + -1;
            UNLOCK();
            if (iVar17 == 1) {
              IppCleanupPathPrimitive(local_a0);
            }
          }
          if (plVar12 != (longlong *)0x0) {
            if ((*(int *)plVar12 == 0x616c7049) && (*(int *)(plVar12 + 3) != 1)) goto LAB_1c0190b8b;
            if ((*(byte *)((longlong)param_1 + 0xb1) & 0x10) != 0) {
              lVar11 = IppGetRouteFromPath(local_a0);
              if ((lVar11 == 0) || (*(longlong *)(lVar11 + 0x90) != 0)) {
                local_b8 = 0;
                local_c0 = (longlong **)((ulonglong)local_c0 & 0xffffffff00000000);
                local_c8 = (longlong *)CONCAT71(local_c8._1_7_,5);
                IppSendError(0,&Ipv4Global,param_1,3);
                if (lVar11 != 0) {
                  IppDereferenceRoute(lVar11);
                }
                goto LAB_1c0190a25;
              }
              IppDereferenceRoute(lVar11);
              lVar16 = local_90;
            }
            if (((*(byte *)(lVar16 + 0x198) & 0x10) != 0) ||
               (((lVar16 == plVar12[1] && (*(byte *)(local_78 + 1) - uVar18 == 4)) &&
                (*piVar3 == *(int *)param_1[0x20])))) {
              lVar11 = NetioAllocateAndReferenceCloneNetBufferList(lVar13,0);
              if (lVar11 != 0) {
                IppCopyNetBufferListInfo(lVar11,lVar13);
                uVar18 = *(uint *)(param_1 + 6);
                plVar14 = (longlong *)(ulonglong)uVar18;
                iVar17 = NetioRetreatNetBufferList(lVar11,plVar14);
                if (-1 < iVar17) {
                  NetioRetreatNetBufferList(lVar13,uVar18,0);
                  *(undefined4 *)(param_1 + 6) = 0;
                  local_c0 = &local_98;
                  local_c8 = plVar14;
                  RtlCopyMdlToMdl(*(undefined8 *)(*(longlong *)(lVar13 + 8) + 8),
                                  *(undefined4 *)(*(longlong *)(lVar13 + 8) + 0x10),
                                  *(undefined8 *)(*(longlong *)(lVar11 + 8) + 8),
                                  *(undefined4 *)(*(longlong *)(lVar11 + 8) + 0x10));
                  if (plVar14 <= local_98) {
                    local_c8 = (longlong *)((ulonglong)local_c8 & 0xffffffff00000000);
                    lVar13 = NdisGetDataBuffer(*(undefined8 *)(lVar11 + 8),plVar14,0,4);
                    piVar1 = (int *)(lVar13 + 0x10);
                    *piVar1 = *piVar3;
                    lVar16 = (ulonglong)(local_a4 & 0xff) + lVar13;
                    *(undefined4 *)(local_70 + lVar16) = *(undefined4 *)param_1[0x1e];
                    pcVar2 = (char *)(lVar16 + 2);
                    *pcVar2 = *pcVar2 + '\x04';
                    lVar16 = IppCopyPacket(&Ipv4Global,param_1);
                    if (lVar16 == 0) {
                      NetioDereferenceNetBufferList(lVar11,0);
                    }
                    else {
                      *(undefined *)(lVar16 + 0x130) = *(undefined *)(param_1 + 0x26);
                      *(byte *)(lVar16 + 0xb1) =
                           *(byte *)(lVar16 + 0xb1) ^
                           (*(byte *)(lVar16 + 0xb1) ^ *(byte *)((longlong)param_1 + 0xb1)) & 0x10;
                      IppDereferenceLocalAddress(*(undefined8 *)(lVar16 + 0xd0));
                      *(longlong **)(lVar16 + 0xd0) = plVar12;
                      if (*(int *)plVar12 == 0x616c7049) {
                        CarAcquireCacheAwareReference(plVar12[4],1);
                      }
                      else if (*(int *)plVar12 == 0x656e7049) {
                        LOCK();
                        *(int *)((longlong)plVar12 + 4) = *(int *)((longlong)plVar12 + 4) + 1;
                        UNLOCK();
                      }
                      *(int **)(lVar16 + 0xf0) = piVar1;
                      uVar10 = Ipv4AddressType(piVar1);
                      local_b0 = &local_a8;
                      *(undefined4 *)(lVar16 + 0xf8) = uVar10;
                      local_b8 = *(byte *)(lVar16 + 0xb1) >> 4 & 1;
                      *(longlong *)(lVar16 + 0x110) = lVar13;
                      *(longlong *)(lVar16 + 8) = lVar11;
                      local_c0 = (longlong **)CONCAT71(local_c0._1_7_,1);
                      local_c8 = plVar12;
                      cVar8 = IppForwardPackets(&Ipv4Global,local_90,plVar12[1],lVar16);
                      iVar17 = local_a8;
                      if (cVar8 == '\0') {
                        if ((local_a8 != 0x101) &&
                           (iVar9 = IppDiscardReceivedPackets(&Ipv4Global,local_a8,lVar16,0),
                           iVar9 == 0)) {
                          local_c8 = (longlong *)((ulonglong)local_c8 & 0xffffffff00000000);
                          IppSendErrorListForDiscardReason(0,&Ipv4Global,lVar16,iVar17);
                        }
                        IppCompleteAndFreePacketList(lVar16,0);
                      }
                      else {
                        *(byte *)(param_1 + 2) = *(byte *)(param_1 + 2) | 2;
                        if (*(int *)plVar12 == 0x616c7049) {
                          uVar4 = *(ushort *)(lVar13 + 6);
                          if (((ushort)(uVar4 >> 8 | (uVar4 & 0xff1f) << 8) != 0) ||
                             ((uVar4 & 0x20) != 0)) {
                            *(undefined4 *)((longlong)param_1 + 0x2c) = 0x2c;
                            IppCompleteAndFreePacketList(lVar16,0);
                            plVar14 = plVar12;
                            goto LAB_1c0190e7f;
                          }
                          local_68 = lVar16;
                          local_60 = lVar16;
                          IppReceiveHeaderBatch(&Ipv4Global,&local_68);
                        }
                        else {
                          IppFragmentPackets(&Ipv4Global,lVar16);
                        }
                      }
                    }
                    goto LAB_1c0190b8b;
                  }
                }
                NetioDereferenceNetBufferList(lVar11,0);
              }
              goto LAB_1c0190b8b;
            }
            uVar15 = 3;
            local_c0 = (longlong **)((ulonglong)local_c0 & 0xffffffff00000000);
            local_c8 = (longlong *)CONCAT71(local_c8._1_7_,5);
            goto LAB_1c0190ad3;
          }
          local_b8 = 0;
          local_c0 = (longlong **)((ulonglong)local_c0 & 0xffffffff00000000);
          local_c8 = (longlong *)CONCAT71(local_c8._1_7_,5);
          IppSendError(0,&Ipv4Global,param_1,3);
LAB_1c0190a25:
          lVar16 = (ulonglong)*(uint *)(unaff_GS_OFFSET + 0x1a4) * 0xc0;
          lVar11 = DAT_1c01ff9d0;
          iVar17 = IppGetPacketCount(lVar13);
          piVar3 = (int *)(lVar16 + 0x74 + lVar11);
          *piVar3 = *piVar3 + iVar17;
        }
        else {
LAB_1c0190e0f:
          uVar15 = 0xc;
          uVar18 = local_a4 + 0x14 + uVar18;
          local_c0 = (longlong **)
                     CONCAT44(local_c0._4_4_,
                              uVar18 >> 0x18 | (uVar18 & 0xff0000) >> 8 | (uVar18 & 0xff00) << 8 |
                              uVar18 * 0x1000000);
          local_c8 = (longlong *)((ulonglong)local_c8 & 0xffffffffffffff00);
LAB_1c0190ad3:
          local_b8 = 0;
          IppSendError(0,&Ipv4Global,param_1,uVar15);
        }
LAB_1c0190b8b:
        plVar20 = (longlong *)0x0;
        *(undefined4 *)((longlong)param_1 + 0x2c) = 0x3b;
        if (param_1[1] != 0) {
          *(undefined4 *)(param_1[1] + 0x8c) = 0xc000021b;
        }
        plVar14 = plVar12;
        if (plVar12 != (longlong *)0x0) {
          plVar14 = plVar20;
          if (*(int *)plVar12 == 0x616c7049) {
            IppDereferenceLocalAddress(plVar12);
          }
          else if (*(int *)plVar12 == 0x656e7049) {
            IppDereferenceNeighbor(plVar12);
          }
        }
      }
    }
LAB_1c0190e7f:
    param_1 = (longlong *)*param_1;
    plVar12 = plVar14;
  } while (param_1 != (longlong *)0x0);
  __security_check_cookie(local_30 ^ (ulonglong)auStack_e8);
  return;
}