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

; 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.RTC_HandleTypeDef = type { ptr, %struct.RTC_InitTypeDef, i32, i32 }
%struct.RTC_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.RTC_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, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_RTC_Init(ptr noundef %0) #0 {
  %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) #2
  store i32 1, ptr %3, align 4, !tbaa !9
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp ne ptr %4, null
  br i1 %5, label %6, label %131

6:                                                ; preds = %1
  store i32 0, ptr %3, align 4, !tbaa !9
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %7, i32 0, i32 3
  %9 = load volatile i32, ptr %8, align 8, !tbaa !11
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %15

11:                                               ; preds = %6
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %12, i32 0, i32 2
  store i32 0, ptr %13, align 4, !tbaa !14
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_RTC_MspInit(ptr noundef %14)
  br label %15

15:                                               ; preds = %11, %6
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %16, i32 0, i32 3
  store volatile i32 2, ptr %17, align 8, !tbaa !11
  br label %18

18:                                               ; preds = %15
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds %struct.RTC_TypeDef, ptr %21, i32 0, i32 9
  store volatile i32 202, ptr %22, align 4, !tbaa !16
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = getelementptr inbounds %struct.RTC_TypeDef, ptr %25, i32 0, i32 9
  store volatile i32 83, ptr %26, align 4, !tbaa !16
  br label %27

27:                                               ; preds = %18
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = call i32 @RTC_EnterInitMode(ptr noundef %29)
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %42

32:                                               ; preds = %28
  br label %33

33:                                               ; preds = %32
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = getelementptr inbounds %struct.RTC_TypeDef, ptr %36, i32 0, i32 9
  store volatile i32 255, ptr %37, align 4, !tbaa !16
  br label %38

38:                                               ; preds = %33
  br label %39

39:                                               ; preds = %38
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %40, i32 0, i32 3
  store volatile i32 4, ptr %41, align 8, !tbaa !11
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %130

42:                                               ; preds = %28
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = getelementptr inbounds %struct.RTC_TypeDef, ptr %45, i32 0, i32 2
  %47 = load volatile i32, ptr %46, align 4, !tbaa !18
  %48 = zext i32 %47 to i64
  %49 = and i64 %48, -7340097
  %50 = trunc i64 %49 to i32
  store volatile i32 %50, ptr %46, align 4, !tbaa !18
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds %struct.RTC_InitTypeDef, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !19
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.RTC_InitTypeDef, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 4, !tbaa !20
  %59 = or i32 %54, %58
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %60, i32 0, i32 1
  %62 = getelementptr inbounds %struct.RTC_InitTypeDef, ptr %61, i32 0, i32 5
  %63 = load i32, ptr %62, align 4, !tbaa !21
  %64 = or i32 %59, %63
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  %68 = getelementptr inbounds %struct.RTC_TypeDef, ptr %67, i32 0, i32 2
  %69 = load volatile i32, ptr %68, align 4, !tbaa !18
  %70 = or i32 %69, %64
  store volatile i32 %70, ptr %68, align 4, !tbaa !18
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %71, i32 0, i32 1
  %73 = getelementptr inbounds %struct.RTC_InitTypeDef, ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 8, !tbaa !22
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  %78 = getelementptr inbounds %struct.RTC_TypeDef, ptr %77, i32 0, i32 4
  store volatile i32 %74, ptr %78, align 4, !tbaa !23
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %79, i32 0, i32 1
  %81 = getelementptr inbounds %struct.RTC_InitTypeDef, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !24
  %83 = shl i32 %82, 16
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %84, i32 0, i32 0
  %86 = load ptr, ptr %85, align 8, !tbaa !15
  %87 = getelementptr inbounds %struct.RTC_TypeDef, ptr %86, i32 0, i32 4
  %88 = load volatile i32, ptr %87, align 4, !tbaa !23
  %89 = or i32 %88, %83
  store volatile i32 %89, ptr %87, align 4, !tbaa !23
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !15
  %93 = getelementptr inbounds %struct.RTC_TypeDef, ptr %92, i32 0, i32 3
  %94 = load volatile i32, ptr %93, align 4, !tbaa !25
  %95 = zext i32 %94 to i64
  %96 = and i64 %95, -129
  %97 = trunc i64 %96 to i32
  store volatile i32 %97, ptr %93, align 4, !tbaa !25
  %98 = load ptr, ptr %2, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !15
  %101 = getelementptr inbounds %struct.RTC_TypeDef, ptr %100, i32 0, i32 19
  %102 = load volatile i32, ptr %101, align 4, !tbaa !26
  %103 = zext i32 %102 to i64
  %104 = and i64 %103, -4
  %105 = trunc i64 %104 to i32
  store volatile i32 %105, ptr %101, align 4, !tbaa !26
  %106 = load ptr, ptr %2, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %106, i32 0, i32 1
  %108 = getelementptr inbounds %struct.RTC_InitTypeDef, ptr %107, i32 0, i32 6
  %109 = load i32, ptr %108, align 8, !tbaa !27
  %110 = load ptr, ptr %2, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %110, i32 0, i32 1
  %112 = getelementptr inbounds %struct.RTC_InitTypeDef, ptr %111, i32 0, i32 4
  %113 = load i32, ptr %112, align 8, !tbaa !28
  %114 = or i32 %109, %113
  %115 = load ptr, ptr %2, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %115, i32 0, i32 0
  %117 = load ptr, ptr %116, align 8, !tbaa !15
  %118 = getelementptr inbounds %struct.RTC_TypeDef, ptr %117, i32 0, i32 19
  %119 = load volatile i32, ptr %118, align 4, !tbaa !26
  %120 = or i32 %119, %114
  store volatile i32 %120, ptr %118, align 4, !tbaa !26
  br label %121

121:                                              ; preds = %42
  %122 = load ptr, ptr %2, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %122, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !15
  %125 = getelementptr inbounds %struct.RTC_TypeDef, ptr %124, i32 0, i32 9
  store volatile i32 255, ptr %125, align 4, !tbaa !16
  br label %126

126:                                              ; preds = %121
  br label %127

127:                                              ; preds = %126
  %128 = load ptr, ptr %2, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %128, i32 0, i32 3
  store volatile i32 1, ptr %129, align 8, !tbaa !11
  br label %130

130:                                              ; preds = %127, %39
  br label %131

131:                                              ; preds = %130, %1
  %132 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %132
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_RTC_MspInit(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @RTC_EnterInitMode(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 40}
!12 = !{!"", !6, i64 0, !13, i64 8, !10, i64 36, !10, i64 40}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!14 = !{!12, !10, i64 36}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !10, i64 36}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192, !10, i64 196, !10, i64 200, !10, i64 204}
!18 = !{!17, !10, i64 8}
!19 = !{!12, !10, i64 8}
!20 = !{!12, !10, i64 20}
!21 = !{!12, !10, i64 28}
!22 = !{!12, !10, i64 16}
!23 = !{!17, !10, i64 16}
!24 = !{!12, !10, i64 12}
!25 = !{!17, !10, i64 12}
!26 = !{!17, !10, i64 76}
!27 = !{!12, !10, i64 32}
!28 = !{!12, !10, i64 24}


; 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 range(i32 0, 2) i32 @HAL_RTC_Init(ptr noundef %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %49, label %2

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load volatile i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %8

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 0, ptr %7, align 4, !tbaa !12
  tail call void @HAL_RTC_MspInit(ptr noundef nonnull %0)
  br label %8

8:                                                ; preds = %6, %2
  store volatile i32 2, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %0, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %9, i64 36
  store volatile i32 202, ptr %10, align 4, !tbaa !14
  store volatile i32 83, ptr %10, align 4, !tbaa !14
  %11 = tail call i32 @RTC_EnterInitMode(ptr noundef nonnull %0)
  %.not27 = icmp eq i32 %11, 0
  %12 = load ptr, ptr %0, align 8, !tbaa !13
  br i1 %.not27, label %13, label %.sink.split

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %12, i64 8
  %15 = load volatile i32, ptr %14, align 4, !tbaa !16
  %16 = and i32 %15, -7340097
  store volatile i32 %16, ptr %14, align 4, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load i32, ptr %17, align 8, !tbaa !17
  %19 = getelementptr inbounds i8, ptr %0, i64 20
  %20 = load i32, ptr %19, align 4, !tbaa !18
  %21 = or i32 %20, %18
  %22 = getelementptr inbounds i8, ptr %0, i64 28
  %23 = load i32, ptr %22, align 4, !tbaa !19
  %24 = or i32 %21, %23
  %25 = load volatile i32, ptr %14, align 4, !tbaa !16
  %26 = or i32 %24, %25
  store volatile i32 %26, ptr %14, align 4, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %0, i64 16
  %28 = load i32, ptr %27, align 8, !tbaa !20
  %29 = getelementptr inbounds i8, ptr %12, i64 16
  store volatile i32 %28, ptr %29, align 4, !tbaa !21
  %30 = getelementptr inbounds i8, ptr %0, i64 12
  %31 = load i32, ptr %30, align 4, !tbaa !22
  %32 = shl i32 %31, 16
  %33 = load volatile i32, ptr %29, align 4, !tbaa !21
  %34 = or i32 %33, %32
  store volatile i32 %34, ptr %29, align 4, !tbaa !21
  %35 = getelementptr inbounds i8, ptr %12, i64 12
  %36 = load volatile i32, ptr %35, align 4, !tbaa !23
  %37 = and i32 %36, -129
  store volatile i32 %37, ptr %35, align 4, !tbaa !23
  %38 = getelementptr inbounds i8, ptr %12, i64 76
  %39 = load volatile i32, ptr %38, align 4, !tbaa !24
  %40 = and i32 %39, -4
  store volatile i32 %40, ptr %38, align 4, !tbaa !24
  %41 = getelementptr inbounds i8, ptr %0, i64 32
  %42 = load i32, ptr %41, align 8, !tbaa !25
  %43 = getelementptr inbounds i8, ptr %0, i64 24
  %44 = load i32, ptr %43, align 8, !tbaa !26
  %45 = or i32 %44, %42
  %46 = load volatile i32, ptr %38, align 4, !tbaa !24
  %47 = or i32 %45, %46
  store volatile i32 %47, ptr %38, align 4, !tbaa !24
  br label %.sink.split

.sink.split:                                      ; preds = %8, %13
  %.sink = phi i32 [ 1, %13 ], [ 4, %8 ]
  %.0.ph = phi i32 [ 0, %13 ], [ 1, %8 ]
  %48 = getelementptr inbounds i8, ptr %12, i64 36
  store volatile i32 255, ptr %48, align 4, !tbaa !14
  store volatile i32 %.sink, ptr %3, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %.sink.split, %1
  %.0 = phi i32 [ 1, %1 ], [ %.0.ph, %.sink.split ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_RTC_MspInit(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @RTC_EnterInitMode(ptr noundef) local_unnamed_addr #0

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, !11, i64 40}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 36, !11, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 36}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !11, i64 36}
!15 = !{!"", !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, !11, i64 172, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192, !11, i64 196, !11, i64 200, !11, i64 204}
!16 = !{!15, !11, i64 8}
!17 = !{!6, !11, i64 8}
!18 = !{!6, !11, i64 20}
!19 = !{!6, !11, i64 28}
!20 = !{!6, !11, i64 16}
!21 = !{!15, !11, i64 16}
!22 = !{!6, !11, i64 12}
!23 = !{!15, !11, i64 12}
!24 = !{!15, !11, i64 76}
!25 = !{!6, !11, i64 32}
!26 = !{!6, !11, i64 24}


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