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

; 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.RCC_CRSInitTypeDef = type { i32, i32, i32, i32, i32, i32 }
%struct.CRS_TypeDef = type { i32, 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_CRSConfig(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %4 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 37), align 4, !tbaa !9
  %5 = zext i32 %4 to i64
  %6 = or i64 %5, 2
  %7 = trunc i64 %6 to i32
  store volatile i32 %7, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 37), align 4, !tbaa !9
  %8 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 37), align 4, !tbaa !9
  %9 = zext i32 %8 to i64
  %10 = and i64 %9, -3
  %11 = trunc i64 %10 to i32
  store volatile i32 %11, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 37), align 4, !tbaa !9
  %12 = call i32 @HAL_GetREVID()
  %13 = icmp ule i32 %12, 4099
  br i1 %13, label %14, label %29

14:                                               ; preds = %1
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.RCC_CRSInitTypeDef, ptr %15, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !12
  %18 = zext i32 %17 to i64
  %19 = icmp eq i64 %18, 805306368
  br i1 %19, label %20, label %29

20:                                               ; preds = %14
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.RCC_CRSInitTypeDef, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !14
  %24 = or i32 %23, 0
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.RCC_CRSInitTypeDef, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 4, !tbaa !15
  %28 = or i32 %24, %27
  store i32 %28, ptr %3, align 4, !tbaa !16
  br label %41

29:                                               ; preds = %14, %1
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.RCC_CRSInitTypeDef, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 4, !tbaa !14
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.RCC_CRSInitTypeDef, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !12
  %36 = or i32 %32, %35
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.RCC_CRSInitTypeDef, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %40 = or i32 %36, %39
  store i32 %40, ptr %3, align 4, !tbaa !16
  br label %41

41:                                               ; preds = %29, %20
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.RCC_CRSInitTypeDef, ptr %42, i32 0, i32 3
  %44 = load i32, ptr %43, align 4, !tbaa !17
  %45 = load i32, ptr %3, align 4, !tbaa !16
  %46 = or i32 %45, %44
  store i32 %46, ptr %3, align 4, !tbaa !16
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.RCC_CRSInitTypeDef, ptr %47, i32 0, i32 4
  %49 = load i32, ptr %48, align 4, !tbaa !18
  %50 = shl i32 %49, 16
  %51 = load i32, ptr %3, align 4, !tbaa !16
  %52 = or i32 %51, %50
  store i32 %52, ptr %3, align 4, !tbaa !16
  %53 = load i32, ptr %3, align 4, !tbaa !16
  store volatile i32 %53, ptr getelementptr inbounds (%struct.CRS_TypeDef, ptr inttoptr (i64 1073775616 to ptr), i32 0, i32 1), align 4, !tbaa !19
  %54 = load volatile i32, ptr inttoptr (i64 1073775616 to ptr), align 4, !tbaa !21
  %55 = zext i32 %54 to i64
  %56 = and i64 %55, -16129
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.RCC_CRSInitTypeDef, ptr %57, i32 0, i32 5
  %59 = load i32, ptr %58, align 4, !tbaa !22
  %60 = shl i32 %59, 8
  %61 = zext i32 %60 to i64
  %62 = or i64 %56, %61
  %63 = trunc i64 %62 to i32
  store volatile i32 %63, ptr inttoptr (i64 1073775616 to ptr), align 4, !tbaa !21
  %64 = load volatile i32, ptr inttoptr (i64 1073775616 to ptr), align 4, !tbaa !21
  %65 = zext i32 %64 to i64
  %66 = or i64 %65, 96
  %67 = trunc i64 %66 to i32
  store volatile i32 %67, ptr inttoptr (i64 1073775616 to ptr), align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

declare i32 @HAL_GetREVID() #2

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 = { "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, !11, i64 148}
!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 = !{!13, !11, i64 4}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!14 = !{!13, !11, i64 0}
!15 = !{!13, !11, i64 8}
!16 = !{!11, !11, i64 0}
!17 = !{!13, !11, i64 12}
!18 = !{!13, !11, i64 16}
!19 = !{!20, !11, i64 4}
!20 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!21 = !{!20, !11, i64 0}
!22 = !{!13, !11, i64 20}


; 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: nounwind uwtable
define dso_local void @HAL_RCCEx_CRSConfig(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load volatile i32, ptr inttoptr (i64 1476543636 to ptr), align 4, !tbaa !5
  %3 = or i32 %2, 2
  store volatile i32 %3, ptr inttoptr (i64 1476543636 to ptr), align 4, !tbaa !5
  %4 = load volatile i32, ptr inttoptr (i64 1476543636 to ptr), align 4, !tbaa !5
  %5 = and i32 %4, -3
  store volatile i32 %5, ptr inttoptr (i64 1476543636 to ptr), align 4, !tbaa !5
  %6 = tail call i32 @HAL_GetREVID() #2
  %7 = icmp ult i32 %6, 4100
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !10
  %10 = icmp eq i32 %9, 805306368
  %or.cond = select i1 %7, i1 %10, i1 false
  %11 = load i32, ptr %0, align 4, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = or i32 %13, %11
  %15 = or i32 %11, %13
  %16 = or i32 %15, %9
  %.0 = select i1 %or.cond, i32 %14, i32 %16
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  %18 = load i32, ptr %17, align 4, !tbaa !14
  %19 = or i32 %18, %.0
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load i32, ptr %20, align 4, !tbaa !15
  %22 = shl i32 %21, 16
  %23 = or i32 %19, %22
  store volatile i32 %23, ptr inttoptr (i64 1073775620 to ptr), align 4, !tbaa !16
  %24 = load volatile i32, ptr inttoptr (i64 1073775616 to ptr), align 1024, !tbaa !18
  %25 = and i32 %24, -16129
  %26 = getelementptr inbounds i8, ptr %0, i64 20
  %27 = load i32, ptr %26, align 4, !tbaa !19
  %28 = shl i32 %27, 8
  %29 = or i32 %28, %25
  store volatile i32 %29, ptr inttoptr (i64 1073775616 to ptr), align 1024, !tbaa !18
  %30 = load volatile i32, ptr inttoptr (i64 1073775616 to ptr), align 1024, !tbaa !18
  %31 = or i32 %30, 96
  store volatile i32 %31, ptr inttoptr (i64 1073775616 to ptr), align 1024, !tbaa !18
  ret void
}

declare i32 @HAL_GetREVID() local_unnamed_addr #1

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

!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 148}
!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 = !{!11, !7, i64 4}
!11 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!12 = !{!11, !7, i64 0}
!13 = !{!11, !7, i64 8}
!14 = !{!11, !7, i64 12}
!15 = !{!11, !7, i64 16}
!16 = !{!17, !7, i64 4}
!17 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!18 = !{!17, !7, i64 0}
!19 = !{!11, !7, i64 20}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass