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

; 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.PWR_PVDTypeDef = type { i32, i32 }
%struct.EXTI_TypeDef = type { i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @HAL_PWR_ConfigPVD(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %6

5:                                                ; preds = %1
  br label %75

6:                                                ; preds = %1
  %7 = load volatile i32, ptr inttoptr (i64 1476544512 to ptr), align 4, !tbaa !9
  %8 = zext i32 %7 to i64
  %9 = and i64 %8, -225
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.PWR_PVDTypeDef, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 4, !tbaa !12
  %13 = zext i32 %12 to i64
  %14 = or i64 %9, %13
  %15 = trunc i64 %14 to i32
  store volatile i32 %15, ptr inttoptr (i64 1476544512 to ptr), align 4, !tbaa !9
  %16 = load volatile i32, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 22), align 4, !tbaa !14
  %17 = zext i32 %16 to i64
  %18 = and i64 %17, -65537
  %19 = trunc i64 %18 to i32
  store volatile i32 %19, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 22), align 4, !tbaa !14
  %20 = load volatile i32, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 21), align 4, !tbaa !16
  %21 = zext i32 %20 to i64
  %22 = and i64 %21, -65537
  %23 = trunc i64 %22 to i32
  store volatile i32 %23, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 21), align 4, !tbaa !16
  %24 = load volatile i32, ptr inttoptr (i64 1476395008 to ptr), align 4, !tbaa !17
  %25 = zext i32 %24 to i64
  %26 = and i64 %25, -65537
  %27 = trunc i64 %26 to i32
  store volatile i32 %27, ptr inttoptr (i64 1476395008 to ptr), align 4, !tbaa !17
  %28 = load volatile i32, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 1), align 4, !tbaa !18
  %29 = zext i32 %28 to i64
  %30 = and i64 %29, -65537
  %31 = trunc i64 %30 to i32
  store volatile i32 %31, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 1), align 4, !tbaa !18
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.PWR_PVDTypeDef, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !19
  %35 = and i32 %34, 65536
  %36 = icmp eq i32 %35, 65536
  br i1 %36, label %37, label %42

37:                                               ; preds = %6
  %38 = load volatile i32, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 21), align 4, !tbaa !16
  %39 = zext i32 %38 to i64
  %40 = or i64 %39, 65536
  %41 = trunc i64 %40 to i32
  store volatile i32 %41, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 21), align 4, !tbaa !16
  br label %42

42:                                               ; preds = %37, %6
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.PWR_PVDTypeDef, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !19
  %46 = and i32 %45, 131072
  %47 = icmp eq i32 %46, 131072
  br i1 %47, label %48, label %53

48:                                               ; preds = %42
  %49 = load volatile i32, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 22), align 4, !tbaa !14
  %50 = zext i32 %49 to i64
  %51 = or i64 %50, 65536
  %52 = trunc i64 %51 to i32
  store volatile i32 %52, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 22), align 4, !tbaa !14
  br label %53

53:                                               ; preds = %48, %42
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.PWR_PVDTypeDef, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !19
  %57 = and i32 %56, 1
  %58 = icmp eq i32 %57, 1
  br i1 %58, label %59, label %64

59:                                               ; preds = %53
  %60 = load volatile i32, ptr inttoptr (i64 1476395008 to ptr), align 4, !tbaa !17
  %61 = zext i32 %60 to i64
  %62 = or i64 %61, 65536
  %63 = trunc i64 %62 to i32
  store volatile i32 %63, ptr inttoptr (i64 1476395008 to ptr), align 4, !tbaa !17
  br label %64

64:                                               ; preds = %59, %53
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.PWR_PVDTypeDef, ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 4, !tbaa !19
  %68 = and i32 %67, 2
  %69 = icmp eq i32 %68, 2
  br i1 %69, label %70, label %75

70:                                               ; preds = %64
  %71 = load volatile i32, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 1), align 4, !tbaa !18
  %72 = zext i32 %71 to i64
  %73 = or i64 %72, 65536
  %74 = trunc i64 %73 to i32
  store volatile i32 %74, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 1), align 4, !tbaa !18
  br label %75

75:                                               ; preds = %70, %64, %5
  ret void
}

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, !11, i64 0}
!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 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"", !11, i64 0, !11, i64 4}
!14 = !{!15, !11, i64 132}
!15 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !7, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !7, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !7, i64 88, !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}
!16 = !{!15, !11, i64 128}
!17 = !{!15, !11, i64 0}
!18 = !{!15, !11, i64 4}
!19 = !{!13, !11, i64 4}


; 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: nofree norecurse nounwind uwtable
define dso_local void @HAL_PWR_ConfigPVD(ptr noundef readonly %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %37, label %3

3:                                                ; preds = %1
  %4 = load volatile i32, ptr inttoptr (i64 1476544512 to ptr), align 2048, !tbaa !5
  %5 = and i32 %4, -225
  %6 = load i32, ptr %0, align 4, !tbaa !10
  %7 = or i32 %5, %6
  store volatile i32 %7, ptr inttoptr (i64 1476544512 to ptr), align 2048, !tbaa !5
  %8 = load volatile i32, ptr inttoptr (i64 1476395140 to ptr), align 4, !tbaa !12
  %9 = and i32 %8, -65537
  store volatile i32 %9, ptr inttoptr (i64 1476395140 to ptr), align 4, !tbaa !12
  %10 = load volatile i32, ptr inttoptr (i64 1476395136 to ptr), align 128, !tbaa !14
  %11 = and i32 %10, -65537
  store volatile i32 %11, ptr inttoptr (i64 1476395136 to ptr), align 128, !tbaa !14
  %12 = load volatile i32, ptr inttoptr (i64 1476395008 to ptr), align 134217728, !tbaa !15
  %13 = and i32 %12, -65537
  store volatile i32 %13, ptr inttoptr (i64 1476395008 to ptr), align 134217728, !tbaa !15
  %14 = load volatile i32, ptr inttoptr (i64 1476395012 to ptr), align 4, !tbaa !16
  %15 = and i32 %14, -65537
  store volatile i32 %15, ptr inttoptr (i64 1476395012 to ptr), align 4, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %0, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !17
  %18 = and i32 %17, 65536
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %22, label %19

19:                                               ; preds = %3
  %20 = load volatile i32, ptr inttoptr (i64 1476395136 to ptr), align 128, !tbaa !14
  %21 = or i32 %20, 65536
  store volatile i32 %21, ptr inttoptr (i64 1476395136 to ptr), align 128, !tbaa !14
  br label %22

22:                                               ; preds = %19, %3
  %23 = and i32 %17, 131072
  %.not6 = icmp eq i32 %23, 0
  br i1 %.not6, label %27, label %24

24:                                               ; preds = %22
  %25 = load volatile i32, ptr inttoptr (i64 1476395140 to ptr), align 4, !tbaa !12
  %26 = or i32 %25, 65536
  store volatile i32 %26, ptr inttoptr (i64 1476395140 to ptr), align 4, !tbaa !12
  br label %27

27:                                               ; preds = %24, %22
  %28 = and i32 %17, 1
  %.not7 = icmp eq i32 %28, 0
  br i1 %.not7, label %32, label %29

29:                                               ; preds = %27
  %30 = load volatile i32, ptr inttoptr (i64 1476395008 to ptr), align 134217728, !tbaa !15
  %31 = or i32 %30, 65536
  store volatile i32 %31, ptr inttoptr (i64 1476395008 to ptr), align 134217728, !tbaa !15
  br label %32

32:                                               ; preds = %29, %27
  %33 = and i32 %17, 2
  %.not8 = icmp eq i32 %33, 0
  br i1 %.not8, label %37, label %34

34:                                               ; preds = %32
  %35 = load volatile i32, ptr inttoptr (i64 1476395012 to ptr), align 4, !tbaa !16
  %36 = or i32 %35, 65536
  store volatile i32 %36, ptr inttoptr (i64 1476395012 to ptr), align 4, !tbaa !16
  br label %37

37:                                               ; preds = %1, %34, %32
  ret void
}

attributes #0 = { nofree norecurse 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, !7, i64 0}
!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 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"", !7, i64 0, !7, i64 4}
!12 = !{!13, !7, i64 132}
!13 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !8, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !8, i64 56, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !8, i64 88, !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}
!14 = !{!13, !7, i64 128}
!15 = !{!13, !7, i64 0}
!16 = !{!13, !7, i64 4}
!17 = !{!11, !7, i64 4}


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