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

; 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_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._LIST_ENTRY = 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.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 [151 x i8], align 1
@gBS = external global ptr, align 8
@.str.17 = external hidden unnamed_addr constant [127 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [44 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
declare dso_local i64 @MnpStopSnp(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @MnpConfigReceiveFilters(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @MnpStop(ptr noundef %0) #2 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = 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
  br label %7

7:                                                ; preds = %1
  %8 = call zeroext i8 @DebugAssertEnabled()
  %9 = icmp ne i8 %8, 0
  br i1 %9, label %10, label %20

10:                                               ; preds = %7
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %18

13:                                               ; preds = %10
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.MNP_SERVICE_DATA, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = icmp eq i32 %16, 1399877197
  br i1 %17, label %19, label %18

18:                                               ; preds = %13, %10
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1119, ptr noundef @.str.17)
  br label %19

19:                                               ; preds = %18, %13
  br label %20

20:                                               ; preds = %19, %7
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.MNP_SERVICE_DATA, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  store ptr %25, ptr %5, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %22
  %27 = call zeroext i8 @DebugAssertEnabled()
  %28 = icmp ne i8 %27, 0
  br i1 %28, label %29, label %36

29:                                               ; preds = %26
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %30, i32 0, i32 8
  %32 = load i64, ptr %31, align 8, !tbaa !17
  %33 = icmp ugt i64 %32, 0
  br i1 %33, label %35, label %34

34:                                               ; preds = %29
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1121, ptr noundef @.str.24)
  br label %35

35:                                               ; preds = %34, %29
  br label %36

36:                                               ; preds = %35, %26
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call i64 @MnpConfigReceiveFilters(ptr noundef %39)
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %41, i32 0, i32 8
  %43 = load i64, ptr %42, align 8, !tbaa !17
  %44 = add i64 %43, -1
  store i64 %44, ptr %42, align 8, !tbaa !17
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %45, i32 0, i32 8
  %47 = load i64, ptr %46, align 8, !tbaa !17
  %48 = icmp ugt i64 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %38
  store i64 0, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %85

50:                                               ; preds = %38
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %51, i32 0, i32 15
  %53 = load i8, ptr %52, align 8, !tbaa !21
  %54 = icmp ne i8 %53, 0
  br i1 %54, label %55, label %65

55:                                               ; preds = %50
  %56 = load ptr, ptr @gBS, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %56, i32 0, i32 9
  %58 = load ptr, ptr %57, align 8, !tbaa !22
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %59, i32 0, i32 14
  %61 = load ptr, ptr %60, align 8, !tbaa !25
  %62 = call i64 %58(ptr noundef %61, i32 noundef 0, i64 noundef 0)
  store i64 %62, ptr %4, align 8, !tbaa !26
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %63, i32 0, i32 15
  store i8 0, ptr %64, align 8, !tbaa !21
  br label %65

65:                                               ; preds = %55, %50
  %66 = load ptr, ptr @gBS, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %66, i32 0, i32 9
  %68 = load ptr, ptr %67, align 8, !tbaa !22
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %69, i32 0, i32 16
  %71 = load ptr, ptr %70, align 8, !tbaa !27
  %72 = call i64 %68(ptr noundef %71, i32 noundef 0, i64 noundef 0)
  store i64 %72, ptr %4, align 8, !tbaa !26
  %73 = load ptr, ptr @gBS, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %73, i32 0, i32 9
  %75 = load ptr, ptr %74, align 8, !tbaa !22
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %76, i32 0, i32 17
  %78 = load ptr, ptr %77, align 8, !tbaa !28
  %79 = call i64 %75(ptr noundef %78, i32 noundef 0, i64 noundef 0)
  store i64 %79, ptr %4, align 8, !tbaa !26
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.MNP_DEVICE_DATA, ptr %80, i32 0, i32 6
  %82 = load ptr, ptr %81, align 8, !tbaa !29
  %83 = call i64 @MnpStopSnp(ptr noundef %82)
  store i64 %83, ptr %4, align 8, !tbaa !26
  %84 = load i64, ptr %4, align 8, !tbaa !26
  store i64 %84, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %85

85:                                               ; preds = %65, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %86 = load i64, ptr %2, align 8
  ret i64 %86
}

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, !12, i64 8, !6, i64 24, !6, i64 32, !13, i64 40, !6, i64 56, !12, i64 64, !14, i64 80, !11, i64 88, !15, i64 92, !7, i64 94}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!13 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!10, !6, i64 24}
!17 = !{!18, !14, i64 88}
!18 = !{!"", !11, i64 0, !6, i64 8, !6, i64 16, !19, i64 24, !14, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !14, i64 88, !12, i64 96, !11, i64 112, !6, i64 120, !20, i64 128, !14, 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}
!19 = !{!"_EFI_VLAN_CONFIG_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"", !11, i64 0, !14, i64 8, !12, i64 16, !12, i64 32, !11, i64 48, !11, i64 52}
!21 = !{!18, !7, i64 200}
!22 = !{!23, !6, i64 88}
!23 = !{!"", !24, 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}
!24 = !{!"", !14, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!25 = !{!18, !6, i64 192}
!26 = !{!14, !14, i64 0}
!27 = !{!18, !6, i64 208}
!28 = !{!18, !6, i64 216}
!29 = !{!18, !6, i64 64}


; 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
@gBS = external local_unnamed_addr global ptr, align 8
@.str.17 = external hidden unnamed_addr constant [127 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [44 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
declare dso_local i64 @MnpStopSnp(ptr noundef) local_unnamed_addr #1

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

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

3:                                                ; preds = %1
  %.not15 = icmp eq ptr %0, null
  br i1 %.not15, label %7, label %4

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

7:                                                ; preds = %4, %3
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1119, ptr noundef nonnull @.str.17) #2
  br label %8

8:                                                ; preds = %4, %7, %1
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not16 = icmp eq i8 %11, 0
  br i1 %.not16, label %16, label %12

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %10, i64 88
  %14 = load i64, ptr %13, align 8, !tbaa !16
  %.not17 = icmp eq i64 %14, 0
  br i1 %.not17, label %15, label %16

15:                                               ; preds = %12
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1121, ptr noundef nonnull @.str.24) #2
  br label %16

16:                                               ; preds = %12, %15, %8
  %17 = tail call i64 @MnpConfigReceiveFilters(ptr noundef %10)
  %18 = getelementptr inbounds i8, ptr %10, i64 88
  %19 = load i64, ptr %18, align 8, !tbaa !16
  %20 = add i64 %19, -1
  store i64 %20, ptr %18, align 8, !tbaa !16
  %.not18 = icmp eq i64 %20, 0
  br i1 %.not18, label %21, label %47

21:                                               ; preds = %16
  %22 = getelementptr inbounds i8, ptr %10, i64 200
  %23 = load i8, ptr %22, align 8, !tbaa !20
  %.not19 = icmp eq i8 %23, 0
  br i1 %.not19, label %31, label %24

24:                                               ; preds = %21
  %25 = load ptr, ptr @gBS, align 8, !tbaa !21
  %26 = getelementptr inbounds i8, ptr %25, i64 88
  %27 = load ptr, ptr %26, align 8, !tbaa !22
  %28 = getelementptr inbounds i8, ptr %10, i64 192
  %29 = load ptr, ptr %28, align 8, !tbaa !25
  %30 = tail call i64 %27(ptr noundef %29, i32 noundef 0, i64 noundef 0) #2
  store i8 0, ptr %22, align 8, !tbaa !20
  br label %31

31:                                               ; preds = %24, %21
  %32 = load ptr, ptr @gBS, align 8, !tbaa !21
  %33 = getelementptr inbounds i8, ptr %32, i64 88
  %34 = load ptr, ptr %33, align 8, !tbaa !22
  %35 = getelementptr inbounds i8, ptr %10, i64 208
  %36 = load ptr, ptr %35, align 8, !tbaa !26
  %37 = tail call i64 %34(ptr noundef %36, i32 noundef 0, i64 noundef 0) #2
  %38 = load ptr, ptr @gBS, align 8, !tbaa !21
  %39 = getelementptr inbounds i8, ptr %38, i64 88
  %40 = load ptr, ptr %39, align 8, !tbaa !22
  %41 = getelementptr inbounds i8, ptr %10, i64 216
  %42 = load ptr, ptr %41, align 8, !tbaa !27
  %43 = tail call i64 %40(ptr noundef %42, i32 noundef 0, i64 noundef 0) #2
  %44 = getelementptr inbounds i8, ptr %10, i64 64
  %45 = load ptr, ptr %44, align 8, !tbaa !28
  %46 = tail call i64 @MnpStopSnp(ptr noundef %45)
  br label %47

47:                                               ; preds = %16, %31
  %.0 = phi i64 [ %46, %31 ], [ 0, %16 ]
  ret i64 %.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, !11, i64 24, !11, i64 32, !12, i64 40, !11, i64 56, !10, i64 64, !13, i64 80, !7, i64 88, !14, i64 92, !8, i64 94}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !11, i64 0, !11, i64 8}
!13 = !{!"long long", !8, i64 0}
!14 = !{!"short", !8, i64 0}
!15 = !{!6, !11, i64 24}
!16 = !{!17, !13, i64 88}
!17 = !{!"", !7, i64 0, !11, i64 8, !11, i64 16, !18, i64 24, !13, i64 48, !11, i64 56, !11, i64 64, !10, i64 72, !13, i64 88, !10, i64 96, !7, i64 112, !11, i64 120, !19, i64 128, !13, i64 184, !11, i64 192, !8, i64 200, !11, i64 208, !11, i64 216, !7, i64 224, !7, i64 228, !7, i64 232, !7, i64 236, !7, i64 240, !7, i64 244, !11, i64 248, !11, i64 256}
!18 = !{!"_EFI_VLAN_CONFIG_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16}
!19 = !{!"", !7, i64 0, !13, i64 8, !10, i64 16, !10, i64 32, !7, i64 48, !7, i64 52}
!20 = !{!17, !8, i64 200}
!21 = !{!11, !11, i64 0}
!22 = !{!23, !11, i64 88}
!23 = !{!"", !24, 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}
!24 = !{!"", !13, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!25 = !{!17, !11, i64 192}
!26 = !{!17, !11, i64 208}
!27 = !{!17, !11, i64 216}
!28 = !{!17, !11, i64 64}


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