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

; 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.MNP_INSTANCE_DATA = type { i32, ptr, ptr, %struct._LIST_ENTRY, %struct._EFI_MANAGED_NETWORK_PROTOCOL, i8, i8, %struct._LIST_ENTRY, %struct.NET_MAP, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i64, %struct.EFI_MANAGED_NETWORK_CONFIG_DATA, i8 }
%struct._EFI_MANAGED_NETWORK_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.NET_MAP = type { %struct._LIST_ENTRY, %struct._LIST_ENTRY, i64 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_MANAGED_NETWORK_CONFIG_DATA = type { i32, i32, i16, i8, i8, i8, i8, i8, i8, i8 }
%struct.EFI_MANAGED_NETWORK_RECEIVE_DATA = type { %struct.EFI_TIME, ptr, i32, i32, i32, i32, i8, i8, i8, i16, ptr, ptr, ptr, ptr }
%struct.EFI_TIME = type { i16, i8, i8, i8, i8, i8, i8, i32, i16, i8, i8 }
%struct.MNP_GROUP_CONTROL_BLOCK = type { %struct._LIST_ENTRY, ptr }

@.str = external hidden unnamed_addr constant [147 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [29 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

declare zeroext i8 @DebugAssertEnabled() #1

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

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

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

14:                                               ; preds = %4
  %15 = call zeroext i8 @DebugAssertEnabled()
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %17, label %27

17:                                               ; preds = %14
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %25

20:                                               ; preds = %17
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.MNP_INSTANCE_DATA, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !10
  %24 = icmp eq i32 %23, 1232105037
  br i1 %24, label %26, label %25

25:                                               ; preds = %20, %17
  call void @DebugAssert(ptr noundef @.str, i64 noundef 572, ptr noundef @.str.11)
  br label %26

26:                                               ; preds = %25, %20
  br label %27

27:                                               ; preds = %26, %14
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.MNP_INSTANCE_DATA, ptr %30, i32 0, i32 12
  store ptr %31, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.EFI_MANAGED_NETWORK_CONFIG_DATA, ptr %32, i32 0, i32 2
  %34 = load i16, ptr %33, align 4, !tbaa !19
  %35 = zext i16 %34 to i32
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %48

37:                                               ; preds = %29
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.EFI_MANAGED_NETWORK_CONFIG_DATA, ptr %38, i32 0, i32 2
  %40 = load i16, ptr %39, align 4, !tbaa !19
  %41 = zext i16 %40 to i32
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.EFI_MANAGED_NETWORK_RECEIVE_DATA, ptr %42, i32 0, i32 9
  %44 = load i16, ptr %43, align 4, !tbaa !20
  %45 = zext i16 %44 to i32
  %46 = icmp ne i32 %41, %45
  br i1 %46, label %47, label %48

47:                                               ; preds = %37
  store i8 0, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %115

48:                                               ; preds = %37, %29
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.EFI_MANAGED_NETWORK_CONFIG_DATA, ptr %49, i32 0, i32 6
  %51 = load i8, ptr %50, align 1, !tbaa !23
  %52 = icmp ne i8 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  store i8 1, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %115

54:                                               ; preds = %48
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MNP_INSTANCE_DATA, ptr %55, i32 0, i32 13
  %57 = load i8, ptr %56, align 4, !tbaa !24
  %58 = zext i8 %57 to i32
  %59 = load i8, ptr %9, align 1, !tbaa !9
  %60 = zext i8 %59 to i32
  %61 = and i32 %58, %60
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %54
  store i8 1, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %115

64:                                               ; preds = %54
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.EFI_MANAGED_NETWORK_CONFIG_DATA, ptr %65, i32 0, i32 4
  %67 = load i8, ptr %66, align 1, !tbaa !25
  %68 = zext i8 %67 to i32
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %114

70:                                               ; preds = %64
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.EFI_MANAGED_NETWORK_RECEIVE_DATA, ptr %71, i32 0, i32 7
  %73 = load i8, ptr %72, align 1, !tbaa !26
  %74 = zext i8 %73 to i32
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %114

76:                                               ; preds = %70
  br label %77

77:                                               ; preds = %76
  %78 = call zeroext i8 @DebugAssertEnabled()
  %79 = icmp ne i8 %78, 0
  br i1 %79, label %80, label %85

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

83:                                               ; preds = %80
  call void @DebugAssert(ptr noundef @.str, i64 noundef 602, ptr noundef @.str.16)
  br label %84

84:                                               ; preds = %83, %80
  br label %85

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

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.MNP_INSTANCE_DATA, ptr %88, i32 0, i32 7
  %90 = getelementptr inbounds %struct._LIST_ENTRY, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !27
  store ptr %91, ptr %11, align 8, !tbaa !5
  br label %92

92:                                               ; preds = %109, %87
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.MNP_INSTANCE_DATA, ptr %94, i32 0, i32 7
  %96 = icmp ne ptr %93, %95
  br i1 %96, label %97, label %113

97:                                               ; preds = %92
  %98 = load ptr, ptr %11, align 8, !tbaa !5
  %99 = ptrtoint ptr %98 to i64
  %100 = sub i64 %99, 0
  %101 = inttoptr i64 %100 to ptr
  store ptr %101, ptr %12, align 8, !tbaa !5
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.MNP_GROUP_CONTROL_BLOCK, ptr %102, i32 0, i32 1
  %104 = load ptr, ptr %103, align 8, !tbaa !28
  %105 = load ptr, ptr %8, align 8, !tbaa !5
  %106 = icmp eq ptr %104, %105
  br i1 %106, label %107, label %108

107:                                              ; preds = %97
  store i8 1, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %115

108:                                              ; preds = %97
  br label %109

109:                                              ; preds = %108
  %110 = load ptr, ptr %11, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct._LIST_ENTRY, ptr %110, i32 0, i32 0
  %112 = load ptr, ptr %111, align 8, !tbaa !30
  store ptr %112, ptr %11, align 8, !tbaa !5
  br label %92, !llvm.loop !31

113:                                              ; preds = %92
  br label %114

114:                                              ; preds = %113, %70, %64
  store i8 0, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %115

115:                                              ; preds = %114, %107, %63, %53, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %116 = load i8, ptr %5, align 1
  ret i8 %116
}

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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"", !12, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 40, !7, i64 104, !7, i64 105, !13, i64 112, !15, i64 128, !13, i64 168, !13, i64 184, !16, i64 200, !17, i64 208, !7, i64 228}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!"_EFI_MANAGED_NETWORK_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}
!15 = !{!"", !13, i64 0, !13, i64 16, !16, i64 32}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"", !12, i64 0, !12, i64 4, !18, i64 8, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16}
!18 = !{!"short", !7, i64 0}
!19 = !{!17, !18, i64 8}
!20 = !{!21, !18, i64 44}
!21 = !{!"", !22, i64 0, !6, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !7, i64 40, !7, i64 41, !7, i64 42, !18, i64 44, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!22 = !{!"", !18, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !12, i64 8, !18, i64 12, !7, i64 14, !7, i64 15}
!23 = !{!17, !7, i64 13}
!24 = !{!11, !7, i64 228}
!25 = !{!17, !7, i64 11}
!26 = !{!21, !7, i64 41}
!27 = !{!11, !6, i64 112}
!28 = !{!29, !6, i64 16}
!29 = !{!"", !13, i64 0, !6, i64 16}
!30 = !{!13, !6, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"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 [147 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [29 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @MnpMatchPacket(ptr noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef readnone %2, i8 noundef zeroext %3) local_unnamed_addr #1 {
  %5 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %11, label %6

6:                                                ; preds = %4
  %.not23 = icmp eq ptr %0, null
  br i1 %.not23, label %10, label %7

7:                                                ; preds = %6
  %8 = load i32, ptr %0, align 8, !tbaa !5
  %9 = icmp eq i32 %8, 1232105037
  br i1 %9, label %11, label %10

10:                                               ; preds = %7, %6
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 572, ptr noundef nonnull @.str.11) #2
  br label %11

11:                                               ; preds = %7, %10, %4
  %12 = getelementptr inbounds i8, ptr %0, i64 216
  %13 = load i16, ptr %12, align 4, !tbaa !17
  %.not24 = icmp eq i16 %13, 0
  br i1 %.not24, label %17, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %1, i64 44
  %16 = load i16, ptr %15, align 4, !tbaa !18
  %.not25 = icmp eq i16 %13, %16
  br i1 %.not25, label %17, label %.loopexit

17:                                               ; preds = %14, %11
  %18 = getelementptr inbounds i8, ptr %0, i64 221
  %19 = load i8, ptr %18, align 1, !tbaa !21
  %.not26 = icmp eq i8 %19, 0
  br i1 %.not26, label %20, label %.loopexit

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %0, i64 228
  %22 = load i8, ptr %21, align 4, !tbaa !22
  %23 = and i8 %22, %3
  %.not27 = icmp eq i8 %23, 0
  br i1 %.not27, label %24, label %.loopexit

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %0, i64 219
  %26 = load i8, ptr %25, align 1, !tbaa !23
  %.not28 = icmp eq i8 %26, 0
  br i1 %.not28, label %.loopexit, label %27

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %1, i64 41
  %29 = load i8, ptr %28, align 1, !tbaa !24
  %.not29 = icmp eq i8 %29, 0
  br i1 %.not29, label %.loopexit, label %30

30:                                               ; preds = %27
  %31 = tail call zeroext i8 @DebugAssertEnabled() #2
  %32 = icmp eq i8 %31, 0
  %33 = icmp ne ptr %2, null
  %or.cond = or i1 %33, %32
  br i1 %or.cond, label %35, label %34

34:                                               ; preds = %30
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 602, ptr noundef nonnull @.str.16) #2
  br label %35

35:                                               ; preds = %34, %30
  %36 = getelementptr inbounds i8, ptr %0, i64 112
  br label %37

37:                                               ; preds = %38, %35
  %.020.in = phi ptr [ %36, %35 ], [ %.020, %38 ]
  %.020 = load ptr, ptr %.020.in, align 8, !tbaa !25
  %.not30 = icmp eq ptr %.020, %36
  br i1 %.not30, label %.loopexit, label %38

38:                                               ; preds = %37
  %39 = getelementptr inbounds i8, ptr %.020, i64 16
  %40 = load ptr, ptr %39, align 8, !tbaa !26
  %41 = icmp eq ptr %40, %2
  br i1 %41, label %.loopexit, label %37, !llvm.loop !28

.loopexit:                                        ; preds = %37, %38, %24, %27, %20, %17, %14
  %.0 = phi i8 [ 0, %14 ], [ 1, %17 ], [ 1, %20 ], [ 0, %27 ], [ 0, %24 ], [ 0, %37 ], [ 1, %38 ]
  ret i8 %.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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !12, i64 40, !8, i64 104, !8, i64 105, !11, i64 112, !13, i64 128, !11, i64 168, !11, i64 184, !14, i64 200, !15, i64 208, !8, i64 228}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}
!12 = !{!"_EFI_MANAGED_NETWORK_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!13 = !{!"", !11, i64 0, !11, i64 16, !14, i64 32}
!14 = !{!"long long", !8, i64 0}
!15 = !{!"", !7, i64 0, !7, i64 4, !16, i64 8, !8, i64 10, !8, i64 11, !8, i64 12, !8, i64 13, !8, i64 14, !8, i64 15, !8, i64 16}
!16 = !{!"short", !8, i64 0}
!17 = !{!15, !16, i64 8}
!18 = !{!19, !16, i64 44}
!19 = !{!"", !20, i64 0, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !8, i64 40, !8, i64 41, !8, i64 42, !16, i64 44, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!20 = !{!"", !16, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7, !7, i64 8, !16, i64 12, !8, i64 14, !8, i64 15}
!21 = !{!15, !8, i64 13}
!22 = !{!6, !8, i64 228}
!23 = !{!15, !8, i64 11}
!24 = !{!19, !8, i64 41}
!25 = !{!11, !10, i64 0}
!26 = !{!27, !10, i64 16}
!27 = !{!"", !11, i64 0, !10, i64 16}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass