; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe (Ip6InstanceDeliverPacket)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct._IP6_PROTOCOL = type { i32, %struct._EFI_IP6_PROTOCOL, ptr, i64, ptr, %struct._LIST_ENTRY, i8, %struct.NET_MAP, %struct.NET_MAP, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct.EFI_LOCK, ptr, %struct._LIST_ENTRY, ptr, i32, %struct.EFI_IP6_CONFIG_DATA, i8 }
%struct._EFI_IP6_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.NET_MAP = type { %struct._LIST_ENTRY, %struct._LIST_ENTRY, i64 }
%struct.EFI_LOCK = type { i64, i64, i32 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_IP6_CONFIG_DATA = type { i8, i8, i8, i8, %struct.EFI_IPv6_ADDRESS, %struct.EFI_IPv6_ADDRESS, i8, i8, i32, i32, i32 }
%struct.EFI_IPv6_ADDRESS = type { [16 x i8] }
%struct.NET_BUF = type { i32, i64, %struct._LIST_ENTRY, %union.NET_IP_HEAD, ptr, ptr, [64 x i8], ptr, i32, i32, [1 x %struct.NET_BLOCK_OP] }
%union.NET_IP_HEAD = type { ptr }
%struct.NET_BLOCK_OP = type { ptr, ptr, ptr, ptr, i32 }
%struct.NET_VECTOR = type { i32, i64, ptr, ptr, i32, i32, i32, [1 x %struct.NET_BLOCK] }
%struct.NET_BLOCK = type { i32, ptr }
%struct.IP6_RXDATA_WRAP = type { %struct._LIST_ENTRY, ptr, ptr, %struct._EFI_IP6_RECEIVE_DATA }
%struct._EFI_IP6_RECEIVE_DATA = type { %struct.EFI_TIME, ptr, i32, ptr, i32, i32, [1 x %struct._EFI_IP6_FRAGMENT_DATA] }
%struct.EFI_TIME = type { i16, i8, i8, i8, i8, i8, i8, i32, i16, i8, i8 }
%struct._EFI_IP6_FRAGMENT_DATA = type { i32, ptr }
%struct.IP6_CLIP_INFO = type { i32, i32, i32, i32, i32, i32, i64, i32, i16, i8, i8, i32 }
%struct.EFI_IP6_COMPLETION_TOKEN = type { ptr, i64, %union.anon.0 }
%union.anon.0 = type { ptr }
%struct.EFI_BOOT_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [130 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@gBS = external global ptr, align 8

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @RemoveEntryList(ptr noundef) #1

declare void @NetbufFree(ptr noundef) #1

declare zeroext i8 @DebugAssertEnabled() #1

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) #1

declare i32 @NetbufTrim(ptr noundef, i32 noundef, i8 noundef zeroext) #1

declare ptr @InsertHeadList(ptr noundef, ptr noundef) #1

declare ptr @NetbufDuplicate(ptr noundef, ptr noundef, i32 noundef) #1

declare ptr @NetbufAllocSpace(ptr noundef, i32 noundef, i8 noundef zeroext) #1

declare i64 @EfiAcquireLockOrFail(ptr noundef) #1

declare void @EfiReleaseLock(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @Ip6WrapRxData(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @Ip6InstanceDeliverPacket(ptr noundef %0) #2 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  br label %10

10:                                               ; preds = %96, %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._IP6_PROTOCOL, ptr %11, i32 0, i32 9
  %13 = call zeroext i8 @IsListEmpty(ptr noundef %12)
  %14 = icmp ne i8 %13, 0
  br i1 %14, label %21, label %15

15:                                               ; preds = %10
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._IP6_PROTOCOL, ptr %16, i32 0, i32 7
  %18 = call zeroext i8 @NetMapIsEmpty(ptr noundef %17)
  %19 = icmp ne i8 %18, 0
  %20 = xor i1 %19, true
  br label %21

21:                                               ; preds = %15, %10
  %22 = phi i1 [ false, %10 ], [ %20, %15 ]
  br i1 %22, label %23, label %128

23:                                               ; preds = %21
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._IP6_PROTOCOL, ptr %24, i32 0, i32 9
  %26 = getelementptr inbounds %struct._LIST_ENTRY, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = ptrtoint ptr %27 to i64
  %29 = sub i64 %28, ptrtoint (ptr getelementptr inbounds (%struct.NET_BUF, ptr null, i32 0, i32 2) to i64)
  %30 = inttoptr i64 %29 to ptr
  store ptr %30, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.NET_BUF, ptr %31, i32 0, i32 1
  %33 = load i64, ptr %32, align 8, !tbaa !19
  %34 = icmp sgt i64 %33, 1
  br i1 %34, label %53, label %35

35:                                               ; preds = %23
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.NET_BUF, ptr %36, i32 0, i32 7
  %38 = load ptr, ptr %37, align 8, !tbaa !21
  %39 = getelementptr inbounds %struct.NET_VECTOR, ptr %38, i32 0, i32 1
  %40 = load i64, ptr %39, align 8, !tbaa !22
  %41 = icmp sgt i64 %40, 1
  br i1 %41, label %53, label %42

42:                                               ; preds = %35
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = call ptr @Ip6WrapRxData(ptr noundef %43, ptr noundef %44)
  store ptr %45, ptr %5, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = icmp eq ptr %46, null
  br i1 %47, label %48, label %49

48:                                               ; preds = %42
  store i64 -9223372036854775799, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %129

49:                                               ; preds = %42
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.NET_BUF, ptr %50, i32 0, i32 2
  %52 = call ptr @RemoveEntryList(ptr noundef %51)
  br label %96

53:                                               ; preds = %35, %23
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = call ptr @NetbufDuplicate(ptr noundef %54, ptr noundef null, i32 noundef 40)
  store ptr %55, ptr %7, align 8, !tbaa !5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = icmp eq ptr %56, null
  br i1 %57, label %58, label %59

58:                                               ; preds = %53
  store i64 -9223372036854775799, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %129

59:                                               ; preds = %53
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call ptr @NetbufAllocSpace(ptr noundef %60, i32 noundef 40, i8 noundef zeroext 1)
  store ptr %61, ptr %8, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %59
  %63 = call zeroext i8 @DebugAssertEnabled()
  %64 = icmp ne i8 %63, 0
  br i1 %64, label %65, label %70

65:                                               ; preds = %62
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %69, label %68

68:                                               ; preds = %65
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1520, ptr noundef @.str.3)
  br label %69

69:                                               ; preds = %68, %65
  br label %70

70:                                               ; preds = %69, %62
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.NET_BUF, ptr %74, i32 0, i32 3
  store ptr %73, ptr %75, align 8, !tbaa !24
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.NET_BUF, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !24
  %80 = call ptr @CopyMem(ptr noundef %76, ptr noundef %79, i64 noundef 40)
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = call i32 @NetbufTrim(ptr noundef %81, i32 noundef 40, i8 noundef zeroext 1)
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = call ptr @Ip6WrapRxData(ptr noundef %83, ptr noundef %84)
  store ptr %85, ptr %5, align 8, !tbaa !5
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = icmp eq ptr %86, null
  br i1 %87, label %88, label %90

88:                                               ; preds = %72
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %89)
  store i64 -9223372036854775799, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %129

90:                                               ; preds = %72
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.NET_BUF, ptr %91, i32 0, i32 2
  %93 = call ptr @RemoveEntryList(ptr noundef %92)
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %94)
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %95, ptr %6, align 8, !tbaa !5
  br label %96

96:                                               ; preds = %90, %49
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct._IP6_PROTOCOL, ptr %97, i32 0, i32 11
  %99 = call i64 @EfiAcquireLockOrFail(ptr noundef %98)
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct._IP6_PROTOCOL, ptr %100, i32 0, i32 10
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.IP6_RXDATA_WRAP, ptr %102, i32 0, i32 0
  %104 = call ptr @InsertHeadList(ptr noundef %101, ptr noundef %103)
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct._IP6_PROTOCOL, ptr %105, i32 0, i32 11
  call void @EfiReleaseLock(ptr noundef %106)
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._IP6_PROTOCOL, ptr %107, i32 0, i32 7
  %109 = call ptr @NetMapRemoveHead(ptr noundef %108, ptr noundef null)
  store ptr %109, ptr %4, align 8, !tbaa !5
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.NET_BUF, ptr %110, i32 0, i32 6
  %112 = getelementptr inbounds [64 x i8], ptr %111, i64 0, i64 0
  %113 = getelementptr inbounds %struct.IP6_CLIP_INFO, ptr %112, i32 0, i32 6
  %114 = load i64, ptr %113, align 8, !tbaa !25
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.EFI_IP6_COMPLETION_TOKEN, ptr %115, i32 0, i32 1
  store i64 %114, ptr %116, align 8, !tbaa !28
  %117 = load ptr, ptr %5, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.IP6_RXDATA_WRAP, ptr %117, i32 0, i32 3
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.EFI_IP6_COMPLETION_TOKEN, ptr %119, i32 0, i32 2
  store ptr %118, ptr %120, align 8, !tbaa !24
  %121 = load ptr, ptr @gBS, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %121, i32 0, i32 11
  %123 = load ptr, ptr %122, align 8, !tbaa !30
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.EFI_IP6_COMPLETION_TOKEN, ptr %124, i32 0, i32 0
  %126 = load ptr, ptr %125, align 8, !tbaa !33
  %127 = call i64 %123(ptr noundef %126)
  br label %10, !llvm.loop !34

128:                                              ; preds = %21
  store i64 0, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %129

129:                                              ; preds = %128, %88, %58, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %130 = load i64, ptr %2, align 8
  ret i64 %130
}

declare zeroext i8 @IsListEmpty(ptr noundef) #1

declare zeroext i8 @NetMapIsEmpty(ptr noundef) #1

declare ptr @NetMapRemoveHead(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 208}
!10 = !{!"_IP6_PROTOCOL", !11, i64 0, !12, i64 8, !6, i64 80, !13, i64 88, !6, i64 96, !14, i64 104, !7, i64 120, !15, i64 128, !15, i64 168, !14, i64 208, !14, i64 224, !16, i64 240, !6, i64 264, !14, i64 272, !6, i64 288, !11, i64 296, !17, i64 300, !7, i64 352}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_IP6_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"", !14, i64 0, !14, i64 16, !13, i64 32}
!16 = !{!"", !13, i64 0, !13, i64 8, !11, i64 16}
!17 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !18, i64 4, !18, i64 20, !7, i64 36, !7, i64 37, !11, i64 40, !11, i64 44, !11, i64 48}
!18 = !{!"", !7, i64 0}
!19 = !{!20, !13, i64 8}
!20 = !{!"", !11, i64 0, !13, i64 8, !14, i64 16, !7, i64 32, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !11, i64 128, !11, i64 132, !7, i64 136}
!21 = !{!20, !6, i64 120}
!22 = !{!23, !13, i64 8}
!23 = !{!"", !11, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !7, i64 48}
!24 = !{!7, !7, i64 0}
!25 = !{!26, !13, i64 24}
!26 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !13, i64 24, !11, i64 32, !27, i64 36, !7, i64 38, !7, i64 39, !11, i64 40}
!27 = !{!"short", !7, i64 0}
!28 = !{!29, !13, i64 8}
!29 = !{!"", !6, i64 0, !13, i64 8, !7, i64 16}
!30 = !{!31, !6, i64 104}
!31 = !{!"", !32, i64 0, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!32 = !{!"", !13, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!33 = !{!29, !6, i64 0}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [130 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@gBS = external local_unnamed_addr global ptr, align 8

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

declare ptr @RemoveEntryList(ptr noundef) local_unnamed_addr #0

declare void @NetbufFree(ptr noundef) local_unnamed_addr #0

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare i32 @NetbufTrim(ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #0

declare ptr @InsertHeadList(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @NetbufDuplicate(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare ptr @NetbufAllocSpace(ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #0

declare i64 @EfiAcquireLockOrFail(ptr noundef) local_unnamed_addr #0

declare void @EfiReleaseLock(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @Ip6WrapRxData(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775799, 1) i64 @Ip6InstanceDeliverPacket(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 208
  %3 = tail call zeroext i8 @IsListEmpty(ptr noundef nonnull %2) #2
  %.not42 = icmp eq i8 %3, 0
  br i1 %.not42, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 128
  %5 = getelementptr inbounds i8, ptr %0, i64 240
  %6 = getelementptr inbounds i8, ptr %0, i64 224
  br label %7

7:                                                ; preds = %.lr.ph, %50
  %8 = tail call zeroext i8 @NetMapIsEmpty(ptr noundef nonnull %4) #2
  %.not41 = icmp eq i8 %8, 0
  br i1 %.not41, label %9, label %.critedge

9:                                                ; preds = %7
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = ptrtoint ptr %10 to i64
  %12 = add i64 %11, -16
  %13 = inttoptr i64 %12 to ptr
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !18
  %16 = icmp sgt i64 %15, 1
  br i1 %16, label %29, label %17

17:                                               ; preds = %9
  %18 = getelementptr inbounds i8, ptr %13, i64 120
  %19 = load ptr, ptr %18, align 8, !tbaa !20
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !21
  %22 = icmp sgt i64 %21, 1
  br i1 %22, label %29, label %23

23:                                               ; preds = %17
  %24 = tail call ptr @Ip6WrapRxData(ptr noundef nonnull %0, ptr noundef nonnull %13)
  %25 = icmp eq ptr %24, null
  br i1 %25, label %.critedge, label %26

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %13, i64 16
  %28 = tail call ptr @RemoveEntryList(ptr noundef nonnull %27) #2
  br label %50

29:                                               ; preds = %17, %9
  %30 = tail call ptr @NetbufDuplicate(ptr noundef nonnull %13, ptr noundef null, i32 noundef 40) #2
  %31 = icmp eq ptr %30, null
  br i1 %31, label %.critedge, label %32

32:                                               ; preds = %29
  %33 = tail call ptr @NetbufAllocSpace(ptr noundef nonnull %30, i32 noundef 40, i8 noundef zeroext 1) #2
  %34 = tail call zeroext i8 @DebugAssertEnabled() #2
  %35 = icmp eq i8 %34, 0
  %36 = icmp ne ptr %33, null
  %or.cond = select i1 %35, i1 true, i1 %36
  br i1 %or.cond, label %38, label %37

37:                                               ; preds = %32
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1520, ptr noundef nonnull @.str.3) #2
  br label %38

38:                                               ; preds = %37, %32
  %39 = getelementptr inbounds i8, ptr %30, i64 32
  store ptr %33, ptr %39, align 8, !tbaa !23
  %40 = getelementptr inbounds i8, ptr %13, i64 32
  %41 = load ptr, ptr %40, align 8, !tbaa !23
  %42 = tail call ptr @CopyMem(ptr noundef %33, ptr noundef %41, i64 noundef 40) #2
  %43 = tail call i32 @NetbufTrim(ptr noundef nonnull %30, i32 noundef 40, i8 noundef zeroext 1) #2
  %44 = tail call ptr @Ip6WrapRxData(ptr noundef nonnull %0, ptr noundef nonnull %30)
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %47

46:                                               ; preds = %38
  tail call void @NetbufFree(ptr noundef nonnull %30) #2
  br label %.critedge

47:                                               ; preds = %38
  %48 = getelementptr inbounds i8, ptr %13, i64 16
  %49 = tail call ptr @RemoveEntryList(ptr noundef nonnull %48) #2
  tail call void @NetbufFree(ptr noundef nonnull %13) #2
  br label %50

50:                                               ; preds = %47, %26
  %.037 = phi ptr [ %30, %47 ], [ %13, %26 ]
  %.036 = phi ptr [ %44, %47 ], [ %24, %26 ]
  %51 = tail call i64 @EfiAcquireLockOrFail(ptr noundef nonnull %5) #2
  %52 = tail call ptr @InsertHeadList(ptr noundef nonnull %6, ptr noundef nonnull %.036) #2
  tail call void @EfiReleaseLock(ptr noundef nonnull %5) #2
  %53 = tail call ptr @NetMapRemoveHead(ptr noundef nonnull %4, ptr noundef null) #2
  %54 = getelementptr inbounds i8, ptr %.037, i64 80
  %55 = load i64, ptr %54, align 8, !tbaa !24
  %56 = getelementptr inbounds i8, ptr %53, i64 8
  store i64 %55, ptr %56, align 8, !tbaa !27
  %57 = getelementptr inbounds i8, ptr %.036, i64 32
  %58 = getelementptr inbounds i8, ptr %53, i64 16
  store ptr %57, ptr %58, align 8, !tbaa !23
  %59 = load ptr, ptr @gBS, align 8, !tbaa !29
  %60 = getelementptr inbounds i8, ptr %59, i64 104
  %61 = load ptr, ptr %60, align 8, !tbaa !30
  %62 = load ptr, ptr %53, align 8, !tbaa !33
  %63 = tail call i64 %61(ptr noundef %62) #2
  %64 = tail call zeroext i8 @IsListEmpty(ptr noundef nonnull %2) #2
  %.not = icmp eq i8 %64, 0
  br i1 %.not, label %7, label %.critedge, !llvm.loop !34

.critedge:                                        ; preds = %23, %29, %50, %7, %1, %46
  %.0 = phi i64 [ -9223372036854775799, %46 ], [ 0, %1 ], [ -9223372036854775799, %23 ], [ -9223372036854775799, %29 ], [ 0, %50 ], [ 0, %7 ]
  ret i64 %.0
}

declare zeroext i8 @IsListEmpty(ptr noundef) local_unnamed_addr #0

declare zeroext i8 @NetMapIsEmpty(ptr noundef) local_unnamed_addr #0

declare ptr @NetMapRemoveHead(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !11, i64 208}
!6 = !{!"_IP6_PROTOCOL", !7, i64 0, !10, i64 8, !11, i64 80, !12, i64 88, !11, i64 96, !13, i64 104, !8, i64 120, !14, i64 128, !14, i64 168, !13, i64 208, !13, i64 224, !15, i64 240, !11, i64 264, !13, i64 272, !11, i64 288, !7, i64 296, !16, i64 300, !8, i64 352}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_EFI_IP6_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!14 = !{!"", !13, i64 0, !13, i64 16, !12, i64 32}
!15 = !{!"", !12, i64 0, !12, i64 8, !7, i64 16}
!16 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !17, i64 4, !17, i64 20, !8, i64 36, !8, i64 37, !7, i64 40, !7, i64 44, !7, i64 48}
!17 = !{!"", !8, i64 0}
!18 = !{!19, !12, i64 8}
!19 = !{!"", !7, i64 0, !12, i64 8, !13, i64 16, !8, i64 32, !11, i64 40, !11, i64 48, !8, i64 56, !11, i64 120, !7, i64 128, !7, i64 132, !8, i64 136}
!20 = !{!19, !11, i64 120}
!21 = !{!22, !12, i64 8}
!22 = !{!"", !7, i64 0, !12, i64 8, !11, i64 16, !11, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !8, i64 48}
!23 = !{!8, !8, i64 0}
!24 = !{!25, !12, i64 24}
!25 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !12, i64 24, !7, i64 32, !26, i64 36, !8, i64 38, !8, i64 39, !7, i64 40}
!26 = !{!"short", !8, i64 0}
!27 = !{!28, !12, i64 8}
!28 = !{!"", !11, i64 0, !12, i64 8, !8, i64 16}
!29 = !{!11, !11, i64 0}
!30 = !{!31, !11, i64 104}
!31 = !{!"", !32, i64 0, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !11, i64 184, !11, i64 192, !11, i64 200, !11, i64 208, !11, i64 216, !11, i64 224, !11, i64 232, !11, i64 240, !11, i64 248, !11, i64 256, !11, i64 264, !11, i64 272, !11, i64 280, !11, i64 288, !11, i64 296, !11, i64 304, !11, i64 312, !11, i64 320, !11, i64 328, !11, i64 336, !11, i64 344, !11, i64 352, !11, i64 360, !11, i64 368}
!32 = !{!"", !12, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!33 = !{!28, !11, i64 0}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass