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

; 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

declare i32 @HAL_RCC_GetHCLKFreq() #1

; Function Attrs: nounwind uwtable
define dso_local void @HAL_ETH_SetMDIOClockRange(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.ETH_HandleTypeDef, ptr %5, i32 0, i32 0
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.ETH_TypeDef, ptr %7, i32 0, i32 37
  %9 = load volatile i32, ptr %8, align 4, !tbaa !15
  store i32 %9, ptr %3, align 4, !tbaa !17
  %10 = load i32, ptr %3, align 4, !tbaa !17
  %11 = zext i32 %10 to i64
  %12 = and i64 %11, -3841
  %13 = trunc i64 %12 to i32
  store i32 %13, ptr %3, align 4, !tbaa !17
  %14 = call i32 @HAL_RCC_GetHCLKFreq()
  store i32 %14, ptr %4, align 4, !tbaa !17
  %15 = load i32, ptr %4, align 4, !tbaa !17
  %16 = icmp uge i32 %15, 20000000
  br i1 %16, label %17, label %23

17:                                               ; preds = %1
  %18 = load i32, ptr %4, align 4, !tbaa !17
  %19 = icmp ult i32 %18, 35000000
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %21 = load i32, ptr %3, align 4, !tbaa !17
  %22 = or i32 %21, 512
  store i32 %22, ptr %3, align 4, !tbaa !17
  br label %56

23:                                               ; preds = %17, %1
  %24 = load i32, ptr %4, align 4, !tbaa !17
  %25 = icmp uge i32 %24, 35000000
  br i1 %25, label %26, label %32

26:                                               ; preds = %23
  %27 = load i32, ptr %4, align 4, !tbaa !17
  %28 = icmp ult i32 %27, 60000000
  br i1 %28, label %29, label %32

29:                                               ; preds = %26
  %30 = load i32, ptr %3, align 4, !tbaa !17
  %31 = or i32 %30, 768
  store i32 %31, ptr %3, align 4, !tbaa !17
  br label %55

32:                                               ; preds = %26, %23
  %33 = load i32, ptr %4, align 4, !tbaa !17
  %34 = icmp uge i32 %33, 60000000
  br i1 %34, label %35, label %41

35:                                               ; preds = %32
  %36 = load i32, ptr %4, align 4, !tbaa !17
  %37 = icmp ult i32 %36, 100000000
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = load i32, ptr %3, align 4, !tbaa !17
  %40 = or i32 %39, 0
  store i32 %40, ptr %3, align 4, !tbaa !17
  br label %54

41:                                               ; preds = %35, %32
  %42 = load i32, ptr %4, align 4, !tbaa !17
  %43 = icmp uge i32 %42, 100000000
  br i1 %43, label %44, label %50

44:                                               ; preds = %41
  %45 = load i32, ptr %4, align 4, !tbaa !17
  %46 = icmp ult i32 %45, 150000000
  br i1 %46, label %47, label %50

47:                                               ; preds = %44
  %48 = load i32, ptr %3, align 4, !tbaa !17
  %49 = or i32 %48, 256
  store i32 %49, ptr %3, align 4, !tbaa !17
  br label %53

50:                                               ; preds = %44, %41
  %51 = load i32, ptr %3, align 4, !tbaa !17
  %52 = or i32 %51, 1024
  store i32 %52, ptr %3, align 4, !tbaa !17
  br label %53

53:                                               ; preds = %50, %47
  br label %54

54:                                               ; preds = %53, %38
  br label %55

55:                                               ; preds = %54, %29
  br label %56

56:                                               ; preds = %55, %20
  %57 = load i32, ptr %3, align 4, !tbaa !17
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ETH_HandleTypeDef, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.ETH_TypeDef, ptr %60, i32 0, i32 37
  store volatile i32 %57, ptr %61, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

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

declare i32 @HAL_RCC_GetHCLKFreq() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @HAL_ETH_SetMDIOClockRange(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 512
  %4 = load volatile i32, ptr %3, align 4, !tbaa !14
  %5 = and i32 %4, -3841
  %6 = tail call i32 @HAL_RCC_GetHCLKFreq() #2
  %7 = add i32 %6, -20000000
  %or.cond = icmp ult i32 %7, 15000000
  br i1 %or.cond, label %8, label %10

8:                                                ; preds = %1
  %9 = or disjoint i32 %5, 512
  br label %22

10:                                               ; preds = %1
  %11 = add i32 %6, -35000000
  %or.cond3 = icmp ult i32 %11, 25000000
  br i1 %or.cond3, label %12, label %14

12:                                               ; preds = %10
  %13 = or disjoint i32 %5, 768
  br label %22

14:                                               ; preds = %10
  %15 = add i32 %6, -60000000
  %or.cond5 = icmp ult i32 %15, 40000000
  br i1 %or.cond5, label %22, label %16

16:                                               ; preds = %14
  %17 = add i32 %6, -100000000
  %or.cond7 = icmp ult i32 %17, 50000000
  br i1 %or.cond7, label %18, label %20

18:                                               ; preds = %16
  %19 = or disjoint i32 %5, 256
  br label %22

20:                                               ; preds = %16
  %21 = or disjoint i32 %5, 1024
  br label %22

22:                                               ; preds = %14, %12, %18, %20, %8
  %.0 = phi i32 [ %9, %8 ], [ %13, %12 ], [ %19, %18 ], [ %21, %20 ], [ %5, %14 ]
  %23 = load ptr, ptr %0, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 512
  store volatile i32 %.0, ptr %24, align 4, !tbaa !14
  ret void
}

attributes #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 = { 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, !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 = !{!15, !11, i64 512}
!15 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !8, i64 24, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !8, i64 104, !11, i64 112, !8, i64 116, !11, i64 144, !8, i64 148, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192, !11, i64 196, !8, i64 200, !11, i64 208, !11, i64 212, !11, i64 216, !11, i64 220, !8, i64 224, !11, i64 272, !11, i64 276, !11, i64 280, !11, i64 284, !11, i64 288, !11, i64 292, !8, i64 296, !11, i64 512, !11, i64 516, !8, i64 520, !11, i64 528, !8, 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, !8, i64 800, !11, i64 1792, !11, i64 1796, !11, i64 1800, !11, i64 1804, !11, i64 1808, !8, i64 1812, !11, i64 1868, !11, i64 1872, !8, i64 1876, !11, i64 1896, !8, i64 1900, !11, i64 1940, !11, i64 1944, !8, i64 1948, !11, i64 1988, !8, i64 1992, !11, i64 2028, !11, i64 2032, !11, i64 2036, !11, i64 2040, !8, i64 2044, !11, i64 2304, !11, i64 2308, !8, i64 2312, !11, i64 2320, !11, i64 2324, !11, i64 2328, !11, i64 2332, !8, i64 2336, !11, i64 2352, !11, i64 2356, !8, i64 2360, !11, i64 2368, !11, i64 2372, !11, i64 2376, !11, i64 2380, !8, 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, !8, i64 2852, !11, i64 2864, !11, i64 2868, !8, 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, !8, i64 2912, !11, i64 2928, !8, i64 2932, !11, i64 2944, !11, i64 2948, !11, i64 2952, !11, i64 2956, !8, i64 2960, !11, i64 3008, !11, i64 3012, !11, i64 3016, !11, i64 3020, !11, i64 3024, !8, i64 3028, !11, i64 3072, !8, i64 3076, !11, i64 3104, !8, i64 3108, !11, i64 3328, !11, i64 3332, !11, i64 3336, !8, i64 3340, !11, i64 3372, !11, i64 3376, !11, i64 3380, !11, i64 3384, !8, i64 3388, !11, i64 4096, !11, i64 4100, !11, i64 4104, !11, i64 4108, !8, i64 4112, !11, i64 4352, !11, i64 4356, !11, i64 4360, !8, 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, !8, i64 4452, !11, i64 4460}


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