; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/Drivers/STM32H7xx_HAL_Driver/Src (SetMACFilterConfig)

; 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.ETH_MACFilterConfigTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.ETH_HandleTypeDef = type { ptr, %struct.ETH_InitTypeDef, %struct.ETH_TxDescListTypeDef, %struct.ETH_RxDescListTypeDef, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.ETH_InitTypeDef = type { ptr, i32, ptr, ptr, i32 }
%struct.ETH_TxDescListTypeDef = type { [4 x i32], i32 }
%struct.ETH_RxDescListTypeDef = type { [4 x i32], i32, i32, i32, i32, i32 }
%struct.ETH_TypeDef = type { i32, i32, i32, i32, i32, i32, [14 x i32], i32, i32, i32, i32, i32, i32, [2 x i32], i32, [7 x i32], i32, [7 x i32], i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, [12 x i32], i32, i32, i32, i32, i32, i32, [54 x i32], i32, i32, [2 x i32], i32, [59 x i32], i32, i32, i32, i32, i32, i32, i32, i32, [248 x i32], i32, i32, i32, i32, i32, [14 x i32], i32, i32, [5 x i32], i32, [10 x i32], i32, i32, [10 x i32], i32, [9 x i32], i32, i32, i32, i32, [65 x i32], i32, i32, [2 x i32], i32, i32, i32, i32, [4 x i32], i32, i32, [2 x i32], i32, i32, i32, i32, [108 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, i32, i32, [4 x i32], i32, [3 x i32], i32, i32, i32, i32, [12 x i32], i32, i32, i32, i32, i32, [11 x i32], i32, [7 x i32], i32, [55 x i32], i32, i32, i32, [8 x i32], i32, i32, i32, i32, [177 x i32], i32, i32, i32, i32, [60 x i32], i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [2 x i32], 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 i32 @HAL_ETH_SetMACFilterConfig(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %79

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %15, i32 0, i32 3
  %17 = load i32, ptr %16, align 4, !tbaa !12
  %18 = shl i32 %17, 1
  %19 = or i32 %14, %18
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %20, i32 0, i32 4
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = shl i32 %22, 2
  %24 = or i32 %19, %23
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %25, i32 0, i32 8
  %27 = load i32, ptr %26, align 4, !tbaa !14
  %28 = shl i32 %27, 3
  %29 = or i32 %24, %28
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %30, i32 0, i32 5
  %32 = load i32, ptr %31, align 4, !tbaa !15
  %33 = shl i32 %32, 4
  %34 = or i32 %29, %33
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %35, i32 0, i32 9
  %37 = load i32, ptr %36, align 4, !tbaa !16
  %38 = icmp eq i32 %37, 0
  %39 = zext i1 %38 to i64
  %40 = select i1 %38, i32 1, i32 0
  %41 = shl i32 %40, 5
  %42 = or i32 %34, %41
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %43, i32 0, i32 7
  %45 = load i32, ptr %44, align 4, !tbaa !17
  %46 = shl i32 %45, 8
  %47 = or i32 %42, %46
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %48, i32 0, i32 6
  %50 = load i32, ptr %49, align 4, !tbaa !18
  %51 = shl i32 %50, 9
  %52 = or i32 %47, %51
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 4, !tbaa !19
  %56 = shl i32 %55, 10
  %57 = or i32 %52, %56
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !20
  %61 = shl i32 %60, 31
  %62 = or i32 %57, %61
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ETH_MACFilterConfigTypeDef, ptr %63, i32 0, i32 10
  %65 = load i32, ptr %64, align 4, !tbaa !21
  %66 = or i32 %62, %65
  store i32 %66, ptr %6, align 4, !tbaa !22
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ETH_HandleTypeDef, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !23
  %70 = getelementptr inbounds %struct.ETH_TypeDef, ptr %69, i32 0, i32 2
  %71 = load volatile i32, ptr %70, align 4, !tbaa !28
  %72 = and i32 %71, 2147481600
  %73 = load i32, ptr %6, align 4, !tbaa !22
  %74 = or i32 %72, %73
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ETH_HandleTypeDef, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !23
  %78 = getelementptr inbounds %struct.ETH_TypeDef, ptr %77, i32 0, i32 2
  store volatile i32 %74, ptr %78, align 4, !tbaa !28
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %79

79:                                               ; preds = %11, %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %80 = load i32, ptr %3, align 4
  ret i32 %80
}

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 0}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 12}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 32}
!15 = !{!10, !11, i64 20}
!16 = !{!10, !11, i64 36}
!17 = !{!10, !11, i64 28}
!18 = !{!10, !11, i64 24}
!19 = !{!10, !11, i64 8}
!20 = !{!10, !11, i64 4}
!21 = !{!10, !11, i64 40}
!22 = !{!11, !11, i64 0}
!23 = !{!24, !6, i64 0}
!24 = !{!"", !6, i64 0, !25, i64 8, !26, i64 48, !27, i64 68, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132}
!25 = !{!"", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !11, i64 32}
!26 = !{!"", !7, i64 0, !11, i64 16}
!27 = !{!"", !7, i64 0, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!28 = !{!29, !11, i64 8}
!29 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !7, i64 24, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !7, i64 104, !11, i64 112, !7, i64 116, !11, i64 144, !7, i64 148, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192, !11, i64 196, !7, i64 200, !11, i64 208, !11, i64 212, !11, i64 216, !11, i64 220, !7, i64 224, !11, i64 272, !11, i64 276, !11, i64 280, !11, i64 284, !11, i64 288, !11, i64 292, !7, i64 296, !11, i64 512, !11, i64 516, !7, i64 520, !11, i64 528, !7, i64 532, !11, i64 768, !11, i64 772, !11, i64 776, !11, i64 780, !11, i64 784, !11, i64 788, !11, i64 792, !11, i64 796, !7, i64 800, !11, i64 1792, !11, i64 1796, !11, i64 1800, !11, i64 1804, !11, i64 1808, !7, i64 1812, !11, i64 1868, !11, i64 1872, !7, i64 1876, !11, i64 1896, !7, i64 1900, !11, i64 1940, !11, i64 1944, !7, i64 1948, !11, i64 1988, !7, i64 1992, !11, i64 2028, !11, i64 2032, !11, i64 2036, !11, i64 2040, !7, i64 2044, !11, i64 2304, !11, i64 2308, !7, i64 2312, !11, i64 2320, !11, i64 2324, !11, i64 2328, !11, i64 2332, !7, i64 2336, !11, i64 2352, !11, i64 2356, !7, i64 2360, !11, i64 2368, !11, i64 2372, !11, i64 2376, !11, i64 2380, !7, i64 2384, !11, i64 2816, !11, i64 2820, !11, i64 2824, !11, i64 2828, !11, i64 2832, !11, i64 2836, !11, i64 2840, !11, i64 2844, !11, i64 2848, !7, i64 2852, !11, i64 2864, !11, i64 2868, !7, i64 2872, !11, i64 2880, !11, i64 2884, !11, i64 2888, !11, i64 2892, !11, i64 2896, !11, i64 2900, !11, i64 2904, !11, i64 2908, !7, i64 2912, !11, i64 2928, !7, i64 2932, !11, i64 2944, !11, i64 2948, !11, i64 2952, !11, i64 2956, !7, i64 2960, !11, i64 3008, !11, i64 3012, !11, i64 3016, !11, i64 3020, !11, i64 3024, !7, i64 3028, !11, i64 3072, !7, i64 3076, !11, i64 3104, !7, i64 3108, !11, i64 3328, !11, i64 3332, !11, i64 3336, !7, i64 3340, !11, i64 3372, !11, i64 3376, !11, i64 3380, !11, i64 3384, !7, i64 3388, !11, i64 4096, !11, i64 4100, !11, i64 4104, !11, i64 4108, !7, i64 4112, !11, i64 4352, !11, i64 4356, !11, i64 4360, !7, i64 4364, !11, i64 4372, !11, i64 4376, !11, i64 4380, !11, i64 4384, !11, i64 4388, !11, i64 4392, !11, i64 4396, !11, i64 4400, !11, i64 4404, !11, i64 4408, !11, i64 4412, !11, i64 4416, !11, i64 4420, !11, i64 4424, !11, i64 4428, !11, i64 4432, !11, i64 4436, !11, i64 4440, !11, i64 4444, !11, i64 4448, !7, i64 4452, !11, i64 4460}


; 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: nofree norecurse nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_ETH_SetMACFilterConfig(ptr nocapture noundef readonly %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %1, null
  br i1 %3, label %20, label %4

4:                                                ; preds = %2
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 36
  %7 = load i32, ptr %6, align 4, !tbaa !10
  %8 = icmp eq i32 %7, 0
  %9 = select i1 %8, i32 32, i32 0
  %10 = getelementptr inbounds i8, ptr %1, i64 4
  %11 = load <8 x i32>, ptr %10, align 4, !tbaa !11
  %12 = shl <8 x i32> %11, <i32 31, i32 10, i32 1, i32 2, i32 4, i32 9, i32 8, i32 3>
  %13 = getelementptr inbounds i8, ptr %1, i64 40
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = load ptr, ptr %0, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load volatile i32, ptr %16, align 4, !tbaa !19
  %18 = and i32 %17, 2147481600
  %19 = tail call i32 @llvm.vector.reduce.or.v8i32(<8 x i32> %12)
  %op.rdx = or i32 %19, %5
  %op.rdx16 = or i32 %14, %18
  %op.rdx17 = or i32 %op.rdx, %op.rdx16
  %op.rdx18 = or i32 %op.rdx17, %9
  store volatile i32 %op.rdx18, ptr %16, align 4, !tbaa !19
  br label %20

20:                                               ; preds = %2, %4
  %.0 = phi i32 [ 0, %4 ], [ 1, %2 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.or.v8i32(<8 x i32>) #1

attributes #0 = { nofree norecurse 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 speculatable willreturn memory(none) }

!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, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 36}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 40}
!13 = !{!14, !15, i64 0}
!14 = !{!"", !15, i64 0, !16, i64 8, !17, i64 48, !18, i64 68, !7, i64 104, !7, i64 108, !7, i64 112, !7, i64 116, !7, i64 120, !7, i64 124, !7, i64 128, !7, i64 132}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"", !15, i64 0, !7, i64 8, !15, i64 16, !15, i64 24, !7, i64 32}
!17 = !{!"", !8, i64 0, !7, i64 16}
!18 = !{!"", !8, i64 0, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32}
!19 = !{!20, !7, i64 8}
!20 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !8, i64 24, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !8, i64 104, !7, i64 112, !8, i64 116, !7, i64 144, !8, i64 148, !7, i64 176, !7, i64 180, !7, i64 184, !7, i64 188, !7, i64 192, !7, i64 196, !8, i64 200, !7, i64 208, !7, i64 212, !7, i64 216, !7, i64 220, !8, i64 224, !7, i64 272, !7, i64 276, !7, i64 280, !7, i64 284, !7, i64 288, !7, i64 292, !8, i64 296, !7, i64 512, !7, i64 516, !8, i64 520, !7, i64 528, !8, i64 532, !7, i64 768, !7, i64 772, !7, i64 776, !7, i64 780, !7, i64 784, !7, i64 788, !7, i64 792, !7, i64 796, !8, i64 800, !7, i64 1792, !7, i64 1796, !7, i64 1800, !7, i64 1804, !7, i64 1808, !8, i64 1812, !7, i64 1868, !7, i64 1872, !8, i64 1876, !7, i64 1896, !8, i64 1900, !7, i64 1940, !7, i64 1944, !8, i64 1948, !7, i64 1988, !8, i64 1992, !7, i64 2028, !7, i64 2032, !7, i64 2036, !7, i64 2040, !8, i64 2044, !7, i64 2304, !7, i64 2308, !8, i64 2312, !7, i64 2320, !7, i64 2324, !7, i64 2328, !7, i64 2332, !8, i64 2336, !7, i64 2352, !7, i64 2356, !8, i64 2360, !7, i64 2368, !7, i64 2372, !7, i64 2376, !7, i64 2380, !8, i64 2384, !7, i64 2816, !7, i64 2820, !7, i64 2824, !7, i64 2828, !7, i64 2832, !7, i64 2836, !7, i64 2840, !7, i64 2844, !7, i64 2848, !8, i64 2852, !7, i64 2864, !7, i64 2868, !8, i64 2872, !7, i64 2880, !7, i64 2884, !7, i64 2888, !7, i64 2892, !7, i64 2896, !7, i64 2900, !7, i64 2904, !7, i64 2908, !8, i64 2912, !7, i64 2928, !8, i64 2932, !7, i64 2944, !7, i64 2948, !7, i64 2952, !7, i64 2956, !8, i64 2960, !7, i64 3008, !7, i64 3012, !7, i64 3016, !7, i64 3020, !7, i64 3024, !8, i64 3028, !7, i64 3072, !8, i64 3076, !7, i64 3104, !8, i64 3108, !7, i64 3328, !7, i64 3332, !7, i64 3336, !8, i64 3340, !7, i64 3372, !7, i64 3376, !7, i64 3380, !7, i64 3384, !8, i64 3388, !7, i64 4096, !7, i64 4100, !7, i64 4104, !7, i64 4108, !8, i64 4112, !7, i64 4352, !7, i64 4356, !7, i64 4360, !8, i64 4364, !7, i64 4372, !7, i64 4376, !7, i64 4380, !7, i64 4384, !7, i64 4388, !7, i64 4392, !7, i64 4396, !7, i64 4400, !7, i64 4404, !7, i64 4408, !7, i64 4412, !7, i64 4416, !7, i64 4420, !7, i64 4424, !7, i64 4428, !7, i64 4432, !7, i64 4436, !7, i64 4440, !7, i64 4444, !7, i64 4448, !8, i64 4452, !7, i64 4460}


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