; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal (Ip4InstanceDeliverPacket)

; 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._IP4_PROTOCOL = type { i32, %struct._EFI_IP4_PROTOCOL, ptr, i64, ptr, %struct._LIST_ENTRY, %struct.NET_MAP, %struct.NET_MAP, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct.EFI_LOCK, ptr, %struct._LIST_ENTRY, ptr, ptr, i32, ptr, i32, %struct.EFI_IP4_CONFIG_DATA }
%struct._EFI_IP4_PROTOCOL = type { 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_IP4_CONFIG_DATA = type { i8, i8, i8, i8, i8, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i8, i8, i8, i8, i32, i32 }
%struct.EFI_IPv4_ADDRESS = type { [4 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.IP4_RXDATA_WRAP = type { %struct._LIST_ENTRY, ptr, ptr, %struct.EFI_IP4_RECEIVE_DATA }
%struct.EFI_IP4_RECEIVE_DATA = type { %struct.EFI_TIME, ptr, i32, ptr, i32, ptr, i32, i32, [1 x %struct.EFI_IP4_FRAGMENT_DATA] }
%struct.EFI_TIME = type { i16, i8, i8, i8, i8, i8, i8, i32, i16, i8, i8 }
%struct.EFI_IP4_FRAGMENT_DATA = type { i32, ptr }
%struct.IP4_CLIP_INFO = type { i64, i64, i64, i64, i64, i32, i64 }
%struct.EFI_IP4_COMPLETION_TOKEN = type { ptr, i64, %union.anon }
%union.anon = 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 [150 x i8], align 1
@gBS = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1

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

; 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 @CopyMem(ptr noundef, ptr noundef, i64 noundef) #1

declare i64 @EfiAcquireLockOrFail(ptr noundef) #1

declare void @EfiReleaseLock(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i64 @Ip4InstanceDeliverPacket(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
  %10 = 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  br label %11

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

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

22:                                               ; preds = %16, %11
  %23 = phi i1 [ false, %11 ], [ %21, %16 ]
  br i1 %23, label %24, label %153

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

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

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

49:                                               ; preds = %43
  store i64 -9223372036854775799, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %154

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

54:                                               ; preds = %36, %24
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %55, i32 0, i32 18
  %57 = getelementptr inbounds %struct.EFI_IP4_CONFIG_DATA, ptr %56, i32 0, i32 11
  %58 = load i8, ptr %57, align 1, !tbaa !24
  %59 = icmp ne i8 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %54
  store i32 0, ptr %9, align 4, !tbaa !25
  br label %62

61:                                               ; preds = %54
  store i32 60, ptr %9, align 4, !tbaa !25
  br label %62

62:                                               ; preds = %61, %60
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load i32, ptr %9, align 4, !tbaa !25
  %65 = call ptr @NetbufDuplicate(ptr noundef %63, ptr noundef null, i32 noundef %64)
  store ptr %65, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = icmp eq ptr %66, null
  br i1 %67, label %68, label %69

68:                                               ; preds = %62
  store i64 -9223372036854775799, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %154

69:                                               ; preds = %62
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %70, i32 0, i32 18
  %72 = getelementptr inbounds %struct.EFI_IP4_CONFIG_DATA, ptr %71, i32 0, i32 11
  %73 = load i8, ptr %72, align 1, !tbaa !24
  %74 = icmp ne i8 %73, 0
  br i1 %74, label %107, label %75

75:                                               ; preds = %69
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = call ptr @NetbufAllocSpace(ptr noundef %76, i32 noundef 60, i8 noundef zeroext 1)
  store ptr %77, ptr %8, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %75
  %79 = call zeroext i8 @DebugAssertEnabled()
  %80 = icmp ne i8 %79, 0
  br i1 %80, label %81, label %86

81:                                               ; preds = %78
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = icmp ne ptr %82, null
  br i1 %83, label %85, label %84

84:                                               ; preds = %81
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1299, ptr noundef @.str.7)
  br label %85

85:                                               ; preds = %84, %81
  br label %86

86:                                               ; preds = %85, %78
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.NET_BUF, ptr %90, i32 0, i32 3
  store ptr %89, ptr %91, align 8, !tbaa !26
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.NET_BUF, ptr %93, i32 0, i32 3
  %95 = load ptr, ptr %94, align 8, !tbaa !26
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.NET_BUF, ptr %96, i32 0, i32 3
  %98 = load ptr, ptr %97, align 8, !tbaa !26
  %99 = load i8, ptr %98, align 1
  %100 = and i8 %99, 15
  %101 = zext i8 %100 to i32
  %102 = shl i32 %101, 2
  %103 = sext i32 %102 to i64
  %104 = call ptr @CopyMem(ptr noundef %92, ptr noundef %95, i64 noundef %103)
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = call i32 @NetbufTrim(ptr noundef %105, i32 noundef 60, i8 noundef zeroext 1)
  br label %107

107:                                              ; preds = %88, %69
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = call ptr @Ip4WrapRxData(ptr noundef %108, ptr noundef %109)
  store ptr %110, ptr %5, align 8, !tbaa !5
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = icmp eq ptr %111, null
  br i1 %112, label %113, label %115

113:                                              ; preds = %107
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %114)
  store i64 -9223372036854775799, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %154

115:                                              ; preds = %107
  %116 = load ptr, ptr %6, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.NET_BUF, ptr %116, i32 0, i32 2
  %118 = call ptr @RemoveEntryList(ptr noundef %117)
  %119 = load ptr, ptr %6, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %119)
  %120 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %120, ptr %6, align 8, !tbaa !5
  br label %121

121:                                              ; preds = %115, %50
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %122, i32 0, i32 10
  %124 = call i64 @EfiAcquireLockOrFail(ptr noundef %123)
  %125 = load ptr, ptr %3, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %125, i32 0, i32 9
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.IP4_RXDATA_WRAP, ptr %127, i32 0, i32 0
  %129 = call ptr @InsertHeadList(ptr noundef %126, ptr noundef %128)
  %130 = load ptr, ptr %3, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %130, i32 0, i32 10
  call void @EfiReleaseLock(ptr noundef %131)
  %132 = load ptr, ptr %3, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %132, i32 0, i32 6
  %134 = call ptr @NetMapRemoveHead(ptr noundef %133, ptr noundef null)
  store ptr %134, ptr %4, align 8, !tbaa !5
  %135 = load ptr, ptr %6, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.NET_BUF, ptr %135, i32 0, i32 6
  %137 = getelementptr inbounds [64 x i8], ptr %136, i64 0, i64 0
  %138 = getelementptr inbounds %struct.IP4_CLIP_INFO, ptr %137, i32 0, i32 6
  %139 = load i64, ptr %138, align 8, !tbaa !27
  %140 = load ptr, ptr %4, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.EFI_IP4_COMPLETION_TOKEN, ptr %140, i32 0, i32 1
  store i64 %139, ptr %141, align 8, !tbaa !29
  %142 = load ptr, ptr %5, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.IP4_RXDATA_WRAP, ptr %142, i32 0, i32 3
  %144 = load ptr, ptr %4, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.EFI_IP4_COMPLETION_TOKEN, ptr %144, i32 0, i32 2
  store ptr %143, ptr %145, align 8, !tbaa !26
  %146 = load ptr, ptr @gBS, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %146, i32 0, i32 11
  %148 = load ptr, ptr %147, align 8, !tbaa !31
  %149 = load ptr, ptr %4, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.EFI_IP4_COMPLETION_TOKEN, ptr %149, i32 0, i32 0
  %151 = load ptr, ptr %150, align 8, !tbaa !34
  %152 = call i64 %148(ptr noundef %151)
  br label %11, !llvm.loop !35

153:                                              ; preds = %22
  store i64 0, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %154

154:                                              ; preds = %153, %113, %68, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  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
  %155 = load i64, ptr %2, align 8
  ret i64 %155
}

declare zeroext i8 @IsListEmpty(ptr noundef) #1

declare zeroext i8 @NetMapIsEmpty(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 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 192}
!10 = !{!"_IP4_PROTOCOL", !11, i64 0, !12, i64 8, !6, i64 72, !13, i64 80, !6, i64 88, !14, i64 96, !15, i64 112, !15, i64 152, !14, i64 192, !14, i64 208, !16, i64 224, !6, i64 248, !14, i64 256, !6, i64 272, !6, i64 280, !11, i64 288, !6, i64 296, !11, i64 304, !17, i64 308}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_IP4_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}
!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, !7, i64 4, !7, i64 5, !18, i64 6, !18, i64 10, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 17, !11, i64 20, !11, i64 24}
!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 = !{!10, !7, i64 325}
!25 = !{!11, !11, i64 0}
!26 = !{!7, !7, i64 0}
!27 = !{!28, !13, i64 48}
!28 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !11, i64 40, !13, i64 48}
!29 = !{!30, !13, i64 8}
!30 = !{!"", !6, i64 0, !13, i64 8, !7, i64 16}
!31 = !{!32, !6, i64 104}
!32 = !{!"", !33, 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}
!33 = !{!"", !13, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!34 = !{!30, !6, i64 0}
!35 = distinct !{!35, !36}
!36 = !{!"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 [150 x i8], align 1
@gBS = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1

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 @CopyMem(ptr noundef, ptr noundef, i64 noundef) 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 @Ip4WrapRxData(ptr noundef, ptr noundef) local_unnamed_addr #1

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

.lr.ph:                                           ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 112
  %5 = getelementptr inbounds i8, ptr %0, i64 325
  %6 = getelementptr inbounds i8, ptr %0, i64 224
  %7 = getelementptr inbounds i8, ptr %0, i64 208
  br label %8

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

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

18:                                               ; preds = %10
  %19 = getelementptr inbounds i8, ptr %14, i64 120
  %20 = load ptr, ptr %19, align 8, !tbaa !20
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load i64, ptr %21, align 8, !tbaa !21
  %23 = icmp sgt i64 %22, 1
  br i1 %23, label %30, label %24

24:                                               ; preds = %18
  %25 = tail call ptr @Ip4WrapRxData(ptr noundef nonnull %0, ptr noundef nonnull %14)
  %26 = icmp eq ptr %25, null
  br i1 %26, label %.critedge, label %27

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %14, i64 16
  %29 = tail call ptr @RemoveEntryList(ptr noundef nonnull %28) #2
  br label %59

30:                                               ; preds = %18, %10
  %31 = load i8, ptr %5, align 1, !tbaa !23
  %.not47 = icmp eq i8 %31, 0
  %. = select i1 %.not47, i32 60, i32 0
  %32 = tail call ptr @NetbufDuplicate(ptr noundef nonnull %14, ptr noundef null, i32 noundef %.) #2
  %33 = icmp eq ptr %32, null
  br i1 %33, label %.critedge, label %34

34:                                               ; preds = %30
  %35 = load i8, ptr %5, align 1, !tbaa !23
  %.not48 = icmp eq i8 %35, 0
  br i1 %.not48, label %36, label %52

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

41:                                               ; preds = %36
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1299, ptr noundef nonnull @.str.7) #2
  br label %42

42:                                               ; preds = %41, %36
  %43 = getelementptr inbounds i8, ptr %32, i64 32
  store ptr %37, ptr %43, align 8, !tbaa !24
  %44 = getelementptr inbounds i8, ptr %14, i64 32
  %45 = load ptr, ptr %44, align 8, !tbaa !24
  %46 = load i8, ptr %45, align 1
  %47 = shl i8 %46, 2
  %48 = and i8 %47, 60
  %49 = zext nneg i8 %48 to i64
  %50 = tail call ptr @CopyMem(ptr noundef %37, ptr noundef nonnull %45, i64 noundef %49) #2
  %51 = tail call i32 @NetbufTrim(ptr noundef nonnull %32, i32 noundef 60, i8 noundef zeroext 1) #2
  br label %52

52:                                               ; preds = %42, %34
  %53 = tail call ptr @Ip4WrapRxData(ptr noundef nonnull %0, ptr noundef nonnull %32)
  %54 = icmp eq ptr %53, null
  br i1 %54, label %55, label %56

55:                                               ; preds = %52
  tail call void @NetbufFree(ptr noundef nonnull %32) #2
  br label %.critedge

56:                                               ; preds = %52
  %57 = getelementptr inbounds i8, ptr %14, i64 16
  %58 = tail call ptr @RemoveEntryList(ptr noundef nonnull %57) #2
  tail call void @NetbufFree(ptr noundef nonnull %14) #2
  br label %59

59:                                               ; preds = %56, %27
  %.042 = phi ptr [ %32, %56 ], [ %14, %27 ]
  %.041 = phi ptr [ %53, %56 ], [ %25, %27 ]
  %60 = tail call i64 @EfiAcquireLockOrFail(ptr noundef nonnull %6) #2
  %61 = tail call ptr @InsertHeadList(ptr noundef nonnull %7, ptr noundef nonnull %.041) #2
  tail call void @EfiReleaseLock(ptr noundef nonnull %6) #2
  %62 = tail call ptr @NetMapRemoveHead(ptr noundef nonnull %4, ptr noundef null) #2
  %63 = getelementptr inbounds i8, ptr %.042, i64 104
  %64 = load i64, ptr %63, align 8, !tbaa !25
  %65 = getelementptr inbounds i8, ptr %62, i64 8
  store i64 %64, ptr %65, align 8, !tbaa !27
  %66 = getelementptr inbounds i8, ptr %.041, i64 32
  %67 = getelementptr inbounds i8, ptr %62, i64 16
  store ptr %66, ptr %67, align 8, !tbaa !24
  %68 = load ptr, ptr @gBS, align 8, !tbaa !29
  %69 = getelementptr inbounds i8, ptr %68, i64 104
  %70 = load ptr, ptr %69, align 8, !tbaa !30
  %71 = load ptr, ptr %62, align 8, !tbaa !33
  %72 = tail call i64 %70(ptr noundef %71) #2
  %73 = tail call zeroext i8 @IsListEmpty(ptr noundef nonnull %2) #2
  %.not = icmp eq i8 %73, 0
  br i1 %.not, label %8, label %.critedge, !llvm.loop !34

.critedge:                                        ; preds = %24, %30, %59, %8, %1, %55
  %.040 = phi i64 [ -9223372036854775799, %55 ], [ 0, %1 ], [ -9223372036854775799, %24 ], [ -9223372036854775799, %30 ], [ 0, %59 ], [ 0, %8 ]
  ret i64 %.040
}

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

declare zeroext i8 @NetMapIsEmpty(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 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 192}
!6 = !{!"_IP4_PROTOCOL", !7, i64 0, !10, i64 8, !11, i64 72, !12, i64 80, !11, i64 88, !13, i64 96, !14, i64 112, !14, i64 152, !13, i64 192, !13, i64 208, !15, i64 224, !11, i64 248, !13, i64 256, !11, i64 272, !11, i64 280, !7, i64 288, !11, i64 296, !7, i64 304, !16, i64 308}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_EFI_IP4_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 = !{!"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, !8, i64 4, !8, i64 5, !17, i64 6, !17, i64 10, !8, i64 14, !8, i64 15, !8, i64 16, !8, i64 17, !7, i64 20, !7, i64 24}
!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 = !{!6, !8, i64 325}
!24 = !{!8, !8, i64 0}
!25 = !{!26, !12, i64 48}
!26 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !7, i64 40, !12, i64 48}
!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