clean up the following decompiled C code. 
/* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

void UdpReceiveDatagrams(longlong param_1,longlong ******param_2)

{
  int *piVar1;
  longlong ****pppplVar2;
  undefined auVar3 [16];
  char cVar4;
  byte bVar5;
  int iVar6;
  longlong *****ppppplVar7;
  longlong lVar8;
  longlong lVar9;
  ulonglong *puVar10;
  longlong ***ppplVar11;
  longlong ****pppplVar12;
  ushort uVar13;
  ushort uVar14;
  longlong ******pppppplVar15;
  undefined2 uVar16;
  ulonglong *puVar17;
  ulonglong uVar18;
  longlong lVar19;
  undefined4 uVar20;
  undefined4 uVar21;
  uint uVar22;
  uint uVar23;
  ulonglong uVar24;
  longlong ******pppppplVar25;
  longlong ******pppppplVar26;
  short sVar27;
  undefined4 uVar28;
  undefined4 uVar29;
  longlong *****ppppplVar30;
  longlong unaff_GS_OFFSET;
  undefined8 in_CR8;
  undefined auStack_408 [32];
  undefined8 local_3e8;
  undefined8 local_3e0;
  undefined8 local_3d8;
  uint local_3d0;
  longlong *****local_3c8;
  undefined4 local_3c0;
  undefined8 local_3b8;
  undefined4 local_3b0;
  char local_3a8;
  undefined local_3a7;
  byte local_3a6;
  undefined local_3a5;
  int local_3a4;
  undefined8 local_3a0;
  uint local_398;
  ulonglong *local_390;
  short local_388;
  short local_384;
  short local_380 [4];
  longlong local_378;
  longlong ******local_370;
  longlong *****local_368;
  longlong ******local_360;
  undefined4 local_358 [2];
  undefined8 local_350;
  undefined4 local_348;
  uint local_344;
  uint local_340;
  longlong *****local_338;
  undefined local_330 [16];
  undefined local_320 [16];
  undefined local_310 [8];
  undefined2 uStack_308;
  undefined2 uStack_306;
  undefined4 uStack_304;
  undefined local_300 [16];
  undefined local_2f0 [16];
  undefined local_2e0 [8];
  undefined2 uStack_2d8;
  undefined2 uStack_2d6;
  undefined4 uStack_2d4;
  undefined local_2d0 [16];
  undefined8 local_2c0;
  undefined local_2b8 [16];
  undefined8 local_2a8;
  undefined local_2a0 [16];
  undefined8 local_290;
  undefined local_288 [16];
  undefined8 local_278;
  undefined local_268 [16];
  undefined local_258 [16];
  undefined local_248 [16];
  undefined local_238 [16];
  undefined local_228 [16];
  undefined local_218 [16];
  undefined local_208 [16];
  undefined local_1f8 [16];
  undefined local_1e8 [16];
  undefined local_1d8 [16];
  undefined local_1c8 [16];
  undefined local_1b8 [16];
  undefined local_1a8 [16];
  undefined local_198 [16];
  undefined local_188 [16];
  undefined local_178 [16];
  undefined local_168 [16];
  undefined local_158 [16];
  undefined local_148 [16];
  undefined local_138 [16];
  undefined local_128 [16];
  undefined local_118 [16];
  undefined local_108 [16];
  undefined local_f8 [16];
  undefined local_e8 [16];
  undefined local_d8 [16];
  undefined local_c8 [16];
  undefined local_b8 [16];
  undefined local_a8 [16];
  undefined local_98 [16];
  undefined local_88 [16];
  undefined local_78 [16];
  undefined local_68 [16];
  undefined local_58 [16];
  undefined8 local_48;
  ulonglong local_40;
  
  local_40 = __security_cookie ^ (ulonglong)auStack_408;
  local_48 = 0;
  local_390 = (ulonglong *)local_68;
  local_68 = ZEXT816(0);
  local_58 = ZEXT816(0);
  local_344 = *(uint *)(unaff_GS_OFFSET + 0x1a4);
  local_398 = 5;
  local_3a8 = '\x01';
  local_378 = param_1;
  local_370 = param_2;
  local_340 = KeQueryActiveProcessorCountEx(0xffff);
  do {
    ppppplVar7 = param_2[9];
    uVar21 = 0;
    uVar29 = 0;
    uVar28 = 0xc000000d;
    uVar20 = 2;
    if (ppppplVar7 != (longlong *****)0x0) {
LAB_1c0029eac:
      local_3a0 = *ppppplVar7;
      goto LAB_1c0029ec0;
    }
    ppppplVar7 = param_2[1];
    if (-1 < *(int *)((longlong)ppppplVar7 + 0x8c)) {
      if (*(short *)(param_1 + 0x18) == 0x17) {
        uVar21 = 0;
        cVar4 = IN6_IS_ADDR_UNSPECIFIED();
        uVar29 = uVar21;
        if (cVar4 == '\0') goto LAB_1c0029c82;
LAB_1c0029d1e:
        uVar29 = uVar21;
        if (*(int *)(param_2[4] + 3) == 4) goto LAB_1c0029c82;
      }
      else {
        if (*(int *)param_2[3] == 0) goto LAB_1c0029d1e;
LAB_1c0029c82:
        pppplVar12 = ppppplVar7[1];
        uVar21 = uVar20;
        if (7 < *(uint *)(pppplVar12 + 3)) {
          local_3e8 = (longlong ******)CONCAT44(local_3e8._4_4_,uVar29);
          ppppplVar7 = (longlong *****)NdisGetDataBuffer(pppplVar12);
          uVar13 = *(ushort *)((longlong)ppppplVar7 + 4) >> 8 |
                   *(ushort *)((longlong)ppppplVar7 + 4) << 8;
          if ((7 < uVar13) &&
             ((uint)uVar13 < *(uint *)(pppplVar12 + 3) || (uint)uVar13 == *(uint *)(pppplVar12 + 3))
             ) {
            if (*(short *)(param_2[1] + 0x23) == 0) {
              if (*(short *)((longlong)ppppplVar7 + 6) == 0) {
                if (*(short *)(param_1 + 0x18) == 0x17) {
LAB_1c0029e6e:
                  uVar21 = 3;
                  uVar28 = 0xc000003f;
                  goto LAB_1c0029d2f;
                }
              }
              else {
                local_330 = ZEXT816(0);
                local_320 = ZEXT816(0);
                _local_310 = ZEXT816(0);
                lVar19 = WfpNblInfoGet();
                auVar3 = _local_310;
                if ((((lVar19 == 0) || (lVar19 == *(longlong *)MmBadPointer_exref)) ||
                    (*(uint **)(lVar19 + 0x18) == (uint *)0x0)) ||
                   ((**(uint **)(lVar19 + 0x18) & 0x100000) == 0)) {
                  ppppplVar30 = param_2[1];
                  iVar6 = *(int *)(*(longlong *)(param_1 + 0x20) + 0x10);
                  if (iVar6 == 6) {
                    if ((*(uint *)(ppppplVar30 + 0x12) & 8) != 0) goto LAB_1c0029cf2;
                    if ((*(uint *)(ppppplVar30 + 0x12) & 1) != 0) {
                      uVar21 = 3;
                      uVar28 = 0xc000003f;
                      goto LAB_1c0029d2f;
                    }
                  }
                  else if (iVar6 == 0x11) {
                    if ((*(uint *)(ppppplVar30 + 0x12) & 0x10) != 0) goto LAB_1c0029cf2;
                    if ((*(uint *)(ppppplVar30 + 0x12) & 2) != 0) goto LAB_1c0029e6e;
                  }
                  local_330._8_8_ = ppppplVar30[1];
                  local_330._0_8_ = *(undefined8 *)(param_1 + 0x28);
                  local_320._8_8_ = *param_2[4][2];
                  local_320._0_8_ = param_2[3];
                  local_310._4_4_ = 0;
                  local_310._0_4_ = *(uint *)(*(longlong *)(param_1 + 0x20) + 0x10);
                  uStack_304 = auVar3._12_4_;
                  uStack_308 = uVar13;
                  uStack_306 = 0;
                  iVar6 = (**(code **)(*(longlong *)(param_1 + 0x30) + 8))(local_330);
                  if (iVar6 != 0xffff) goto LAB_1c0029e6e;
                }
              }
            }
LAB_1c0029cf2:
            if (*(int *)(pppplVar12 + 2) + 8U < *(uint *)(pppplVar12[1] + 5)) {
              *(int *)(pppplVar12 + 5) = *(int *)(pppplVar12 + 5) + 8;
              *(int *)(pppplVar12 + 3) = *(int *)(pppplVar12 + 3) + -8;
              *(uint *)(pppplVar12 + 2) = *(int *)(pppplVar12 + 2) + 8U;
            }
            else {
              NdisAdvanceNetBufferDataStart(pppplVar12);
            }
            *(int *)(param_2 + 6) = *(int *)(param_2 + 6) + 8;
            param_2[9] = ppppplVar7;
            if (ppppplVar7 != (longlong *****)0x0) goto LAB_1c0029eac;
            goto LAB_1c0029d77;
          }
        }
      }
LAB_1c0029d2f:
      local_3d8 = (undefined *)CONCAT44(local_3d8._4_4_,uVar21);
      local_3e0 = (longlong ******)((ulonglong)local_3e0 & 0xffffffff00000000);
      local_3e8 = param_2;
      InetInspectReceiveDiscard(*(undefined2 *)(param_1 + 0x18));
      *(undefined4 *)((longlong)param_2[1] + 0x8c) = uVar28;
      piVar1 = (int *)((ulonglong)*(uint *)(unaff_GS_OFFSET + 0x1a4) * 0x40 + 0xc +
                      *(longlong *)(param_1 + 0x80));
      *piVar1 = *piVar1 + 1;
    }
LAB_1c0029d77:
    param_2 = (longlong ******)*param_2;
    local_370 = param_2;
  } while (param_2 != (longlong ******)0x0);
LAB_1c002aea0:
  __security_check_cookie(local_40 ^ (ulonglong)auStack_408);
  return;
LAB_1c0029ec0:
  lVar19 = UdpCompartmentSet;
  ppppplVar7 = param_2[4];
  local_360 = (longlong ******)0x0;
  local_368 = (longlong *****)0x0;
  local_350 = ppppplVar7;
  if (1 < *(int *)(ppppplVar7 + 3) - 1U) {
    local_3a7 = 0;
    local_358[0] = 0;
    iVar6 = *(int *)*ppppplVar7[1];
    if (iVar6 == 1) {
      lVar8 = *(longlong *)(UdpCompartmentSet + 0x148);
    }
    else {
      RtlAcquireScalableReadLock(UdpCompartmentSet,local_358,&local_3a7);
      lVar8 = InetGetCompartmentUnderLock(lVar19,iVar6,0);
      RtlReleaseScalableReadLock(lVar19);
    }
    pppppplVar25 = (longlong ******)0x1;
    uVar22 = 0;
    local_3a6 = 1;
    local_2d0 = ZEXT816(0);
    lVar19 = **(longlong **)(lVar8 + 0x20);
    uVar13 = local_3a0._2_2_ >> 8;
    lVar8 = *(longlong *)(lVar19 + 0xe0 + (ulonglong)(local_3a0._2_2_ & 0xff) * 8);
    local_2c0 = 0;
    LOCK();
    *(int *)(lVar8 + 8) = *(int *)(lVar8 + 8) + 1;
    UNLOCK();
    cVar4 = KeTestSpinLock(lVar8);
    if (cVar4 == '\0') {
      LOCK();
      *(int *)(lVar8 + 8) = *(int *)(lVar8 + 8) + -1;
      UNLOCK();
      KeAcquireInStackQueuedSpinLockAtDpcLevel(lVar8);
      LOCK();
      *(int *)(lVar8 + 8) = *(int *)(lVar8 + 8) + 1;
      UNLOCK();
      KeReleaseInStackQueuedSpinLockFromDpcLevel(local_2d0);
    }
    if (*(short *)(lVar8 + 0x10) != 0) {
      puVar17 = (ulonglong *)(*(longlong *)(lVar8 + 0x18) + (ulonglong)uVar13 * 0x20 + 0x10);
      uVar18 = *puVar17;
      while (uVar18 != 0) {
        local_388 = 0;
        uVar18 = *puVar17;
        if ((((uVar18 == 0) || ((uVar18 & 3) != 0)) &&
            (lVar9 = (**(code **)(lVar19 + 0x70))(uVar18 & 0xfffffffffffffffc), lVar9 != -1)) &&
           (((uVar18 = 0, local_388 == 0 || (uVar18 = 0, param_1 == 0)) ||
            (local_388 == *(short *)(param_1 + 0x18))))) goto LAB_1c002a050;
        puVar17 = (ulonglong *)(*puVar17 & 0xfffffffffffffffc);
        uVar18 = *puVar17;
      }
    }
    goto LAB_1c002a195;
  }
  if ((*(byte *)(param_2 + 2) & 1) == 0) {
    uVar18 = (ulonglong)local_344;
  }
  else {
    uVar18 = (ulonglong)*(uint *)(param_2[1] + 0x1a) % (ulonglong)local_340;
  }
  local_3a5 = 0;
  local_348 = 0;
  iVar6 = *(int *)*ppppplVar7[1];
  if (iVar6 == 1) {
    lVar8 = *(longlong *)(UdpCompartmentSet + 0x148);
  }
  else {
    RtlAcquireScalableReadLock(UdpCompartmentSet,&local_348,&local_3a5);
    lVar8 = InetGetCompartmentUnderLock(lVar19,iVar6,0);
    RtlReleaseScalableReadLock(lVar19,local_348,local_3a5);
  }
  pppplVar12 = local_3a0;
  local_2a0 = ZEXT816(0);
  lVar19 = **(longlong **)(lVar8 + 0x20);
  ppppplVar30 = *(longlong ******)(lVar19 + 0xe0 + (ulonglong)(local_3a0._2_2_ & 0xff) * 8);
  local_290 = 0;
  LOCK();
  *(int *)(ppppplVar30 + 1) = *(int *)(ppppplVar30 + 1) + 1;
  UNLOCK();
  local_338 = ppppplVar30;
  cVar4 = KeTestSpinLock(ppppplVar30);
  if (cVar4 == '\0') {
    LOCK();
    *(int *)(ppppplVar30 + 1) = *(int *)(ppppplVar30 + 1) + -1;
    UNLOCK();
    KeAcquireInStackQueuedSpinLockAtDpcLevel(ppppplVar30,local_2a0);
    LOCK();
    *(int *)(ppppplVar30 + 1) = *(int *)(ppppplVar30 + 1) + 1;
    UNLOCK();
    KeReleaseInStackQueuedSpinLockFromDpcLevel(local_2a0);
  }
  if (*(short *)(ppppplVar30 + 2) == 0) {
    ppplVar11 = (longlong ***)0x0;
  }
  else {
    pppplVar12 = ppppplVar30[3] + ((ulonglong)pppplVar12 >> 0x18 & 0xff) * 4;
    if (((pppplVar12[2] != (longlong ***)0x0) && ((*(uint *)pppplVar12 & 2) != 0)) &&
       (pppplVar12[3] != (longlong ***)0x0)) {
      ppplVar11 = (longlong ***)
                  LookupEndpointFromPerProcEndpointTable
                            (pppplVar12,*(undefined2 *)(param_1 + 0x18),ppppplVar7[2],uVar18);
      if (ppplVar11 != (longlong ***)0x0) {
        local_3e8 = (longlong ******)CONCAT71(local_3e8._1_7_,1);
        cVar4 = ReferenceEndpointInAssignmentIfMatched(lVar19,ppplVar11,param_1,ppppplVar7);
        if (cVar4 != '\0') goto LAB_1c002ace3;
      }
      ppplVar11 = (longlong ***)
                  LookupEndpointFromPerProcEndpointTable
                            (pppplVar12,*(undefined2 *)(param_1 + 0x18),0,uVar18);
      if (ppplVar11 != (longlong ***)0x0) {
        local_3e8 = (longlong ******)CONCAT71(local_3e8._1_7_,1);
        cVar4 = ReferenceEndpointInAssignmentIfMatched(lVar19,ppplVar11,param_1,ppppplVar7);
        if (cVar4 != '\0') goto LAB_1c002ace3;
      }
      ppplVar11 = (longlong ***)LookupEndpointFromPerProcEndpointTable(pppplVar12,0,0,uVar18);
      if (ppplVar11 != (longlong ***)0x0) {
        local_3e8 = (longlong ******)CONCAT71(local_3e8._1_7_,1);
        cVar4 = ReferenceEndpointInAssignmentIfMatched(lVar19,ppplVar11,param_1,ppppplVar7);
        if (cVar4 != '\0') goto LAB_1c002ace3;
      }
    }
    for (ppplVar11 = pppplVar12[2]; ppplVar11 != (longlong ***)0x0;
        ppplVar11 = *(longlong ****)((ulonglong)ppplVar11 & 0xfffffffffffffffc)) {
      local_380[0] = 0;
      bVar5 = (byte)ppplVar11 & 3;
      if (((ulonglong)ppplVar11 & 3) != 0) {
        uVar18 = (ulonglong)ppplVar11 & 0xfffffffffffffffc;
        pppplVar12 = (longlong ****)(**(code **)(lVar19 + 0x70))(uVar18,bVar5,local_380);
        if ((((pppplVar12 != (longlong ****)0xffffffffffffffff) &&
             ((local_380[0] == 0 || (local_380[0] == *(short *)(param_1 + 0x18))))) &&
            ((pppplVar12 == (longlong ****)0x0 || (pppplVar12 == ppppplVar7[2])))) &&
           ((bVar5 == 1 && ((*(uint *)(uVar18 + 0x10) & 2) == 0)))) {
          local_3e8 = (longlong ******)0x0;
          cVar4 = (**(code **)(lVar19 + 0x80))(uVar18,1,param_1,ppppplVar7);
          ppppplVar30 = local_338;
          if (cVar4 != '\0') break;
        }
      }
      ppppplVar30 = local_338;
    }
  }
LAB_1c002ace3:
  pppppplVar25 = local_370;
  LOCK();
  *(int *)(ppppplVar30 + 1) = *(int *)(ppppplVar30 + 1) + -1;
  UNLOCK();
  uVar18 = (ulonglong)ppplVar11 & 0xfffffffffffffffc;
  if (uVar18 == 0) {
    local_3e8 = &local_368;
    UdpDiscardDatagrams(param_1,local_370,&local_3a0,&local_360);
    puVar17 = local_390;
  }
  else {
    lVar19 = uVar18 - 0x70;
    local_278 = 0;
    local_288 = ZEXT816(0);
    LOCK();
    *(int *)(uVar18 - 0x68) = *(int *)(uVar18 - 0x68) + 1;
    UNLOCK();
    cVar4 = KeTestSpinLock(lVar19);
    if (cVar4 == '\0') {
      LOCK();
      *(int *)(uVar18 - 0x68) = *(int *)(uVar18 - 0x68) + -1;
      UNLOCK();
      KeAcquireInStackQueuedSpinLockAtDpcLevel(lVar19,local_288);
      LOCK();
      *(int *)(uVar18 - 0x68) = *(int *)(uVar18 - 0x68) + 1;
      UNLOCK();
      KeReleaseInStackQueuedSpinLockFromDpcLevel(local_288);
    }
    pppppplVar25 = local_370;
    local_3e8 = &local_368;
    if ((*(uint *)(uVar18 - 0x5c) & 8) == 0) {
      LOCK();
      *(int *)(uVar18 - 0x68) = *(int *)(uVar18 - 0x68) + -1;
      UNLOCK();
      UdpDiscardDatagrams(param_1,local_370,&local_3a0,&local_360);
    }
    else {
      local_3e0 = local_3e8;
      local_3e8 = (longlong ******)&local_360;
      UdpDeliverDatagrams(param_1,lVar19,local_370,&local_3a0);
    }
    LOCK();
    piVar1 = (int *)(uVar18 - 0x60);
    iVar6 = *piVar1;
    *piVar1 = *piVar1 + -1;
    UNLOCK();
    puVar17 = local_390;
    if (iVar6 == 1) {
      if ((char)in_CR8 == '\0') {
        *(undefined8 *)(uVar18 + 0x58) = 0;
        UdpCleanupEndpointWorkQueueRoutine((undefined8 *)(uVar18 + 0x58));
        puVar17 = local_390;
      }
      else {
        NetioInsertWorkQueue(&UdpCleanupEndpointWorkQueue);
        puVar17 = local_390;
      }
    }
  }
  goto LAB_1c002ae02;
LAB_1c002a050:
  uVar22 = (uint)uVar18;
  if (local_398 <= uVar22) {
    local_398 = local_398 * 10 + 1;
    if ((local_398 <= uVar22) ||
       (puVar10 = (ulonglong *)ExAllocatePoolWithTag(0x200), puVar10 == (ulonglong *)0x0)) {
      pppppplVar25 = (longlong ******)0x0;
      local_398 = uVar22;
      goto LAB_1c002a195;
    }
    if ((local_390 != (ulonglong *)0x0) && (memcpy(puVar10), local_3a8 == '\0')) {
      ExFreePoolWithTag(local_390);
    }
    local_3a8 = '\0';
    local_390 = puVar10;
  }
  puVar10 = local_390;
  uVar24 = uVar18;
  if (((*(byte *)puVar17 & 3) == 1) &&
     (local_3e8 = param_2, cVar4 = (**(code **)(lVar19 + 0x80))(*puVar17 & 0xfffffffffffffffc),
     cVar4 != '\0')) {
    uVar24 = (ulonglong)(uVar22 + 1);
    puVar10[uVar18] = *puVar17;
  }
  uVar22 = (uint)uVar24;
  puVar17 = (ulonglong *)(*puVar17 & 0xfffffffffffffffc);
  if (*puVar17 != 0) {
    while( true ) {
      local_384 = 0;
      uVar18 = *puVar17;
      if ((((uVar18 == 0) || ((uVar18 & 3) != 0)) &&
          (lVar9 = (**(code **)(lVar19 + 0x70))(uVar18 & 0xfffffffffffffffc), lVar9 != -1)) &&
         (((uVar18 = uVar24, local_384 == 0 || (param_1 == 0)) ||
          (local_384 == *(short *)(param_1 + 0x18))))) break;
      puVar17 = (ulonglong *)(*puVar17 & 0xfffffffffffffffc);
      if (*puVar17 == 0) goto LAB_1c002a190;
    }
    goto LAB_1c002a050;
  }
LAB_1c002a190:
  pppppplVar25 = (longlong ******)(ulonglong)local_3a6;
LAB_1c002a195:
  pppplVar12 = local_3a0;
  LOCK();
  *(int *)(lVar8 + 8) = *(int *)(lVar8 + 8) + -1;
  UNLOCK();
  pppppplVar26 = (longlong ******)0x0;
  if (uVar22 < local_398) {
    local_390[uVar22] = 0;
  }
  pppppplVar15 = pppppplVar26;
  if (uVar22 != 0) {
    pppppplVar15 = pppppplVar25;
  }
  local_350 = (longlong *****)CONCAT44(local_350._4_4_,(int)pppppplVar15);
  if ((char)pppppplVar15 == '\0') {
    local_338 = param_2[4];
    local_3a4 = 1;
    *(undefined4 *)((longlong)param_2[1] + 0x8c) = 0xc000023f;
    iVar6 = *(int *)(param_2 + 6);
    uVar13 = *(ushort *)(param_1 + 0x18);
    uVar22 = (uint)uVar13;
    uVar16 = SUB82(local_3a0,0);
    if ((DAT_1c0208d86 & 2) != 0) {
      local_3e8._0_2_ = local_3a0._2_2_;
      local_1e8 = ZEXT816(0);
      local_1d8 = ZEXT816(0);
      local_1c8 = ZEXT816(0);
      local_1b8 = ZEXT816(0);
      local_1a8 = ZEXT816(0);
      local_198 = ZEXT816(0);
      local_188 = ZEXT816(0);
      local_178 = ZEXT816(0);
      local_268 = ZEXT816(0);
      local_258 = ZEXT816(0);
      local_248 = ZEXT816(0);
      local_238 = ZEXT816(0);
      local_228 = ZEXT816(0);
      local_218 = ZEXT816(0);
      local_208 = ZEXT816(0);
      local_1f8 = ZEXT816(0);
      uVar14 = uVar13;
      if (uVar13 == 0x17) {
        uVar14 = 0x17;
      }
      INETADDR_SETSOCKADDR(uVar14,local_1e8,*param_2[4][2],*(undefined4 *)(param_2[4][2] + 1));
      local_3e8 = (longlong ******)CONCAT62(local_3e8._2_6_,uVar16);
      INETADDR_SETSOCKADDR(uVar13);
      if (DAT_1c0200d24 == 1) {
        bVar5 = SOCKADDR_SIZE(uVar13);
        local_3b8 = (longlong *****)CONCAT44(local_3b8._4_4_,1);
        local_3c8 = (longlong *****)local_268;
        local_3c0 = 4;
        local_3d8 = local_1e8;
        local_3d0 = (uint)bVar5;
        local_3e0 = (longlong ******)CONCAT44(local_3e0._4_4_,local_3d0);
        local_3e8 = (longlong ******)CONCAT44(local_3e8._4_4_,uVar22);
        McTemplateK0qqqbr2qbr4qq_EtwWriteTransfer(&MICROSOFT_TCPIP_PROVIDER_Context);
      }
    }
    if (uVar22 == 2) {
      local_3b8 = param_2[1];
      local_3b0 = 4;
      local_3c0 = *(undefined4 *)(param_2 + 8);
      local_3c8 = param_2[7];
      local_3d0 = 8;
      local_3d8 = (undefined *)CONCAT44(local_3d8._4_4_,iVar6 + -8);
      local_3e0 = (longlong ******)
                  (CONCAT71(local_3e0._1_7_,*(undefined *)(param_2 + 2)) & 0xffffffffffffff01);
      local_3e8 = (longlong ******)CONCAT62(local_3e8._2_6_,uVar16);
      WfpInTransportShimV4Discard(param_2[4]);
    }
    else if (uVar22 == 0x17) {
      local_3b8 = param_2[1];
      local_3b0 = 4;
      local_3c0 = *(undefined4 *)(param_2 + 8);
      local_3c8 = param_2[7];
      local_3d0 = 8;
      local_3d8 = (undefined *)CONCAT44(local_3d8._4_4_,iVar6 + -8);
      local_3e0 = (longlong ******)
                  (CONCAT71(local_3e0._1_7_,*(undefined *)(param_2 + 2)) & 0xffffffffffffff01);
      local_3e8 = (longlong ******)CONCAT62(local_3e8._2_6_,uVar16);
      WfpInTransportShimV6Discard(param_2[4]);
    }
    pppppplVar26 = (longlong ******)*param_2;
    iVar6 = 1;
    if (pppppplVar26 != (longlong ******)0x0) {
LAB_1c002a410:
      ppppplVar7 = pppppplVar26[9];
      uVar21 = 0xc000000d;
      uVar29 = 2;
      if (ppppplVar7 == (longlong *****)0x0) {
        ppppplVar7 = pppppplVar26[1];
        if (-1 < *(int *)((longlong)ppppplVar7 + 0x8c)) {
          if (*(short *)(local_378 + 0x18) == 0x17) {
            cVar4 = IN6_IS_ADDR_UNSPECIFIED();
            if (cVar4 == '\0') goto LAB_1c002a45f;
LAB_1c002a505:
            if (*(int *)(pppppplVar26[4] + 3) == 4) goto LAB_1c002a45f;
            uVar29 = 0;
          }
          else {
            if (*(int *)pppppplVar26[3] == 0) goto LAB_1c002a505;
LAB_1c002a45f:
            pppplVar2 = ppppplVar7[1];
            if (7 < *(uint *)(pppplVar2 + 3)) {
              local_3e8 = (longlong ******)((ulonglong)local_3e8 & 0xffffffff00000000);
              ppppplVar7 = (longlong *****)NdisGetDataBuffer(pppplVar2);
              uVar13 = *(ushort *)((longlong)ppppplVar7 + 4) >> 8 |
                       *(ushort *)((longlong)ppppplVar7 + 4) << 8;
              if ((7 < uVar13) &&
                 ((uint)uVar13 < *(uint *)(pppplVar2 + 3) ||
                  (uint)uVar13 == *(uint *)(pppplVar2 + 3))) {
                if (*(short *)(pppppplVar26[1] + 0x23) == 0) {
                  if (*(short *)((longlong)ppppplVar7 + 6) == 0) {
                    if (*(short *)(local_378 + 0x18) == 0x17) {
LAB_1c002a74f:
                      uVar29 = 3;
                      uVar21 = 0xc000003f;
                      goto LAB_1c002a518;
                    }
                  }
                  else {
                    local_300 = ZEXT816(0);
                    local_2f0 = ZEXT816(0);
                    _local_2e0 = ZEXT816(0);
                    lVar19 = WfpNblInfoGet();
                    auVar3 = _local_2e0;
                    if ((((lVar19 == 0) || (lVar19 == *(longlong *)MmBadPointer_exref)) ||
                        (*(uint **)(lVar19 + 0x18) == (uint *)0x0)) ||
                       ((**(uint **)(lVar19 + 0x18) & 0x100000) == 0)) {
                      ppppplVar30 = pppppplVar26[1];
                      iVar6 = *(int *)(*(longlong *)(local_378 + 0x20) + 0x10);
                      if (iVar6 == 6) {
                        if ((*(uint *)(ppppplVar30 + 0x12) & 8) != 0) goto LAB_1c002a4d0;
                        if ((*(uint *)(ppppplVar30 + 0x12) & 1) != 0) {
                          uVar29 = 3;
                          uVar21 = 0xc000003f;
                          goto LAB_1c002a518;
                        }
                      }
                      else if (iVar6 == 0x11) {
                        if ((*(uint *)(ppppplVar30 + 0x12) & 0x10) != 0) goto LAB_1c002a4d0;
                        if ((*(uint *)(ppppplVar30 + 0x12) & 2) != 0) goto LAB_1c002a74f;
                      }
                      local_300._8_8_ = ppppplVar30[1];
                      local_300._0_8_ = *(undefined8 *)(local_378 + 0x28);
                      local_2f0._8_8_ = *pppppplVar26[4][2];
                      local_2f0._0_8_ = pppppplVar26[3];
                      local_2e0._4_4_ = 0;
                      local_2e0._0_4_ = *(uint *)(*(longlong *)(local_378 + 0x20) + 0x10);
                      uStack_2d4 = auVar3._12_4_;
                      uStack_2d8 = uVar13;
                      uStack_2d6 = 0;
                      iVar6 = (**(code **)(*(longlong *)(local_378 + 0x30) + 8))(local_300);
                      if (iVar6 != 0xffff) goto LAB_1c002a74f;
                    }
                  }
                }
LAB_1c002a4d0:
                if (*(int *)(pppplVar2 + 2) + 8U < *(uint *)(pppplVar2[1] + 5)) {
                  *(int *)(pppplVar2 + 5) = *(int *)(pppplVar2 + 5) + 8;
                  *(int *)(pppplVar2 + 3) = *(int *)(pppplVar2 + 3) + -8;
                  *(uint *)(pppplVar2 + 2) = *(int *)(pppplVar2 + 2) + 8U;
                  *(int *)(pppppplVar26 + 6) = *(int *)(pppppplVar26 + 6) + 8;
                  pppppplVar26[9] = ppppplVar7;
                }
                else {
                  NdisAdvanceNetBufferDataStart(pppplVar2);
                  *(int *)(pppppplVar26 + 6) = *(int *)(pppppplVar26 + 6) + 8;
                  pppppplVar26[9] = ppppplVar7;
                }
                goto LAB_1c002a572;
              }
            }
          }
LAB_1c002a518:
          local_3d8 = (undefined *)CONCAT44(local_3d8._4_4_,uVar29);
          local_3e0 = (longlong ******)((ulonglong)local_3e0 & 0xffffffff00000000);
          local_3e8 = pppppplVar26;
          InetInspectReceiveDiscard(*(undefined2 *)(local_378 + 0x18));
          ppppplVar7 = (longlong *****)0x0;
          *(undefined4 *)((longlong)pppppplVar26[1] + 0x8c) = uVar21;
          piVar1 = (int *)((ulonglong)*(uint *)(unaff_GS_OFFSET + 0x1a4) * 0x40 + 0xc +
                          *(longlong *)(local_378 + 0x80));
          *piVar1 = *piVar1 + 1;
          pppplVar12 = local_3a0;
          goto LAB_1c002a572;
        }
        local_368 = (longlong *****)0x0;
LAB_1c002a8e6:
        param_1 = local_378;
        pppppplVar26 = (longlong ******)*pppppplVar26;
        while ((iVar6 = local_3a4, pppppplVar26 != (longlong ******)0x0 &&
               (local_368 = (longlong *****)UdpBeginDelivery(param_1), iVar6 = local_3a4,
               local_368 == (longlong *****)0x0))) {
          pppppplVar26 = (longlong ******)*pppppplVar26;
        }
      }
      else {
LAB_1c002a572:
        param_1 = local_378;
        local_368 = ppppplVar7;
        if (ppppplVar7 == (longlong *****)0x0) goto LAB_1c002a8e6;
        iVar6 = local_3a4;
        if ((local_3a0._2_2_ == *(short *)((longlong)ppppplVar7 + 2)) &&
           (local_338 == pppppplVar26[4])) goto code_r0x0001c002a59e;
      }
    }
LAB_1c002a913:
    piVar1 = (int *)((ulonglong)*(uint *)(unaff_GS_OFFSET + 0x1a4) * 0x40 + 8 +
                    *(longlong *)(param_1 + 0x80));
    *piVar1 = *piVar1 + iVar6;
    pppppplVar15 = (longlong ******)((ulonglong)local_350 & 0xffffffff);
    param_2 = local_370;
  }
  puVar17 = local_390;
  uVar22 = local_398;
  uVar23 = 0;
  puVar10 = local_390;
  pppppplVar25 = local_370;
  local_360 = pppppplVar26;
  if (local_398 != 0) {
    do {
      uVar18 = *puVar10 & 0xfffffffffffffffc;
      pppppplVar25 = local_370;
      if (uVar18 == 0) break;
      lVar19 = uVar18 - 0x70;
      if ((char)pppppplVar15 != '\0') {
        local_2b8 = ZEXT816(0);
        local_2a8 = 0;
        LOCK();
        *(int *)(uVar18 - 0x68) = *(int *)(uVar18 - 0x68) + 1;
        UNLOCK();
        cVar4 = KeTestSpinLock(lVar19);
        if (cVar4 == '\0') {
          LOCK();
          *(int *)(uVar18 - 0x68) = *(int *)(uVar18 - 0x68) + -1;
          UNLOCK();
          KeAcquireInStackQueuedSpinLockAtDpcLevel(lVar19);
          LOCK();
          *(int *)(uVar18 - 0x68) = *(int *)(uVar18 - 0x68) + 1;
          UNLOCK();
          KeReleaseInStackQueuedSpinLockFromDpcLevel(local_2b8);
        }
        if ((*(uint *)(uVar18 - 0x5c) & 8) == 0) {
          LOCK();
          *(int *)(uVar18 - 0x68) = *(int *)(uVar18 - 0x68) + -1;
          UNLOCK();
        }
        else {
          local_3e0 = &local_368;
          local_3e8 = (longlong ******)&local_360;
          UdpDeliverDatagrams(param_1,lVar19,param_2,&local_3a0);
        }
      }
      LOCK();
      piVar1 = (int *)(uVar18 - 0x60);
      iVar6 = *piVar1;
      *piVar1 = *piVar1 + -1;
      UNLOCK();
      if (iVar6 == 1) {
        if ((char)in_CR8 == '\0') {
          *(undefined8 *)(uVar18 + 0x58) = 0;
          UdpCleanupEndpointWorkQueueRoutine((undefined8 *)(uVar18 + 0x58));
        }
        else {
          NetioInsertWorkQueue(&UdpCleanupEndpointWorkQueue);
        }
      }
      pppppplVar15 = (longlong ******)((ulonglong)local_350 & 0xffffffff);
      uVar23 = uVar23 + 1;
      puVar10 = puVar10 + 1;
      pppppplVar25 = local_370;
    } while (uVar23 < uVar22);
  }
LAB_1c002ae02:
  if ((*(byte *)(pppppplVar25 + 2) & 8) == 0) {
    do {
      if (pppppplVar25[9] != (longlong *****)0x0) {
        pppplVar12 = pppppplVar25[1][1];
        if (*(uint *)(pppplVar12 + 2) < 8) {
          NdisRetreatNetBufferDataStart(pppplVar12,8,0,NetioAllocateMdl_exref);
        }
        else {
          *(int *)(pppplVar12 + 5) = *(int *)(pppplVar12 + 5) + -8;
          *(int *)(pppplVar12 + 3) = *(int *)(pppplVar12 + 3) + 8;
          *(uint *)(pppplVar12 + 2) = *(uint *)(pppplVar12 + 2) - 8;
        }
        *(int *)(pppppplVar25 + 6) = *(int *)(pppppplVar25 + 6) + -8;
      }
      pppppplVar25 = (longlong ******)*pppppplVar25;
    } while (pppppplVar25 != local_360);
  }
  local_370 = local_360;
  if (local_368 != (longlong *****)0x0) {
    if (local_360 == (longlong ******)0x0) goto LAB_1c002ae85;
    local_3a0 = *local_368;
  }
  param_2 = local_360;
  if (local_360 == (longlong ******)0x0) goto LAB_1c002ae85;
  goto LAB_1c0029ec0;
code_r0x0001c002a59e:
  local_3a4 = local_3a4 + 1;
  *(undefined4 *)((longlong)pppppplVar26[1] + 0x8c) = 0xc000023f;
  iVar6 = *(int *)(pppppplVar26 + 6);
  uVar13 = *(ushort *)(local_378 + 0x18);
  uVar22 = (uint)uVar13;
  sVar27 = local_3a0._2_2_;
  if ((DAT_1c0208d86 & 2) != 0) {
    local_e8 = ZEXT816(0);
    local_d8 = ZEXT816(0);
    local_c8 = ZEXT816(0);
    local_b8 = ZEXT816(0);
    local_a8 = ZEXT816(0);
    local_98 = ZEXT816(0);
    local_88 = ZEXT816(0);
    local_78 = ZEXT816(0);
    local_168 = ZEXT816(0);
    local_158 = ZEXT816(0);
    local_148 = ZEXT816(0);
    local_138 = ZEXT816(0);
    local_128 = ZEXT816(0);
    local_118 = ZEXT816(0);
    local_108 = ZEXT816(0);
    local_f8 = ZEXT816(0);
    uVar14 = uVar13;
    if (uVar13 == 0x17) {
      uVar14 = 0x17;
    }
    local_3e8._0_2_ = (short)pppplVar12;
    INETADDR_SETSOCKADDR
              (uVar14,local_e8,*pppppplVar26[4][2],*(undefined4 *)(pppppplVar26[4][2] + 1));
    local_3e8 = (longlong ******)CONCAT62(local_3e8._2_6_,sVar27);
    INETADDR_SETSOCKADDR(uVar13);
    if (DAT_1c0200d24 == 1) {
      bVar5 = SOCKADDR_SIZE(uVar13);
      local_3b8 = (longlong *****)CONCAT44(local_3b8._4_4_,1);
      local_3c8 = (longlong *****)local_168;
      local_3c0 = 4;
      local_3d8 = local_e8;
      local_3d0 = (uint)bVar5;
      local_3e0 = (longlong ******)CONCAT44(local_3e0._4_4_,local_3d0);
      local_3e8 = (longlong ******)CONCAT44(local_3e8._4_4_,uVar22);
      McTemplateK0qqqbr2qbr4qq_EtwWriteTransfer(&MICROSOFT_TCPIP_PROVIDER_Context);
      sVar27 = local_3a0._2_2_;
    }
  }
  if (uVar22 == 2) {
    local_3b8 = pppppplVar26[1];
    local_3b0 = 4;
    local_3c0 = *(undefined4 *)(pppppplVar26 + 8);
    local_3c8 = pppppplVar26[7];
    local_3d0 = 8;
    local_3d8 = (undefined *)CONCAT44(local_3d8._4_4_,iVar6 + -8);
    local_3e0 = (longlong ******)
                (CONCAT71(local_3e0._1_7_,*(undefined *)(pppppplVar26 + 2)) & 0xffffffffffffff01);
    local_3e8 = (longlong ******)CONCAT62(local_3e8._2_6_,sVar27);
    WfpInTransportShimV4Discard(pppppplVar26[4]);
  }
  else if (uVar22 == 0x17) {
    local_3b8 = pppppplVar26[1];
    local_3b0 = 4;
    local_3c0 = *(undefined4 *)(pppppplVar26 + 8);
    local_3c8 = pppppplVar26[7];
    local_3d0 = 8;
    local_3d8 = (undefined *)CONCAT44(local_3d8._4_4_,iVar6 + -8);
    local_3e0 = (longlong ******)
                (CONCAT71(local_3e0._1_7_,*(undefined *)(pppppplVar26 + 2)) & 0xffffffffffffff01);
    local_3e8 = (longlong ******)CONCAT62(local_3e8._2_6_,sVar27);
    WfpInTransportShimV6Discard(pppppplVar26[4]);
  }
  pppppplVar26 = (longlong ******)*pppppplVar26;
  iVar6 = local_3a4;
  if (pppppplVar26 == (longlong ******)0x0) goto LAB_1c002a913;
  goto LAB_1c002a410;
LAB_1c002ae85:
  if (local_3a8 == '\0') {
    ExFreePoolWithTag(puVar17,0x43456e49);
  }
  goto LAB_1c002aea0;
}