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

; 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_INTERFACE = type { i32, %struct._LIST_ENTRY, i64, i32, i32, i32, i32, i8, ptr, ptr, ptr, ptr, ptr, %struct._LIST_ENTRY, %struct._LIST_ENTRY, ptr, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, i32, %struct._LIST_ENTRY, i8 }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.IP4_ARP_QUE = type { i32, %struct._LIST_ENTRY, %struct._LIST_ENTRY, ptr, ptr, i32, %struct.EFI_MAC_ADDRESS }
%struct._EFI_ARP_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.IP4_LINK_TX_TOKEN = type { i32, %struct._LIST_ENTRY, ptr, ptr, ptr, ptr, ptr, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, %struct.EFI_MANAGED_NETWORK_COMPLETION_TOKEN, %struct.EFI_MANAGED_NETWORK_TRANSMIT_DATA }
%struct.EFI_MANAGED_NETWORK_COMPLETION_TOKEN = type { ptr, i64, %union.anon }
%union.anon = type { ptr }
%struct.EFI_MANAGED_NETWORK_TRANSMIT_DATA = type { ptr, ptr, i16, i32, i16, i16, [1 x %struct.EFI_MANAGED_NETWORK_FRAGMENT_DATA] }
%struct.EFI_MANAGED_NETWORK_FRAGMENT_DATA = type { i32, ptr }
%struct._EFI_MANAGED_NETWORK_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; 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

; Function Attrs: nounwind uwtable
declare dso_local void @Ip4CancelFrameArp(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @Ip4CancelFrames(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  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
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %13, i32 0, i32 13
  %15 = getelementptr inbounds %struct._LIST_ENTRY, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  store ptr %16, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._LIST_ENTRY, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  store ptr %19, ptr %10, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %54, %4
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %22, i32 0, i32 13
  %24 = icmp ne ptr %21, %23
  br i1 %24, label %25, label %59

25:                                               ; preds = %20
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = ptrtoint ptr %26 to i64
  %28 = sub i64 %27, ptrtoint (ptr getelementptr inbounds (%struct.IP4_ARP_QUE, ptr null, i32 0, i32 1) to i64)
  %29 = inttoptr i64 %28 to ptr
  store ptr %29, ptr %11, align 8, !tbaa !5
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  %31 = load i64, ptr %6, align 8, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  call void @Ip4CancelFrameArp(ptr noundef %30, i64 noundef %31, ptr noundef %32, ptr noundef %33)
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.IP4_ARP_QUE, ptr %34, i32 0, i32 2
  %36 = call zeroext i8 @IsListEmpty(ptr noundef %35)
  %37 = icmp ne i8 %36, 0
  br i1 %37, label %38, label %53

38:                                               ; preds = %25
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %39, i32 0, i32 11
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  %42 = getelementptr inbounds %struct._EFI_ARP_PROTOCOL, ptr %41, i32 0, i32 6
  %43 = load ptr, ptr %42, align 8, !tbaa !18
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %44, i32 0, i32 11
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.IP4_ARP_QUE, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.IP4_ARP_QUE, ptr %49, i32 0, i32 4
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = call i64 %43(ptr noundef %46, ptr noundef %48, ptr noundef %51)
  br label %53

53:                                               ; preds = %38, %25
  br label %54

54:                                               ; preds = %53
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %55, ptr %9, align 8, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._LIST_ENTRY, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !16
  store ptr %58, ptr %10, align 8, !tbaa !5
  br label %20, !llvm.loop !22

59:                                               ; preds = %20
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %60, i32 0, i32 14
  %62 = getelementptr inbounds %struct._LIST_ENTRY, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !24
  store ptr %63, ptr %9, align 8, !tbaa !5
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._LIST_ENTRY, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  store ptr %66, ptr %10, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %99, %59
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %69, i32 0, i32 14
  %71 = icmp ne ptr %68, %70
  br i1 %71, label %72, label %104

72:                                               ; preds = %67
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = ptrtoint ptr %73 to i64
  %75 = sub i64 %74, ptrtoint (ptr getelementptr inbounds (%struct.IP4_LINK_TX_TOKEN, ptr null, i32 0, i32 1) to i64)
  %76 = inttoptr i64 %75 to ptr
  store ptr %76, ptr %12, align 8, !tbaa !5
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = icmp eq ptr %77, null
  br i1 %78, label %86, label %79

79:                                               ; preds = %72
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = load ptr, ptr %12, align 8, !tbaa !5
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = call zeroext i8 %80(ptr noundef %81, ptr noundef %82)
  %84 = zext i8 %83 to i32
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %98

86:                                               ; preds = %79, %72
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %87, i32 0, i32 10
  %89 = load ptr, ptr %88, align 8, !tbaa !25
  %90 = getelementptr inbounds %struct._EFI_MANAGED_NETWORK_PROTOCOL, ptr %89, i32 0, i32 6
  %91 = load ptr, ptr %90, align 8, !tbaa !26
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %92, i32 0, i32 10
  %94 = load ptr, ptr %93, align 8, !tbaa !25
  %95 = load ptr, ptr %12, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.IP4_LINK_TX_TOKEN, ptr %95, i32 0, i32 9
  %97 = call i64 %91(ptr noundef %94, ptr noundef %96)
  br label %98

98:                                               ; preds = %86, %79
  br label %99

99:                                               ; preds = %98
  %100 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %100, ptr %9, align 8, !tbaa !5
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct._LIST_ENTRY, ptr %101, i32 0, i32 0
  %103 = load ptr, ptr %102, align 8, !tbaa !16
  store ptr %103, ptr %10, align 8, !tbaa !5
  br label %67, !llvm.loop !28

104:                                              ; preds = %67
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

declare zeroext i8 @IsListEmpty(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 96}
!12 = !{!"_IP4_INTERFACE", !13, i64 0, !14, i64 8, !10, i64 24, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !7, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !14, i64 96, !14, i64 112, !6, i64 128, !15, i64 136, !15, i64 168, !13, i64 200, !14, i64 208, !7, i64 224}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"", !7, i64 0}
!16 = !{!14, !6, i64 0}
!17 = !{!12, !6, i64 80}
!18 = !{!19, !6, i64 48}
!19 = !{!"_EFI_ARP_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!20 = !{!21, !6, i64 48}
!21 = !{!"", !13, i64 0, !14, i64 8, !14, i64 24, !6, i64 40, !6, i64 48, !13, i64 56, !15, i64 60}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!12, !6, i64 112}
!25 = !{!12, !6, i64 72}
!26 = !{!27, !6, i64 48}
!27 = !{!"_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}
!28 = distinct !{!28, !23}


; 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"

; Function Attrs: nounwind uwtable
declare dso_local void @Ip4CancelFrameArp(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @Ip4CancelFrames(ptr noundef readonly %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 96
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not36 = icmp eq ptr %6, %5
  br i1 %.not36, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  br label %8

8:                                                ; preds = %.lr.ph, %22
  %.037 = phi ptr [ %6, %.lr.ph ], [ %.02938, %22 ]
  %.02938 = load ptr, ptr %.037, align 8, !tbaa !14
  %9 = ptrtoint ptr %.037 to i64
  %10 = add i64 %9, -8
  %11 = inttoptr i64 %10 to ptr
  tail call void @Ip4CancelFrameArp(ptr noundef %11, i64 noundef %1, ptr noundef %2, ptr noundef %3)
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  %13 = tail call zeroext i8 @IsListEmpty(ptr noundef nonnull %12) #2
  %.not34 = icmp eq i8 %13, 0
  br i1 %.not34, label %22, label %14

14:                                               ; preds = %8
  %15 = load ptr, ptr %7, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %15, i64 48
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = getelementptr inbounds i8, ptr %11, i64 56
  %19 = getelementptr inbounds i8, ptr %11, i64 48
  %20 = load ptr, ptr %19, align 8, !tbaa !18
  %21 = tail call i64 %17(ptr noundef %15, ptr noundef nonnull %18, ptr noundef %20) #2
  br label %22

22:                                               ; preds = %8, %14
  %.not = icmp eq ptr %.02938, %5
  br i1 %.not, label %._crit_edge, label %8, !llvm.loop !20

._crit_edge:                                      ; preds = %22, %4
  %23 = getelementptr inbounds i8, ptr %0, i64 112
  %24 = load ptr, ptr %23, align 8, !tbaa !22
  %.not3240 = icmp eq ptr %24, %23
  br i1 %.not3240, label %._crit_edge45, label %.lr.ph44

.lr.ph44:                                         ; preds = %._crit_edge
  %.13039 = load ptr, ptr %24, align 8, !tbaa !14
  %25 = icmp eq ptr %2, null
  %26 = getelementptr inbounds i8, ptr %0, i64 72
  br i1 %25, label %.lr.ph44.split.us, label %.lr.ph44.split

.lr.ph44.split.us:                                ; preds = %.lr.ph44, %.lr.ph44.split.us
  %.13042.us = phi ptr [ %.130.us, %.lr.ph44.split.us ], [ %.13039, %.lr.ph44 ]
  %.141.us = phi ptr [ %.13042.us, %.lr.ph44.split.us ], [ %24, %.lr.ph44 ]
  %27 = ptrtoint ptr %.141.us to i64
  %28 = add i64 %27, -8
  %29 = inttoptr i64 %28 to ptr
  %30 = load ptr, ptr %26, align 8, !tbaa !23
  %31 = getelementptr inbounds i8, ptr %30, i64 48
  %32 = load ptr, ptr %31, align 8, !tbaa !24
  %33 = getelementptr inbounds i8, ptr %29, i64 128
  %34 = tail call i64 %32(ptr noundef %30, ptr noundef nonnull %33) #2
  %.130.us = load ptr, ptr %.13042.us, align 8, !tbaa !14
  %.not32.us = icmp eq ptr %.13042.us, %23
  br i1 %.not32.us, label %._crit_edge45, label %.lr.ph44.split.us, !llvm.loop !26

.lr.ph44.split:                                   ; preds = %.lr.ph44, %45
  %.13042 = phi ptr [ %.130, %45 ], [ %.13039, %.lr.ph44 ]
  %.141 = phi ptr [ %.13042, %45 ], [ %24, %.lr.ph44 ]
  %35 = ptrtoint ptr %.141 to i64
  %36 = add i64 %35, -8
  %37 = inttoptr i64 %36 to ptr
  %38 = tail call zeroext i8 %2(ptr noundef %37, ptr noundef %3) #2
  %.not33 = icmp eq i8 %38, 0
  br i1 %.not33, label %45, label %39

39:                                               ; preds = %.lr.ph44.split
  %40 = load ptr, ptr %26, align 8, !tbaa !23
  %41 = getelementptr inbounds i8, ptr %40, i64 48
  %42 = load ptr, ptr %41, align 8, !tbaa !24
  %43 = getelementptr inbounds i8, ptr %37, i64 128
  %44 = tail call i64 %42(ptr noundef %40, ptr noundef nonnull %43) #2
  br label %45

45:                                               ; preds = %.lr.ph44.split, %39
  %.130 = load ptr, ptr %.13042, align 8, !tbaa !14
  %.not32 = icmp eq ptr %.13042, %23
  br i1 %.not32, label %._crit_edge45, label %.lr.ph44.split, !llvm.loop !26

._crit_edge45:                                    ; preds = %45, %.lr.ph44.split.us, %._crit_edge
  ret void
}

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

attributes #0 = { 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 #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 }

!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 96}
!6 = !{!"_IP4_INTERFACE", !7, i64 0, !10, i64 8, !12, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !8, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !10, i64 96, !10, i64 112, !11, i64 128, !13, i64 136, !13, i64 168, !7, i64 200, !10, i64 208, !8, i64 224}
!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 = !{!"long long", !8, i64 0}
!13 = !{!"", !8, i64 0}
!14 = !{!10, !11, i64 0}
!15 = !{!6, !11, i64 80}
!16 = !{!17, !11, i64 48}
!17 = !{!"_EFI_ARP_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!18 = !{!19, !11, i64 48}
!19 = !{!"", !7, i64 0, !10, i64 8, !10, i64 24, !11, i64 40, !11, i64 48, !7, i64 56, !13, i64 60}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!6, !11, i64 112}
!23 = !{!6, !11, i64 72}
!24 = !{!25, !11, i64 48}
!25 = !{!"_EFI_MANAGED_NETWORK_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}
!26 = distinct !{!26, !21}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass