; 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_MODE, i8, ptr, i16, i8, i8, i8, i8, i8, ptr, i64, ptr, ptr, ptr, [2 x i32], 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 [160 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 51, 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
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %31, i32 0, i32 11
  %33 = getelementptr inbounds %struct.EFI_MAC_ADDRESS, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds [32 x i8], ptr %33, i64 0, i64 0
  %35 = call i64 @Ax88772MacAddressSet(ptr noundef %30, ptr noundef %34)
  store i64 %35, ptr %5, align 8, !tbaa !18
  %36 = load i64, ptr %5, align 8, !tbaa !18
  %37 = icmp slt i64 %36, 0
  br i1 %37, label %80, label %38

38:                                               ; preds = %25
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  call void @Ax88772MulticastClear(ptr noundef %39)
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %40, i32 0, i32 7
  %42 = load i32, ptr %41, align 4, !tbaa !19
  %43 = and i32 %42, 2
  %44 = icmp ne i32 0, %43
  br i1 %44, label %45, label %70

45:                                               ; preds = %38
  store i32 0, ptr %6, align 4, !tbaa !20
  br label %46

46:                                               ; preds = %66, %45
  %47 = load i64, ptr %5, align 8, !tbaa !18
  %48 = icmp slt i64 %47, 0
  br i1 %48, label %55, label %49

49:                                               ; preds = %46
  %50 = load i32, ptr %6, align 4, !tbaa !20
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %51, i32 0, i32 9
  %53 = load i32, ptr %52, align 4, !tbaa !21
  %54 = icmp ult i32 %50, %53
  br label %55

55:                                               ; preds = %49, %46
  %56 = phi i1 [ false, %46 ], [ %54, %49 ]
  br i1 %56, label %57, label %69

57:                                               ; preds = %55
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %59, i32 0, i32 10
  %61 = load i32, ptr %6, align 4, !tbaa !20
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds [16 x %struct.EFI_MAC_ADDRESS], ptr %60, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.EFI_MAC_ADDRESS, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds [32 x i8], ptr %64, i64 0, i64 0
  call void @Ax88772MulticastSet(ptr noundef %58, ptr noundef %65)
  br label %66

66:                                               ; preds = %57
  %67 = load i32, ptr %6, align 4, !tbaa !20
  %68 = add i32 %67, 1
  store i32 %68, ptr %6, align 4, !tbaa !20
  br label %46, !llvm.loop !22

69:                                               ; preds = %55
  br label %70

70:                                               ; preds = %69, %38
  %71 = load i64, ptr %5, align 8, !tbaa !18
  %72 = icmp slt i64 %71, 0
  br i1 %72, label %79, label %73

73:                                               ; preds = %70
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %75, i32 0, i32 7
  %77 = load i32, ptr %76, align 4, !tbaa !19
  %78 = call i64 @Ax88772RxControl(ptr noundef %74, i32 noundef %77)
  store i64 %78, ptr %5, align 8, !tbaa !18
  br label %79

79:                                               ; preds = %73, %70
  br label %80

80:                                               ; preds = %79, %25
  %81 = load i64, ptr %5, align 8, !tbaa !18
  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 %81
}

; 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 i64 @Ax88772MacAddressSet(ptr 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, !13, i64 152, !7, i64 808, !6, i64 816, !16, i64 824, !7, i64 826, !7, i64 827, !7, i64 828, !7, i64 829, !7, i64 830, !6, i64 832, !11, i64 840, !6, i64 848, !6, i64 856, !6, i64 864, !7, i64 872, !6, i64 880}
!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 = !{!11, !11, i64 0}
!19 = !{!13, !14, i64 28}
!20 = !{!14, !14, i64 0}
!21 = !{!13, !14, i64 36}
!22 = distinct !{!22, !23}
!23 = !{!"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"

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

@.str = external hidden unnamed_addr constant [160 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
  %.pre26 = ptrtoint ptr %0 to i64
  %.pre27 = add i64 %.pre26, -24
  %.pre29 = inttoptr i64 %.pre27 to ptr
  br i1 %.not, label %._crit_edge, label %3

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

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

._crit_edge:                                      ; preds = %1, %3, %5
  %6 = phi ptr [ %0, %5 ], [ %.pre29, %3 ], [ %.pre29, %1 ]
  %7 = getelementptr inbounds i8, ptr %0, i64 120
  %8 = load ptr, ptr %7, align 8, !tbaa !16
  %9 = getelementptr inbounds i8, ptr %8, i64 552
  %10 = tail call i64 @Ax88772MacAddressSet(ptr noundef %6, ptr noundef nonnull %9) #2
  %11 = icmp slt i64 %10, 0
  br i1 %11, label %26, label %12

12:                                               ; preds = %._crit_edge
  tail call void @Ax88772MulticastClear(ptr noundef %6) #2
  %13 = getelementptr inbounds i8, ptr %8, i64 28
  %14 = load i32, ptr %13, align 4, !tbaa !17
  %15 = and i32 %14, 2
  %.not22 = icmp eq i32 %15, 0
  br i1 %.not22, label %.critedge, label %.preheader

.preheader:                                       ; preds = %12
  %16 = getelementptr inbounds i8, ptr %8, i64 36
  %17 = load i32, ptr %16, align 4, !tbaa !18
  %.not24 = icmp eq i32 %17, 0
  br i1 %.not24, label %.critedge, label %.lr.ph

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

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

.critedge.loopexit:                               ; preds = %19
  %.pre = load i32, ptr %13, align 4, !tbaa !17
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.preheader, %12
  %24 = phi i32 [ %.pre, %.critedge.loopexit ], [ %14, %.preheader ], [ %14, %12 ]
  %25 = tail call i64 @Ax88772RxControl(ptr noundef %6, i32 noundef %24) #2
  br label %26

26:                                               ; preds = %.critedge, %._crit_edge
  %.019 = phi i64 [ %10, %._crit_edge ], [ %25, %.critedge ]
  ret i64 %.019
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

declare i64 @Ax88772MacAddressSet(ptr 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, !12, i64 152, !8, i64 808, !10, i64 816, !15, i64 824, !8, i64 826, !8, i64 827, !8, i64 828, !8, i64 829, !8, i64 830, !10, i64 832, !7, i64 840, !10, i64 848, !10, i64 856, !10, i64 864, !8, i64 872, !10, i64 880}
!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,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass