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

; 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 }
%struct.ETH_L4FilterConfigTypeDef = type { i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_ETHEx_GetL4FilterConfig(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  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
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

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

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

78:                                               ; preds = %11, %10
  %79 = load i32, ptr %4, align 4
  ret i32 %79
}

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

!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 = !{!17, !10, i64 0}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!18 = !{!17, !10, i64 8}
!19 = !{!17, !10, i64 4}
!20 = !{!17, !10, i64 16}
!21 = !{!17, !10, i64 12}


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

5:                                                ; preds = %3
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 2304
  %8 = zext i32 %1 to i64
  %9 = getelementptr inbounds i32, ptr %7, i64 %8
  %10 = load volatile i32, ptr %9, align 4, !tbaa !14
  %11 = and i32 %10, 65536
  store i32 %11, ptr %2, align 4, !tbaa !15
  %12 = load volatile i32, ptr %9, align 4, !tbaa !14
  %13 = and i32 %12, 3145728
  %14 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 %13, ptr %14, align 4, !tbaa !17
  %15 = load volatile i32, ptr %9, align 4, !tbaa !14
  %16 = and i32 %15, 786432
  %17 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 %16, ptr %17, align 4, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %6, i64 2308
  %19 = getelementptr inbounds i32, ptr %18, i64 %8
  %20 = load volatile i32, ptr %19, align 4, !tbaa !14
  %21 = lshr i32 %20, 16
  %22 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 %21, ptr %22, align 4, !tbaa !19
  %23 = load volatile i32, ptr %19, align 4, !tbaa !14
  %24 = and i32 %23, 65535
  %25 = getelementptr inbounds i8, ptr %2, i64 12
  store i32 %24, ptr %25, align 4, !tbaa !20
  br label %26

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

attributes #0 = { mustprogress nofree norecurse nounwind willreturn 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}
!15 = !{!16, !11, i64 0}
!16 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!17 = !{!16, !11, i64 8}
!18 = !{!16, !11, i64 4}
!19 = !{!16, !11, i64 16}
!20 = !{!16, !11, i64 12}


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