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

; 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.MNP_SERVICE_DATA = type { i32, %struct._LIST_ENTRY, ptr, ptr, %struct._EFI_SERVICE_BINDING_PROTOCOL, ptr, %struct._LIST_ENTRY, i64, i32, i16, i8 }
%struct._EFI_SERVICE_BINDING_PROTOCOL = type { ptr, ptr }
%struct.MNP_DEVICE_DATA = type { i32, ptr, ptr, %struct._EFI_VLAN_CONFIG_PROTOCOL, i64, ptr, ptr, %struct._LIST_ENTRY, i64, %struct._LIST_ENTRY, i32, ptr, %struct.NET_BUF_QUEUE, i64, ptr, i8, ptr, ptr, i32, i32, i32, i32, i32, i32, ptr, ptr }
%struct._EFI_VLAN_CONFIG_PROTOCOL = type { ptr, ptr, ptr }
%struct.NET_BUF_QUEUE = type { i32, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32 }
%struct.MNP_GROUP_CONTROL_BLOCK = type { %struct._LIST_ENTRY, ptr }
%struct.MNP_GROUP_ADDRESS = type { %struct._LIST_ENTRY, %struct.EFI_MAC_ADDRESS, i64 }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }

@.str = external hidden unnamed_addr constant [151 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [125 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [25 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

declare void @FreePool(ptr noundef) #1

declare ptr @RemoveEntryList(ptr noundef) #1

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

9:                                                ; preds = %2
  %10 = call zeroext i8 @DebugAssertEnabled()
  %11 = icmp ne i8 %10, 0
  br i1 %11, label %12, label %22

12:                                               ; preds = %9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %20

15:                                               ; preds = %12
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.MNP_INSTANCE_DATA, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = icmp eq i32 %18, 1232105037
  br i1 %19, label %21, label %20

20:                                               ; preds = %15, %12
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1587, ptr noundef @.str.25)
  br label %21

21:                                               ; preds = %20, %15
  br label %22

22:                                               ; preds = %21, %9
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.MNP_INSTANCE_DATA, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %28 = getelementptr inbounds %struct.MNP_SERVICE_DATA, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !19
  store ptr %29, ptr %6, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %24
  %31 = call zeroext i8 @DebugAssertEnabled()
  %32 = icmp ne i8 %31, 0
  br i1 %32, label %33, label %43

33:                                               ; preds = %30
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %41

36:                                               ; preds = %33
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !22
  %40 = icmp eq i32 %39, 1148218957
  br i1 %40, label %42, label %41

41:                                               ; preds = %36, %33
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1590, ptr noundef @.str.1)
  br label %42

42:                                               ; preds = %41, %36
  br label %43

43:                                               ; preds = %42, %30
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.MNP_GROUP_CONTROL_BLOCK, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !26
  store ptr %48, ptr %7, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.MNP_GROUP_CONTROL_BLOCK, ptr %49, i32 0, i32 0
  %51 = call ptr @RemoveEntryList(ptr noundef %50)
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  call void @FreePool(ptr noundef %52)
  br label %53

53:                                               ; preds = %45
  %54 = call zeroext i8 @DebugAssertEnabled()
  %55 = icmp ne i8 %54, 0
  br i1 %55, label %56, label %63

56:                                               ; preds = %53
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.MNP_GROUP_ADDRESS, ptr %57, i32 0, i32 2
  %59 = load i64, ptr %58, align 8, !tbaa !28
  %60 = icmp sgt i64 %59, 0
  br i1 %60, label %62, label %61

61:                                               ; preds = %56
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1599, ptr noundef @.str.32)
  br label %62

62:                                               ; preds = %61, %56
  br label %63

63:                                               ; preds = %62, %53
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.MNP_GROUP_ADDRESS, ptr %66, i32 0, i32 2
  %68 = load i64, ptr %67, align 8, !tbaa !28
  %69 = add nsw i64 %68, -1
  store i64 %69, ptr %67, align 8, !tbaa !28
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.MNP_GROUP_ADDRESS, ptr %70, i32 0, i32 2
  %72 = load i64, ptr %71, align 8, !tbaa !28
  %73 = icmp eq i64 %72, 0
  br i1 %73, label %74, label %83

74:                                               ; preds = %65
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %75, i32 0, i32 10
  %77 = load i32, ptr %76, align 8, !tbaa !31
  %78 = add i32 %77, -1
  store i32 %78, ptr %76, align 8, !tbaa !31
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.MNP_GROUP_ADDRESS, ptr %79, i32 0, i32 0
  %81 = call ptr @RemoveEntryList(ptr noundef %80)
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  call void @FreePool(ptr noundef %82)
  store i8 1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %84

83:                                               ; preds = %65
  store i8 0, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %84

84:                                               ; preds = %83, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %85 = load i8, ptr %3, align 1
  ret i8 %85
}

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, !11, i64 0}
!10 = !{!"", !11, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !13, i64 40, !7, i64 104, !7, i64 105, !12, i64 112, !14, i64 128, !12, i64 168, !12, i64 184, !15, i64 200, !16, i64 208, !7, i64 228}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!13 = !{!"_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}
!14 = !{!"", !12, i64 0, !12, i64 16, !15, i64 32}
!15 = !{!"long long", !7, i64 0}
!16 = !{!"", !11, i64 0, !11, i64 4, !17, i64 8, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16}
!17 = !{!"short", !7, i64 0}
!18 = !{!10, !6, i64 8}
!19 = !{!20, !6, i64 24}
!20 = !{!"", !11, i64 0, !12, i64 8, !6, i64 24, !6, i64 32, !21, i64 40, !6, i64 56, !12, i64 64, !15, i64 80, !11, i64 88, !17, i64 92, !7, i64 94}
!21 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!22 = !{!23, !11, i64 0}
!23 = !{!"", !11, i64 0, !6, i64 8, !6, i64 16, !24, i64 24, !15, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !15, i64 88, !12, i64 96, !11, i64 112, !6, i64 120, !25, i64 128, !15, i64 184, !6, i64 192, !7, i64 200, !6, i64 208, !6, i64 216, !11, i64 224, !11, i64 228, !11, i64 232, !11, i64 236, !11, i64 240, !11, i64 244, !6, i64 248, !6, i64 256}
!24 = !{!"_EFI_VLAN_CONFIG_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!"", !11, i64 0, !15, i64 8, !12, i64 16, !12, i64 32, !11, i64 48, !11, i64 52}
!26 = !{!27, !6, i64 16}
!27 = !{!"", !12, i64 0, !6, i64 16}
!28 = !{!29, !15, i64 48}
!29 = !{!"", !12, i64 0, !30, i64 16, !15, i64 48}
!30 = !{!"", !7, i64 0}
!31 = !{!23, !11, i64 112}


; 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 [151 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [125 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [25 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

declare void @FreePool(ptr noundef) local_unnamed_addr #0

declare ptr @RemoveEntryList(ptr noundef) local_unnamed_addr #0

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

4:                                                ; preds = %2
  %.not16 = icmp eq ptr %0, null
  br i1 %.not16, label %8, label %5

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

8:                                                ; preds = %5, %4
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1587, ptr noundef nonnull @.str.25) #2
  br label %9

9:                                                ; preds = %5, %8, %2
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  %13 = load ptr, ptr %12, align 8, !tbaa !18
  %14 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not17 = icmp eq i8 %14, 0
  br i1 %.not17, label %20, label %15

15:                                               ; preds = %9
  %.not18 = icmp eq ptr %13, null
  br i1 %.not18, label %19, label %16

16:                                               ; preds = %15
  %17 = load i32, ptr %13, align 8, !tbaa !21
  %18 = icmp eq i32 %17, 1148218957
  br i1 %18, label %20, label %19

19:                                               ; preds = %16, %15
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1590, ptr noundef nonnull @.str.1) #2
  br label %20

20:                                               ; preds = %16, %19, %9
  %21 = getelementptr inbounds i8, ptr %1, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !25
  %23 = tail call ptr @RemoveEntryList(ptr noundef %1) #2
  tail call void @FreePool(ptr noundef %1) #2
  %24 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not19 = icmp eq i8 %24, 0
  br i1 %.not19, label %30, label %25

25:                                               ; preds = %20
  %26 = getelementptr inbounds i8, ptr %22, i64 48
  %27 = load i64, ptr %26, align 8, !tbaa !27
  %28 = icmp sgt i64 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1599, ptr noundef nonnull @.str.32) #2
  br label %30

30:                                               ; preds = %25, %29, %20
  %31 = getelementptr inbounds i8, ptr %22, i64 48
  %32 = load i64, ptr %31, align 8, !tbaa !27
  %33 = add nsw i64 %32, -1
  store i64 %33, ptr %31, align 8, !tbaa !27
  %34 = icmp eq i64 %33, 0
  br i1 %34, label %35, label %40

35:                                               ; preds = %30
  %36 = getelementptr inbounds i8, ptr %13, i64 112
  %37 = load i32, ptr %36, align 8, !tbaa !30
  %38 = add i32 %37, -1
  store i32 %38, ptr %36, align 8, !tbaa !30
  %39 = tail call ptr @RemoveEntryList(ptr noundef nonnull %22) #2
  tail call void @FreePool(ptr noundef nonnull %22) #2
  br label %40

40:                                               ; preds = %30, %35
  %.0 = phi i8 [ 1, %35 ], [ 0, %30 ]
  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 = !{!6, !10, i64 8}
!18 = !{!19, !10, i64 24}
!19 = !{!"", !7, i64 0, !11, i64 8, !10, i64 24, !10, i64 32, !20, i64 40, !10, i64 56, !11, i64 64, !14, i64 80, !7, i64 88, !16, i64 92, !8, i64 94}
!20 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !10, i64 0, !10, i64 8}
!21 = !{!22, !7, i64 0}
!22 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !23, i64 24, !14, i64 48, !10, i64 56, !10, i64 64, !11, i64 72, !14, i64 88, !11, i64 96, !7, i64 112, !10, i64 120, !24, i64 128, !14, i64 184, !10, i64 192, !8, i64 200, !10, i64 208, !10, i64 216, !7, i64 224, !7, i64 228, !7, i64 232, !7, i64 236, !7, i64 240, !7, i64 244, !10, i64 248, !10, i64 256}
!23 = !{!"_EFI_VLAN_CONFIG_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16}
!24 = !{!"", !7, i64 0, !14, i64 8, !11, i64 16, !11, i64 32, !7, i64 48, !7, i64 52}
!25 = !{!26, !10, i64 16}
!26 = !{!"", !11, i64 0, !10, i64 16}
!27 = !{!28, !14, i64 48}
!28 = !{!"", !11, i64 0, !29, i64 16, !14, i64 48}
!29 = !{!"", !8, i64 0}
!30 = !{!22, !7, i64 112}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass