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

; 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.RCC_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [9 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i32] }
%struct.PLL1_ClocksTypeDef = type { i32, 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 void @HAL_RCCEx_GetPLL1ClockFreq(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %9 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 10), align 4, !tbaa !9
  %10 = zext i32 %9 to i64
  %11 = and i64 %10, 3
  %12 = trunc i64 %11 to i32
  store i32 %12, ptr %3, align 4, !tbaa !12
  %13 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 10), align 4, !tbaa !9
  %14 = zext i32 %13 to i64
  %15 = and i64 %14, 1008
  %16 = lshr i64 %15, 4
  %17 = trunc i64 %16 to i32
  store i32 %17, ptr %4, align 4, !tbaa !12
  %18 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 11), align 4, !tbaa !13
  %19 = zext i32 %18 to i64
  %20 = and i64 %19, 1
  %21 = trunc i64 %20 to i32
  store i32 %21, ptr %5, align 4, !tbaa !12
  %22 = load i32, ptr %5, align 4, !tbaa !12
  %23 = zext i32 %22 to i64
  %24 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 13), align 4, !tbaa !14
  %25 = zext i32 %24 to i64
  %26 = and i64 %25, 65528
  %27 = lshr i64 %26, 3
  %28 = mul i64 %23, %27
  %29 = trunc i64 %28 to i32
  %30 = uitofp i32 %29 to float
  store float %30, ptr %7, align 4, !tbaa !15
  %31 = load i32, ptr %4, align 4, !tbaa !12
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %159

33:                                               ; preds = %1
  %34 = load i32, ptr %3, align 4, !tbaa !12
  switch i32 %34, label %108 [
    i32 0, label %35
    i32 1, label %80
    i32 2, label %94
  ]

35:                                               ; preds = %33
  %36 = load volatile i32, ptr inttoptr (i64 1476543488 to ptr), align 4, !tbaa !17
  %37 = zext i32 %36 to i64
  %38 = and i64 %37, 32
  %39 = icmp ne i64 %38, 0
  %40 = zext i1 %39 to i64
  %41 = select i1 %39, i32 1, i32 0
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %65

43:                                               ; preds = %35
  %44 = load volatile i32, ptr inttoptr (i64 1476543488 to ptr), align 4, !tbaa !17
  %45 = zext i32 %44 to i64
  %46 = and i64 %45, 24
  %47 = trunc i64 %46 to i32
  %48 = lshr i32 %47, 3
  %49 = lshr i32 64000000, %48
  store i32 %49, ptr %6, align 4, !tbaa !12
  %50 = load i32, ptr %6, align 4, !tbaa !12
  %51 = uitofp i32 %50 to float
  %52 = load i32, ptr %4, align 4, !tbaa !12
  %53 = uitofp i32 %52 to float
  %54 = fdiv float %51, %53
  %55 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 12), align 4, !tbaa !18
  %56 = zext i32 %55 to i64
  %57 = and i64 %56, 511
  %58 = trunc i64 %57 to i32
  %59 = uitofp i32 %58 to float
  %60 = load float, ptr %7, align 4, !tbaa !15
  %61 = fdiv float %60, 8.192000e+03
  %62 = fadd float %59, %61
  %63 = fadd float %62, 1.000000e+00
  %64 = fmul float %54, %63
  store float %64, ptr %8, align 4, !tbaa !15
  br label %79

65:                                               ; preds = %35
  %66 = load i32, ptr %4, align 4, !tbaa !12
  %67 = uitofp i32 %66 to float
  %68 = fdiv float 6.400000e+07, %67
  %69 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 12), align 4, !tbaa !18
  %70 = zext i32 %69 to i64
  %71 = and i64 %70, 511
  %72 = trunc i64 %71 to i32
  %73 = uitofp i32 %72 to float
  %74 = load float, ptr %7, align 4, !tbaa !15
  %75 = fdiv float %74, 8.192000e+03
  %76 = fadd float %73, %75
  %77 = fadd float %76, 1.000000e+00
  %78 = fmul float %68, %77
  store float %78, ptr %8, align 4, !tbaa !15
  br label %79

79:                                               ; preds = %65, %43
  br label %122

80:                                               ; preds = %33
  %81 = load i32, ptr %4, align 4, !tbaa !12
  %82 = uitofp i32 %81 to float
  %83 = fdiv float 4.000000e+06, %82
  %84 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 12), align 4, !tbaa !18
  %85 = zext i32 %84 to i64
  %86 = and i64 %85, 511
  %87 = trunc i64 %86 to i32
  %88 = uitofp i32 %87 to float
  %89 = load float, ptr %7, align 4, !tbaa !15
  %90 = fdiv float %89, 8.192000e+03
  %91 = fadd float %88, %90
  %92 = fadd float %91, 1.000000e+00
  %93 = fmul float %83, %92
  store float %93, ptr %8, align 4, !tbaa !15
  br label %122

94:                                               ; preds = %33
  %95 = load i32, ptr %4, align 4, !tbaa !12
  %96 = uitofp i32 %95 to float
  %97 = fdiv float 1.600000e+07, %96
  %98 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 12), align 4, !tbaa !18
  %99 = zext i32 %98 to i64
  %100 = and i64 %99, 511
  %101 = trunc i64 %100 to i32
  %102 = uitofp i32 %101 to float
  %103 = load float, ptr %7, align 4, !tbaa !15
  %104 = fdiv float %103, 8.192000e+03
  %105 = fadd float %102, %104
  %106 = fadd float %105, 1.000000e+00
  %107 = fmul float %97, %106
  store float %107, ptr %8, align 4, !tbaa !15
  br label %122

108:                                              ; preds = %33
  %109 = load i32, ptr %4, align 4, !tbaa !12
  %110 = uitofp i32 %109 to float
  %111 = fdiv float 4.000000e+06, %110
  %112 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 12), align 4, !tbaa !18
  %113 = zext i32 %112 to i64
  %114 = and i64 %113, 511
  %115 = trunc i64 %114 to i32
  %116 = uitofp i32 %115 to float
  %117 = load float, ptr %7, align 4, !tbaa !15
  %118 = fdiv float %117, 8.192000e+03
  %119 = fadd float %116, %118
  %120 = fadd float %119, 1.000000e+00
  %121 = fmul float %111, %120
  store float %121, ptr %8, align 4, !tbaa !15
  br label %122

122:                                              ; preds = %108, %94, %80, %79
  %123 = load float, ptr %8, align 4, !tbaa !15
  %124 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 12), align 4, !tbaa !18
  %125 = zext i32 %124 to i64
  %126 = and i64 %125, 65024
  %127 = lshr i64 %126, 9
  %128 = trunc i64 %127 to i32
  %129 = uitofp i32 %128 to float
  %130 = fadd float %129, 1.000000e+00
  %131 = fdiv float %123, %130
  %132 = fptoui float %131 to i32
  %133 = load ptr, ptr %2, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.PLL1_ClocksTypeDef, ptr %133, i32 0, i32 0
  store i32 %132, ptr %134, align 4, !tbaa !19
  %135 = load float, ptr %8, align 4, !tbaa !15
  %136 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 12), align 4, !tbaa !18
  %137 = zext i32 %136 to i64
  %138 = and i64 %137, 8323072
  %139 = lshr i64 %138, 16
  %140 = trunc i64 %139 to i32
  %141 = uitofp i32 %140 to float
  %142 = fadd float %141, 1.000000e+00
  %143 = fdiv float %135, %142
  %144 = fptoui float %143 to i32
  %145 = load ptr, ptr %2, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.PLL1_ClocksTypeDef, ptr %145, i32 0, i32 1
  store i32 %144, ptr %146, align 4, !tbaa !21
  %147 = load float, ptr %8, align 4, !tbaa !15
  %148 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 12), align 4, !tbaa !18
  %149 = zext i32 %148 to i64
  %150 = and i64 %149, 2130706432
  %151 = lshr i64 %150, 24
  %152 = trunc i64 %151 to i32
  %153 = uitofp i32 %152 to float
  %154 = fadd float %153, 1.000000e+00
  %155 = fdiv float %147, %154
  %156 = fptoui float %155 to i32
  %157 = load ptr, ptr %2, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.PLL1_ClocksTypeDef, ptr %157, i32 0, i32 2
  store i32 %156, ptr %158, align 4, !tbaa !22
  br label %166

159:                                              ; preds = %1
  %160 = load ptr, ptr %2, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.PLL1_ClocksTypeDef, ptr %160, i32 0, i32 0
  store i32 0, ptr %161, align 4, !tbaa !19
  %162 = load ptr, ptr %2, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.PLL1_ClocksTypeDef, ptr %162, i32 0, i32 1
  store i32 0, ptr %163, align 4, !tbaa !21
  %164 = load ptr, ptr %2, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.PLL1_ClocksTypeDef, ptr %164, i32 0, i32 2
  store i32 0, ptr %165, align 4, !tbaa !22
  br label %166

166:                                              ; preds = %159, %122
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

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 40}
!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, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !11, i64 152, !11, i64 156, !11, i64 160, !11, i64 164, !11, i64 168, !7, i64 172, !11, i64 208, !11, i64 212, !11, i64 216, !11, i64 220, !11, i64 224, !11, i64 228, !11, i64 232, !11, i64 236, !11, i64 240, !11, i64 244, !11, i64 248, !11, i64 252, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !11, i64 280, !11, i64 284, !7, i64 288}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 44}
!14 = !{!10, !11, i64 52}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!10, !11, i64 0}
!18 = !{!10, !11, i64 48}
!19 = !{!20, !11, i64 0}
!20 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!21 = !{!20, !11, i64 4}
!22 = !{!20, !11, i64 8}


; 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 void @HAL_RCCEx_GetPLL1ClockFreq(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
  %2 = load volatile i32, ptr inttoptr (i64 1476543528 to ptr), align 8, !tbaa !5
  %3 = load volatile i32, ptr inttoptr (i64 1476543528 to ptr), align 8, !tbaa !5
  %4 = lshr i32 %3, 4
  %5 = and i32 %4, 63
  %6 = load volatile i32, ptr inttoptr (i64 1476543532 to ptr), align 4, !tbaa !10
  %7 = load volatile i32, ptr inttoptr (i64 1476543540 to ptr), align 4, !tbaa !11
  %8 = lshr i32 %7, 3
  %9 = and i32 %8, 8191
  %10 = trunc i32 %6 to i1
  %11 = uitofp nneg i32 %9 to float
  %12 = fmul float %11, 0x3F20000000000000
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %57, label %13

13:                                               ; preds = %1
  %14 = and i32 %2, 3
  switch i32 %14, label %default.unreachable [
    i32 0, label %15
    i32 1, label %25
    i32 2, label %24
    i32 3, label %25
  ]

15:                                               ; preds = %13
  %16 = load volatile i32, ptr inttoptr (i64 1476543488 to ptr), align 1024, !tbaa !12
  %17 = and i32 %16, 32
  %.not23 = icmp eq i32 %17, 0
  br i1 %.not23, label %25, label %18

18:                                               ; preds = %15
  %19 = load volatile i32, ptr inttoptr (i64 1476543488 to ptr), align 1024, !tbaa !12
  %20 = lshr i32 %19, 3
  %21 = and i32 %20, 3
  %22 = lshr exact i32 64000000, %21
  %23 = uitofp nneg i32 %22 to float
  br label %25

24:                                               ; preds = %13
  br label %25

default.unreachable:                              ; preds = %13
  unreachable

25:                                               ; preds = %13, %13, %15, %18, %24
  %.sink30 = phi float [ %23, %18 ], [ 1.600000e+07, %24 ], [ 6.400000e+07, %15 ], [ 4.000000e+06, %13 ], [ 4.000000e+06, %13 ]
  %26 = uitofp nneg i32 %5 to float
  %27 = fdiv float %.sink30, %26
  %28 = load volatile i32, ptr inttoptr (i64 1476543536 to ptr), align 16, !tbaa !13
  %29 = and i32 %28, 511
  %30 = uitofp nneg i32 %29 to float
  %31 = select i1 %10, float %12, float 0.000000e+00
  %32 = fadd float %31, %30
  %33 = fadd float %32, 1.000000e+00
  %34 = fmul float %27, %33
  %35 = load volatile i32, ptr inttoptr (i64 1476543536 to ptr), align 16, !tbaa !13
  %36 = lshr i32 %35, 9
  %37 = and i32 %36, 127
  %38 = add nuw nsw i32 %37, 1
  %39 = uitofp nneg i32 %38 to float
  %40 = fdiv float %34, %39
  %41 = fptoui float %40 to i32
  store i32 %41, ptr %0, align 4, !tbaa !14
  %42 = load volatile i32, ptr inttoptr (i64 1476543536 to ptr), align 16, !tbaa !13
  %43 = lshr i32 %42, 16
  %44 = and i32 %43, 127
  %45 = add nuw nsw i32 %44, 1
  %46 = uitofp nneg i32 %45 to float
  %47 = fdiv float %34, %46
  %48 = fptoui float %47 to i32
  %49 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %48, ptr %49, align 4, !tbaa !16
  %50 = load volatile i32, ptr inttoptr (i64 1476543536 to ptr), align 16, !tbaa !13
  %51 = lshr i32 %50, 24
  %52 = and i32 %51, 127
  %53 = add nuw nsw i32 %52, 1
  %54 = uitofp nneg i32 %53 to float
  %55 = fdiv float %34, %54
  %56 = fptoui float %55 to i32
  br label %59

57:                                               ; preds = %1
  store i32 0, ptr %0, align 4, !tbaa !14
  %58 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 0, ptr %58, align 4, !tbaa !16
  br label %59

59:                                               ; preds = %57, %25
  %.sink = phi i32 [ 0, %57 ], [ %56, %25 ]
  %60 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %.sink, ptr %60, align 4, !tbaa !17
  ret void
}

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 40}
!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, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !7, i64 104, !7, i64 108, !7, i64 112, !7, i64 116, !7, i64 120, !7, i64 124, !7, i64 128, !7, i64 132, !7, i64 136, !7, i64 140, !7, i64 144, !7, i64 148, !7, i64 152, !7, i64 156, !7, i64 160, !7, i64 164, !7, i64 168, !8, i64 172, !7, i64 208, !7, i64 212, !7, i64 216, !7, i64 220, !7, i64 224, !7, i64 228, !7, i64 232, !7, i64 236, !7, i64 240, !7, i64 244, !7, i64 248, !7, i64 252, !7, i64 256, !7, i64 260, !7, i64 264, !7, i64 268, !7, i64 272, !7, i64 276, !7, i64 280, !7, i64 284, !8, i64 288}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 44}
!11 = !{!6, !7, i64 52}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 48}
!14 = !{!15, !7, i64 0}
!15 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!16 = !{!15, !7, i64 4}
!17 = !{!15, !7, i64 8}


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