; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/OptionRomPkg/Bus/Usb (ReceiveFilterUpdate)

; 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.NIC_DEVICE = type { i64, ptr, ptr, %struct._EFI_SIMPLE_NETWORK_PROTOCOL, %struct._EFI_SIMPLE_NETWORK_PROTOCOL, %struct.EFI_SIMPLE_NETWORK_MODE, i8, ptr, i16, i8, i8, i8, i8, i64, i64, i16, ptr, ptr, [8 x i8], %struct.EFI_MAC_ADDRESS, i8, ptr, ptr, ptr, ptr, ptr, i64, ptr }
%struct._EFI_SIMPLE_NETWORK_PROTOCOL = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_SIMPLE_NETWORK_MODE = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x %struct.EFI_MAC_ADDRESS], %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, i8, i8, i8, i8, i8 }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }

@.str = external hidden unnamed_addr constant [161 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @ReceiveFilterUpdate(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  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 4, ptr %6) #3
  %7 = call zeroext i8 @DebugAssertEnabled()
  %8 = zext i8 %7 to i32
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %20

10:                                               ; preds = %1
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = ptrtoint ptr %11 to i64
  %13 = sub i64 %12, ptrtoint (ptr getelementptr inbounds (%struct.NIC_DEVICE, ptr null, i32 0, i32 3) to i64)
  %14 = inttoptr i64 %13 to ptr
  %15 = getelementptr inbounds %struct.NIC_DEVICE, ptr %14, i32 0, i32 0
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = icmp ne i64 %16, 943216705
  br i1 %17, label %18, label %20

18:                                               ; preds = %10
  call void @DebugAssert(ptr noundef @.str, i64 noundef 49, ptr noundef @.str.1)
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  br label %25

20:                                               ; preds = %10, %1
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = ptrtoint ptr %21 to i64
  %23 = sub i64 %22, ptrtoint (ptr getelementptr inbounds (%struct.NIC_DEVICE, ptr null, i32 0, i32 3) to i64)
  %24 = inttoptr i64 %23 to ptr
  br label %25

25:                                               ; preds = %20, %18
  %26 = phi ptr [ %19, %18 ], [ %24, %20 ]
  store ptr %26, ptr %4, align 8, !tbaa !5
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._EFI_SIMPLE_NETWORK_PROTOCOL, ptr %27, i32 0, i32 15
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  store ptr %29, ptr %3, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  call void @Ax88772MulticastClear(ptr noundef %30)
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %31, i32 0, i32 7
  %33 = load i32, ptr %32, align 4, !tbaa !18
  %34 = and i32 %33, 2
  %35 = icmp ne i32 0, %34
  br i1 %35, label %36, label %56

36:                                               ; preds = %25
  store i32 0, ptr %6, align 4, !tbaa !19
  br label %37

37:                                               ; preds = %52, %36
  %38 = load i32, ptr %6, align 4, !tbaa !19
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %39, i32 0, i32 9
  %41 = load i32, ptr %40, align 4, !tbaa !20
  %42 = icmp ult i32 %38, %41
  br i1 %42, label %43, label %55

43:                                               ; preds = %37
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %45, i32 0, i32 10
  %47 = load i32, ptr %6, align 4, !tbaa !19
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds [16 x %struct.EFI_MAC_ADDRESS], ptr %46, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.EFI_MAC_ADDRESS, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds [32 x i8], ptr %50, i64 0, i64 0
  call void @Ax88772MulticastSet(ptr noundef %44, ptr noundef %51)
  br label %52

52:                                               ; preds = %43
  %53 = load i32, ptr %6, align 4, !tbaa !19
  %54 = add i32 %53, 1
  store i32 %54, ptr %6, align 4, !tbaa !19
  br label %37, !llvm.loop !21

55:                                               ; preds = %37
  br label %56

56:                                               ; preds = %55, %25
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %58, i32 0, i32 7
  %60 = load i32, ptr %59, align 4, !tbaa !18
  %61 = call i64 @Ax88772RxControl(ptr noundef %57, i32 noundef %60)
  store i64 %61, ptr %5, align 8, !tbaa !23
  %62 = load i64, ptr %5, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 4, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i64 %62
}

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

declare zeroext i8 @DebugAssertEnabled() #2

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

declare void @Ax88772MulticastClear(ptr noundef) #2

declare void @Ax88772MulticastSet(ptr noundef, ptr noundef) #2

declare i64 @Ax88772RxControl(ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 0}
!10 = !{!"", !11, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 152, !13, i64 280, !7, i64 936, !6, i64 944, !16, i64 952, !7, i64 954, !7, i64 955, !7, i64 956, !7, i64 957, !11, i64 960, !11, i64 968, !16, i64 976, !6, i64 984, !6, i64 992, !7, i64 1000, !15, i64 1008, !7, i64 1040, !6, i64 1048, !6, i64 1056, !6, i64 1064, !6, i64 1072, !6, i64 1080, !11, i64 1088, !6, i64 1096}
!11 = !{!"long long", !7, i64 0}
!12 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !11, i64 0, !6, i64 8, !6, i64 16, !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}
!13 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !7, i64 40, !15, i64 552, !15, i64 584, !15, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !7, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = !{!12, !6, i64 120}
!18 = !{!13, !14, i64 28}
!19 = !{!14, !14, i64 0}
!20 = !{!13, !14, i64 36}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!11, !11, i64 0}


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

%struct.EFI_MAC_ADDRESS = type { [32 x i8] }

@.str = external hidden unnamed_addr constant [161 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @ReceiveFilterUpdate(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %2, 0
  %.pre19 = ptrtoint ptr %0 to i64
  %.pre20 = add i64 %.pre19, -24
  %.pre22 = inttoptr i64 %.pre20 to ptr
  br i1 %.not, label %._crit_edge, label %3

3:                                                ; preds = %1
  %4 = load i64, ptr %.pre22, align 8, !tbaa !5
  %.not14 = icmp eq i64 %4, 943216705
  br i1 %.not14, label %._crit_edge, label %5

5:                                                ; preds = %3
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 49, ptr noundef nonnull @.str.1) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %1, %3, %5
  %6 = phi ptr [ %0, %5 ], [ %.pre22, %3 ], [ %.pre22, %1 ]
  %7 = getelementptr inbounds i8, ptr %0, i64 120
  %8 = load ptr, ptr %7, align 8, !tbaa !16
  tail call void @Ax88772MulticastClear(ptr noundef %6) #2
  %9 = getelementptr inbounds i8, ptr %8, i64 28
  %10 = load i32, ptr %9, align 4, !tbaa !17
  %11 = and i32 %10, 2
  %.not15 = icmp eq i32 %11, 0
  br i1 %.not15, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %._crit_edge
  %12 = getelementptr inbounds i8, ptr %8, i64 36
  %13 = load i32, ptr %12, align 4, !tbaa !18
  %.not17 = icmp eq i32 %13, 0
  br i1 %.not17, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %14 = getelementptr inbounds i8, ptr %8, i64 40
  br label %15

15:                                               ; preds = %.lr.ph, %15
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %15 ]
  %16 = getelementptr inbounds [16 x %struct.EFI_MAC_ADDRESS], ptr %14, i64 0, i64 %indvars.iv
  tail call void @Ax88772MulticastSet(ptr noundef %6, ptr noundef nonnull %16) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr %12, align 4, !tbaa !18
  %18 = zext i32 %17 to i64
  %19 = icmp ult i64 %indvars.iv.next, %18
  br i1 %19, label %15, label %.loopexit.loopexit, !llvm.loop !19

.loopexit.loopexit:                               ; preds = %15
  %.pre = load i32, ptr %9, align 4, !tbaa !17
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader, %._crit_edge
  %20 = phi i32 [ %.pre, %.loopexit.loopexit ], [ %10, %.preheader ], [ %10, %._crit_edge ]
  %21 = tail call i64 @Ax88772RxControl(ptr noundef %6, i32 noundef %20) #2
  ret i64 %21
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

declare void @Ax88772MulticastClear(ptr noundef) local_unnamed_addr #1

declare void @Ax88772MulticastSet(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i64 @Ax88772RxControl(ptr noundef, i32 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !11, i64 152, !12, i64 280, !8, i64 936, !10, i64 944, !15, i64 952, !8, i64 954, !8, i64 955, !8, i64 956, !8, i64 957, !7, i64 960, !7, i64 968, !15, i64 976, !10, i64 984, !10, i64 992, !8, i64 1000, !14, i64 1008, !8, i64 1040, !10, i64 1048, !10, i64 1056, !10, i64 1064, !10, i64 1072, !10, i64 1080, !7, i64 1088, !10, i64 1096}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !8, i64 40, !14, i64 552, !14, i64 584, !14, i64 616, !8, i64 648, !8, i64 649, !8, i64 650, !8, i64 651, !8, i64 652}
!13 = !{!"int", !8, i64 0}
!14 = !{!"", !8, i64 0}
!15 = !{!"short", !8, i64 0}
!16 = !{!11, !10, i64 120}
!17 = !{!12, !13, i64 28}
!18 = !{!12, !13, i64 36}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass