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

; 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.EXTI_Core_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%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 void @HAL_RTC_AlarmIRQHandler(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  store volatile i32 131072, ptr getelementptr inbounds (%struct.EXTI_Core_TypeDef, ptr inttoptr (i64 1476395136 to ptr), i32 0, i32 2), align 4, !tbaa !9
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %3, i32 0, i32 0
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %6 = getelementptr inbounds %struct.RTC_TypeDef, ptr %5, i32 0, i32 2
  %7 = load volatile i32, ptr %6, align 4, !tbaa !15
  %8 = zext i32 %7 to i64
  %9 = and i64 %8, 4096
  %10 = icmp ne i64 %9, 0
  %11 = zext i1 %10 to i64
  %12 = select i1 %10, i32 1, i32 0
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %42

14:                                               ; preds = %1
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = getelementptr inbounds %struct.RTC_TypeDef, ptr %17, i32 0, i32 3
  %19 = load volatile i32, ptr %18, align 4, !tbaa !17
  %20 = zext i32 %19 to i64
  %21 = and i64 %20, 256
  %22 = icmp ne i64 %21, 0
  %23 = zext i1 %22 to i64
  %24 = select i1 %22, i32 1, i32 0
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %41

26:                                               ; preds = %14
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !12
  %30 = getelementptr inbounds %struct.RTC_TypeDef, ptr %29, i32 0, i32 3
  %31 = load volatile i32, ptr %30, align 4, !tbaa !17
  %32 = zext i32 %31 to i64
  %33 = and i64 %32, 128
  %34 = or i64 -385, %33
  %35 = trunc i64 %34 to i32
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !12
  %39 = getelementptr inbounds %struct.RTC_TypeDef, ptr %38, i32 0, i32 3
  store volatile i32 %35, ptr %39, align 4, !tbaa !17
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_RTC_AlarmAEventCallback(ptr noundef %40)
  br label %41

41:                                               ; preds = %26, %14
  br label %42

42:                                               ; preds = %41, %1
  %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 !12
  %46 = getelementptr inbounds %struct.RTC_TypeDef, ptr %45, i32 0, i32 2
  %47 = load volatile i32, ptr %46, align 4, !tbaa !15
  %48 = zext i32 %47 to i64
  %49 = and i64 %48, 8192
  %50 = icmp ne i64 %49, 0
  %51 = zext i1 %50 to i64
  %52 = select i1 %50, i32 1, i32 0
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %82

54:                                               ; preds = %42
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !12
  %58 = getelementptr inbounds %struct.RTC_TypeDef, ptr %57, i32 0, i32 3
  %59 = load volatile i32, ptr %58, align 4, !tbaa !17
  %60 = zext i32 %59 to i64
  %61 = and i64 %60, 512
  %62 = icmp ne i64 %61, 0
  %63 = zext i1 %62 to i64
  %64 = select i1 %62, i32 1, i32 0
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %81

66:                                               ; preds = %54
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !12
  %70 = getelementptr inbounds %struct.RTC_TypeDef, ptr %69, i32 0, i32 3
  %71 = load volatile i32, ptr %70, align 4, !tbaa !17
  %72 = zext i32 %71 to i64
  %73 = and i64 %72, 128
  %74 = or i64 -641, %73
  %75 = trunc i64 %74 to i32
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !12
  %79 = getelementptr inbounds %struct.RTC_TypeDef, ptr %78, i32 0, i32 3
  store volatile i32 %75, ptr %79, align 4, !tbaa !17
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_RTCEx_AlarmBEventCallback(ptr noundef %80)
  br label %81

81:                                               ; preds = %66, %54
  br label %82

82:                                               ; preds = %81, %42
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.RTC_HandleTypeDef, ptr %83, i32 0, i32 3
  store volatile i32 1, ptr %84, align 8, !tbaa !18
  ret void
}

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

declare void @HAL_RTCEx_AlarmBEventCallback(ptr noundef) #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" }

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


; 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_RTC_AlarmIRQHandler(ptr noundef %0) local_unnamed_addr #0 {
  store volatile i32 131072, ptr inttoptr (i64 1476395144 to ptr), align 8, !tbaa !5
  %2 = load ptr, ptr %0, align 8, !tbaa !10
  %3 = getelementptr inbounds i8, ptr %2, i64 8
  %4 = load volatile i32, ptr %3, align 4, !tbaa !14
  %5 = and i32 %4, 4096
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %14, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %2, i64 12
  %8 = load volatile i32, ptr %7, align 4, !tbaa !16
  %9 = and i32 %8, 256
  %.not11 = icmp eq i32 %9, 0
  br i1 %.not11, label %14, label %10

10:                                               ; preds = %6
  %11 = load volatile i32, ptr %7, align 4, !tbaa !16
  %12 = and i32 %11, 128
  %13 = or disjoint i32 %12, -385
  store volatile i32 %13, ptr %7, align 4, !tbaa !16
  tail call void @HAL_RTC_AlarmAEventCallback(ptr noundef nonnull %0)
  %.pre = load ptr, ptr %0, align 8, !tbaa !10
  br label %14

14:                                               ; preds = %6, %10, %1
  %15 = phi ptr [ %2, %6 ], [ %.pre, %10 ], [ %2, %1 ]
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load volatile i32, ptr %16, align 4, !tbaa !14
  %18 = and i32 %17, 8192
  %.not12 = icmp eq i32 %18, 0
  br i1 %.not12, label %27, label %19

19:                                               ; preds = %14
  %20 = getelementptr inbounds i8, ptr %15, i64 12
  %21 = load volatile i32, ptr %20, align 4, !tbaa !16
  %22 = and i32 %21, 512
  %.not13 = icmp eq i32 %22, 0
  br i1 %.not13, label %27, label %23

23:                                               ; preds = %19
  %24 = load volatile i32, ptr %20, align 4, !tbaa !16
  %25 = and i32 %24, 128
  %26 = or disjoint i32 %25, -641
  store volatile i32 %26, ptr %20, align 4, !tbaa !16
  tail call void @HAL_RTCEx_AlarmBEventCallback(ptr noundef nonnull %0) #2
  br label %27

27:                                               ; preds = %19, %23, %14
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  store volatile i32 1, ptr %28, align 8, !tbaa !17
  ret void
}

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

declare void @HAL_RTCEx_AlarmBEventCallback(ptr noundef) 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 8}
!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, !12, i64 0}
!11 = !{!"", !12, i64 0, !13, i64 8, !7, i64 36, !7, i64 40}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24}
!14 = !{!15, !7, i64 8}
!15 = !{!"", !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, !7, i64 172, !7, i64 176, !7, i64 180, !7, i64 184, !7, i64 188, !7, i64 192, !7, i64 196, !7, i64 200, !7, i64 204}
!16 = !{!15, !7, i64 12}
!17 = !{!11, !7, i64 40}


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