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

; 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.s_data_instance = type { i16, i16, i8, i8, i16, i16, i16, i16, i16, [32 x i8], [32 x i8], [32 x i8], [64 x i32], [128 x i32], i32, i32, i16, i16, i8, i8, i8, i8, i16, i16, i16, i16, i32, i32, i16, i16, [2 x i16], i8, i8, i16, i32, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i64, [64 x i64], i16, i16, i16, i16, i8, i8, i8, i8, i8, [3 x i8], %struct.mc, i64, ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.mc = type { [3 x i16], i16, [8 x [32 x i8]] }
%struct.s_RxFD = type { %struct.CB_Header, i32, i16, i16, [1536 x i8], i8, [3 x i8] }
%struct.CB_Header = type { i16, i16, i32 }

; 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
define dso_local zeroext i8 @SetupReceiveQueues(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #2
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.s_data_instance, ptr %6, i32 0, i32 49
  store i16 0, ptr %7, align 4, !tbaa !9
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.s_data_instance, ptr %8, i32 0, i32 35
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = getelementptr inbounds %struct.s_RxFD, ptr %10, i64 0
  store ptr %11, ptr %3, align 8, !tbaa !5
  store i16 0, ptr %5, align 2, !tbaa !16
  br label %12

12:                                               ; preds = %81, %1
  %13 = load i16, ptr %5, align 2, !tbaa !16
  %14 = zext i16 %13 to i32
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.s_data_instance, ptr %15, i32 0, i32 24
  %17 = load i16, ptr %16, align 4, !tbaa !17
  %18 = zext i16 %17 to i32
  %19 = icmp slt i32 %14, %18
  br i1 %19, label %20, label %84

20:                                               ; preds = %12
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load i16, ptr %5, align 2, !tbaa !16
  %23 = zext i16 %22 to i64
  %24 = getelementptr inbounds %struct.s_RxFD, ptr %21, i64 %23
  %25 = getelementptr inbounds %struct.s_RxFD, ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds %struct.CB_Header, ptr %25, i32 0, i32 0
  store i16 0, ptr %26, align 1, !tbaa !18
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i16, ptr %5, align 2, !tbaa !16
  %29 = zext i16 %28 to i64
  %30 = getelementptr inbounds %struct.s_RxFD, ptr %27, i64 %29
  %31 = getelementptr inbounds %struct.s_RxFD, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds %struct.CB_Header, ptr %31, i32 0, i32 1
  store i16 0, ptr %32, align 1, !tbaa !21
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = load i16, ptr %5, align 2, !tbaa !16
  %35 = zext i16 %34 to i64
  %36 = getelementptr inbounds %struct.s_RxFD, ptr %33, i64 %35
  %37 = getelementptr inbounds %struct.s_RxFD, ptr %36, i32 0, i32 3
  store i16 1536, ptr %37, align 1, !tbaa !22
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load i16, ptr %5, align 2, !tbaa !16
  %40 = zext i16 %39 to i64
  %41 = getelementptr inbounds %struct.s_RxFD, ptr %38, i64 %40
  %42 = getelementptr inbounds %struct.s_RxFD, ptr %41, i32 0, i32 2
  store i16 0, ptr %42, align 1, !tbaa !23
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load i16, ptr %5, align 2, !tbaa !16
  %45 = zext i16 %44 to i64
  %46 = getelementptr inbounds %struct.s_RxFD, ptr %43, i64 %45
  %47 = getelementptr inbounds %struct.s_RxFD, ptr %46, i32 0, i32 1
  store i32 -1, ptr %47, align 1, !tbaa !24
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = load i16, ptr %5, align 2, !tbaa !16
  %50 = zext i16 %49 to i64
  %51 = getelementptr inbounds %struct.s_RxFD, ptr %48, i64 %50
  %52 = getelementptr inbounds %struct.s_RxFD, ptr %51, i32 0, i32 5
  store i8 0, ptr %52, align 1, !tbaa !25
  %53 = load i16, ptr %5, align 2, !tbaa !16
  %54 = zext i16 %53 to i32
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.s_data_instance, ptr %55, i32 0, i32 24
  %57 = load i16, ptr %56, align 4, !tbaa !17
  %58 = zext i16 %57 to i32
  %59 = sub nsw i32 %58, 1
  %60 = icmp slt i32 %54, %59
  br i1 %60, label %61, label %80

61:                                               ; preds = %20
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.s_data_instance, ptr %62, i32 0, i32 41
  %64 = load i64, ptr %63, align 8, !tbaa !26
  %65 = trunc i64 %64 to i32
  %66 = zext i32 %65 to i64
  %67 = load i16, ptr %5, align 2, !tbaa !16
  %68 = zext i16 %67 to i32
  %69 = add nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = mul i64 %70, 1556
  %72 = add i64 %66, %71
  %73 = trunc i64 %72 to i32
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = load i16, ptr %5, align 2, !tbaa !16
  %76 = zext i16 %75 to i64
  %77 = getelementptr inbounds %struct.s_RxFD, ptr %74, i64 %76
  %78 = getelementptr inbounds %struct.s_RxFD, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds %struct.CB_Header, ptr %78, i32 0, i32 2
  store i32 %73, ptr %79, align 1, !tbaa !27
  br label %80

80:                                               ; preds = %61, %20
  br label %81

81:                                               ; preds = %80
  %82 = load i16, ptr %5, align 2, !tbaa !16
  %83 = add i16 %82, 1
  store i16 %83, ptr %5, align 2, !tbaa !16
  br label %12, !llvm.loop !28

84:                                               ; preds = %12
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.s_data_instance, ptr %85, i32 0, i32 35
  %87 = load ptr, ptr %86, align 8, !tbaa !15
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.s_data_instance, ptr %88, i32 0, i32 24
  %90 = load i16, ptr %89, align 4, !tbaa !17
  %91 = zext i16 %90 to i32
  %92 = sub nsw i32 %91, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds %struct.s_RxFD, ptr %87, i64 %93
  store ptr %94, ptr %4, align 8, !tbaa !5
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.s_data_instance, ptr %95, i32 0, i32 41
  %97 = load i64, ptr %96, align 8, !tbaa !26
  %98 = trunc i64 %97 to i32
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.s_RxFD, ptr %99, i32 0, i32 0
  %101 = getelementptr inbounds %struct.CB_Header, ptr %100, i32 0, i32 2
  store i32 %98, ptr %101, align 1, !tbaa !27
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.s_RxFD, ptr %102, i32 0, i32 0
  %104 = getelementptr inbounds %struct.CB_Header, ptr %103, i32 0, i32 1
  store i16 -16384, ptr %104, align 1, !tbaa !21
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = load ptr, ptr %2, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.s_data_instance, ptr %106, i32 0, i32 40
  store ptr %105, ptr %107, align 8, !tbaa !30
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret i8 0
}

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 = { 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 1532}
!10 = !{!"s_data_instance", !11, i64 0, !11, i64 2, !7, i64 4, !7, i64 5, !11, i64 6, !11, i64 8, !11, i64 10, !11, i64 12, !11, i64 14, !7, i64 16, !7, i64 48, !7, i64 80, !7, i64 112, !7, i64 368, !12, i64 880, !12, i64 884, !11, i64 888, !11, i64 890, !7, i64 892, !7, i64 893, !7, i64 894, !7, i64 895, !11, i64 896, !11, i64 898, !11, i64 900, !11, i64 902, !12, i64 904, !12, i64 908, !11, i64 912, !11, i64 914, !7, i64 916, !7, i64 920, !7, i64 921, !11, i64 922, !12, i64 924, !6, i64 928, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !13, i64 976, !13, i64 984, !13, i64 992, !13, i64 1000, !13, i64 1008, !7, i64 1016, !11, i64 1528, !11, i64 1530, !11, i64 1532, !11, i64 1534, !7, i64 1536, !7, i64 1537, !7, i64 1538, !7, i64 1539, !7, i64 1540, !7, i64 1541, !14, i64 1544, !13, i64 1808, !6, i64 1816, !13, i64 1824, !6, i64 1832, !6, i64 1840, !6, i64 1848, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888, !6, i64 1896, !6, i64 1904, !6, i64 1912}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"mc", !7, i64 0, !11, i64 6, !7, i64 8}
!15 = !{!10, !6, i64 928}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 900}
!18 = !{!19, !11, i64 0}
!19 = !{!"s_RxFD", !20, i64 0, !12, i64 8, !11, i64 12, !11, i64 14, !7, i64 16, !7, i64 1552, !7, i64 1553}
!20 = !{!"CB_Header", !11, i64 0, !11, i64 2, !12, i64 4}
!21 = !{!19, !11, i64 2}
!22 = !{!19, !11, i64 14}
!23 = !{!19, !11, i64 12}
!24 = !{!19, !12, i64 8}
!25 = !{!19, !7, i64 1552}
!26 = !{!10, !13, i64 976}
!27 = !{!19, !12, i64 4}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!10, !6, i64 968}


; 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.s_RxFD = type { %struct.CB_Header, i32, i16, i16, [1536 x i8], i8, [3 x i8] }
%struct.CB_Header = type { i16, i16, i32 }

; Function Attrs: nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i8 @SetupReceiveQueues(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 1532
  store i16 0, ptr %2, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 928
  %4 = load ptr, ptr %3, align 8, !tbaa !14
  %5 = getelementptr inbounds i8, ptr %0, i64 900
  %6 = load i16, ptr %5, align 4, !tbaa !15
  %.not = icmp eq i16 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %7 = zext i16 %6 to i32
  %8 = add nsw i32 %7, -1
  %9 = getelementptr inbounds i8, ptr %0, i64 976
  %wide.trip.count = zext i16 %6 to i64
  br label %10

10:                                               ; preds = %.lr.ph, %25
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %25 ]
  %11 = phi i32 [ 0, %.lr.ph ], [ %26, %25 ]
  %12 = getelementptr inbounds %struct.s_RxFD, ptr %4, i64 %indvars.iv
  store i16 0, ptr %12, align 1, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %12, i64 2
  store i16 0, ptr %13, align 1, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %12, i64 14
  store i16 1536, ptr %14, align 1, !tbaa !20
  %15 = getelementptr inbounds i8, ptr %12, i64 12
  store i16 0, ptr %15, align 1, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %12, i64 8
  store i32 -1, ptr %16, align 1, !tbaa !22
  %17 = getelementptr inbounds i8, ptr %12, i64 1552
  store i8 0, ptr %17, align 1, !tbaa !23
  %18 = icmp ugt i32 %8, %11
  br i1 %18, label %19, label %25

19:                                               ; preds = %10
  %20 = load i64, ptr %9, align 8, !tbaa !24
  %21 = mul nuw nsw i32 %11, 1556
  %narrow = add nuw nsw i32 %21, 1556
  %22 = trunc i64 %20 to i32
  %23 = add i32 %narrow, %22
  %24 = getelementptr inbounds i8, ptr %12, i64 4
  store i32 %23, ptr %24, align 1, !tbaa !25
  br label %25

25:                                               ; preds = %10, %19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = trunc nuw i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !26

._crit_edge:                                      ; preds = %25, %1
  %.pre-phi = phi i64 [ 0, %1 ], [ %wide.trip.count, %25 ]
  %27 = getelementptr %struct.s_RxFD, ptr %4, i64 %.pre-phi
  %28 = getelementptr i8, ptr %27, i64 -1556
  %29 = getelementptr inbounds i8, ptr %0, i64 976
  %30 = load i64, ptr %29, align 8, !tbaa !24
  %31 = trunc i64 %30 to i32
  %32 = getelementptr i8, ptr %27, i64 -1552
  store i32 %31, ptr %32, align 1, !tbaa !25
  %33 = getelementptr i8, ptr %27, i64 -1554
  store i16 -16384, ptr %33, align 1, !tbaa !19
  %34 = getelementptr inbounds i8, ptr %0, i64 968
  store ptr %28, ptr %34, align 8, !tbaa !28
  ret i8 0
}

attributes #0 = { nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) 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" }

!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 1532}
!6 = !{!"s_data_instance", !7, i64 0, !7, i64 2, !8, i64 4, !8, i64 5, !7, i64 6, !7, i64 8, !7, i64 10, !7, i64 12, !7, i64 14, !8, i64 16, !8, i64 48, !8, i64 80, !8, i64 112, !8, i64 368, !10, i64 880, !10, i64 884, !7, i64 888, !7, i64 890, !8, i64 892, !8, i64 893, !8, i64 894, !8, i64 895, !7, i64 896, !7, i64 898, !7, i64 900, !7, i64 902, !10, i64 904, !10, i64 908, !7, i64 912, !7, i64 914, !8, i64 916, !8, i64 920, !8, i64 921, !7, i64 922, !10, i64 924, !11, i64 928, !11, i64 936, !11, i64 944, !11, i64 952, !11, i64 960, !11, i64 968, !12, i64 976, !12, i64 984, !12, i64 992, !12, i64 1000, !12, i64 1008, !8, i64 1016, !7, i64 1528, !7, i64 1530, !7, i64 1532, !7, i64 1534, !8, i64 1536, !8, i64 1537, !8, i64 1538, !8, i64 1539, !8, i64 1540, !8, i64 1541, !13, i64 1544, !12, i64 1808, !11, i64 1816, !12, i64 1824, !11, i64 1832, !11, i64 1840, !11, i64 1848, !11, i64 1856, !11, i64 1864, !11, i64 1872, !11, i64 1880, !11, i64 1888, !11, i64 1896, !11, i64 1904, !11, i64 1912}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"mc", !8, i64 0, !7, i64 6, !8, i64 8}
!14 = !{!6, !11, i64 928}
!15 = !{!6, !7, i64 900}
!16 = !{!17, !7, i64 0}
!17 = !{!"s_RxFD", !18, i64 0, !10, i64 8, !7, i64 12, !7, i64 14, !8, i64 16, !8, i64 1552, !8, i64 1553}
!18 = !{!"CB_Header", !7, i64 0, !7, i64 2, !10, i64 4}
!19 = !{!17, !7, i64 2}
!20 = !{!17, !7, i64 14}
!21 = !{!17, !7, i64 12}
!22 = !{!17, !10, i64 8}
!23 = !{!17, !8, i64 1552}
!24 = !{!6, !12, i64 976}
!25 = !{!17, !10, i64 4}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!6, !11, i64 968}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass