; LLVM IR from ctlst-tech/catpilot :: bsp/mcu/core/stm32/h753/hal/src (stm32h7xx_hal_rcc_ex)

; 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 %161

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

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 %67

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 = zext i32 %48 to i64
  %50 = lshr i64 64000000, %49
  %51 = trunc i64 %50 to i32
  store i32 %51, ptr %6, align 4, !tbaa !12
  %52 = load i32, ptr %6, align 4, !tbaa !12
  %53 = uitofp i32 %52 to float
  %54 = load i32, ptr %4, align 4, !tbaa !12
  %55 = uitofp i32 %54 to float
  %56 = fdiv float %53, %55
  %57 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 12), align 4, !tbaa !18
  %58 = zext i32 %57 to i64
  %59 = and i64 %58, 511
  %60 = trunc i64 %59 to i32
  %61 = uitofp i32 %60 to float
  %62 = load float, ptr %7, align 4, !tbaa !15
  %63 = fdiv float %62, 8.192000e+03
  %64 = fadd float %61, %63
  %65 = fadd float %64, 1.000000e+00
  %66 = fmul float %56, %65
  store float %66, ptr %8, align 4, !tbaa !15
  br label %81

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

81:                                               ; preds = %67, %43
  br label %124

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

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

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

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

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

168:                                              ; preds = %161, %124
  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 %58, label %13

13:                                               ; preds = %1
  %14 = and i32 %2, 3
  switch i32 %14, label %default.unreachable [
    i32 0, label %15
    i32 1, label %26
    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 %26, 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 %26

24:                                               ; preds = %13
  br label %26

default.unreachable:                              ; preds = %13
  unreachable

25:                                               ; preds = %13
  br label %26

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

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

60:                                               ; preds = %58, %26
  %.sink = phi i32 [ 0, %58 ], [ %57, %26 ]
  %61 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %.sink, ptr %61, 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