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

; 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_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_SetSourceMACAddrMatch(ptr noundef %0, i32 noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  store i32 1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %74

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

74:                                               ; preds = %14, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %75 = load i32, ptr %4, align 4
  ret i32 %75
}

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !13, i64 8, !14, i64 48, !15, i64 68, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132}
!13 = !{!"", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !10, i64 32}
!14 = !{!"", !7, i64 0, !10, i64 16}
!15 = !{!"", !7, i64 0, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32}
!16 = !{!7, !7, 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"

; Function Attrs: nofree norecurse nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_ETH_SetSourceMACAddrMatch(ptr nocapture noundef readonly %0, i32 noundef %1, ptr noundef readonly %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %2, null
  br i1 %4, label %25, label %5

5:                                                ; preds = %3
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 768
  %8 = ptrtoint ptr %7 to i64
  %9 = trunc i64 %8 to i32
  %10 = add i32 %9, %1
  %11 = getelementptr inbounds i8, ptr %6, i64 772
  %12 = ptrtoint ptr %11 to i64
  %13 = trunc i64 %12 to i32
  %14 = add i32 %13, %1
  %15 = getelementptr i8, ptr %2, i64 4
  %16 = load i16, ptr %15, align 1
  %17 = zext i16 %16 to i32
  %18 = zext i32 %10 to i64
  %19 = inttoptr i64 %18 to ptr
  store volatile i32 %17, ptr %19, align 4, !tbaa !14
  %20 = load i32, ptr %2, align 1
  %21 = zext i32 %14 to i64
  %22 = inttoptr i64 %21 to ptr
  store volatile i32 %20, ptr %22, align 4, !tbaa !14
  %23 = load volatile i32, ptr %19, align 4, !tbaa !14
  %24 = or i32 %23, -1073741824
  store volatile i32 %24, ptr %19, align 4, !tbaa !14
  br label %25

25:                                               ; preds = %3, %5
  %.0 = phi i32 [ 0, %5 ], [ 1, %3 ]
  ret i32 %.0
}

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

!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, !12, i64 48, !13, 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}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !7, i64 0, !11, i64 8, !7, i64 16, !7, i64 24, !11, i64 32}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !8, i64 0, !11, i64 16}
!13 = !{!"", !8, i64 0, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!14 = !{!11, !11, i64 0}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass