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

; 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.MDIOS_HandleTypeDef = type { ptr, %struct.MDIOS_InitTypeDef, i32, i32, i32 }
%struct.MDIOS_InitTypeDef = type { i32, i32 }
%struct.MDIOS_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, [57 x 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, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, 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
declare dso_local i32 @HAL_MDIOS_GetWrittenRegAddress(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @HAL_MDIOS_IRQHandler(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 = getelementptr inbounds %struct.MDIOS_HandleTypeDef, ptr %3, i32 0, i32 0
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %struct.MDIOS_TypeDef, ptr %5, i32 0, i32 0
  %7 = load volatile i32, ptr %6, align 4, !tbaa !13
  %8 = zext i32 %7 to i64
  %9 = and i64 %8, 2
  %10 = icmp ne i64 %9, 0
  br i1 %10, label %11, label %24

11:                                               ; preds = %1
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = call i32 @HAL_MDIOS_GetWrittenRegAddress(ptr noundef %12)
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %23

15:                                               ; preds = %11
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_MDIOS_WriteCpltCallback(ptr noundef %16)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.MDIOS_HandleTypeDef, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.MDIOS_TypeDef, ptr %19, i32 0, i32 2
  %21 = load volatile i32, ptr %20, align 4, !tbaa !15
  %22 = or i32 %21, -1
  store volatile i32 %22, ptr %20, align 4, !tbaa !15
  br label %23

23:                                               ; preds = %15, %11
  br label %24

24:                                               ; preds = %23, %1
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.MDIOS_HandleTypeDef, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.MDIOS_TypeDef, ptr %27, i32 0, i32 0
  %29 = load volatile i32, ptr %28, align 4, !tbaa !13
  %30 = zext i32 %29 to i64
  %31 = and i64 %30, 4
  %32 = icmp ne i64 %31, 0
  br i1 %32, label %33, label %46

33:                                               ; preds = %24
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = call i32 @HAL_MDIOS_GetReadRegAddress(ptr noundef %34)
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %45

37:                                               ; preds = %33
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_MDIOS_ReadCpltCallback(ptr noundef %38)
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.MDIOS_HandleTypeDef, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.MDIOS_TypeDef, ptr %41, i32 0, i32 4
  %43 = load volatile i32, ptr %42, align 4, !tbaa !16
  %44 = or i32 %43, -1
  store volatile i32 %44, ptr %42, align 4, !tbaa !16
  br label %45

45:                                               ; preds = %37, %33
  br label %46

46:                                               ; preds = %45, %24
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.MDIOS_HandleTypeDef, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.MDIOS_TypeDef, ptr %49, i32 0, i32 0
  %51 = load volatile i32, ptr %50, align 4, !tbaa !13
  %52 = zext i32 %51 to i64
  %53 = and i64 %52, 8
  %54 = icmp ne i64 %53, 0
  br i1 %54, label %55, label %78

55:                                               ; preds = %46
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.MDIOS_HandleTypeDef, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.MDIOS_TypeDef, ptr %58, i32 0, i32 5
  %60 = load volatile i32, ptr %59, align 4, !tbaa !17
  %61 = and i32 %60, 7
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %75

63:                                               ; preds = %55
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.MDIOS_HandleTypeDef, ptr %64, i32 0, i32 3
  %66 = load volatile i32, ptr %65, align 4, !tbaa !18
  %67 = or i32 %66, 16
  store volatile i32 %67, ptr %65, align 4, !tbaa !18
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_MDIOS_ErrorCallback(ptr noundef %68)
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.MDIOS_HandleTypeDef, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.MDIOS_TypeDef, ptr %71, i32 0, i32 6
  %73 = load volatile i32, ptr %72, align 4, !tbaa !19
  %74 = or i32 %73, 7
  store volatile i32 %74, ptr %72, align 4, !tbaa !19
  br label %75

75:                                               ; preds = %63, %55
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.MDIOS_HandleTypeDef, ptr %76, i32 0, i32 3
  store volatile i32 0, ptr %77, align 4, !tbaa !18
  br label %78

78:                                               ; preds = %75, %46
  %79 = load volatile i32, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 27), align 4, !tbaa !20
  %80 = and i32 %79, 1024
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %84

82:                                               ; preds = %78
  store volatile i32 1024, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 27), align 4, !tbaa !20
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_MDIOS_WakeUpCallback(ptr noundef %83)
  br label %84

84:                                               ; preds = %82, %78
  ret void
}

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_MDIOS_WakeUpCallback(ptr noundef) #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !12, i64 16, !12, i64 20, !12, i64 24}
!11 = !{!"", !12, i64 0, !12, i64 4}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !7, i64 28, !12, i64 256, !12, i64 260, !12, i64 264, !12, i64 268, !12, i64 272, !12, i64 276, !12, i64 280, !12, i64 284, !12, i64 288, !12, i64 292, !12, i64 296, !12, i64 300, !12, i64 304, !12, i64 308, !12, i64 312, !12, i64 316, !12, i64 320, !12, i64 324, !12, i64 328, !12, i64 332, !12, i64 336, !12, i64 340, !12, i64 344, !12, i64 348, !12, i64 352, !12, i64 356, !12, i64 360, !12, i64 364, !12, i64 368, !12, i64 372, !12, i64 376, !12, i64 380, !12, i64 384, !12, i64 388, !12, i64 392, !12, i64 396, !12, i64 400, !12, i64 404, !12, i64 408, !12, i64 412, !12, i64 416, !12, i64 420, !12, i64 424, !12, i64 428, !12, i64 432, !12, i64 436, !12, i64 440, !12, i64 444, !12, i64 448, !12, i64 452, !12, i64 456, !12, i64 460, !12, i64 464, !12, i64 468, !12, i64 472, !12, i64 476, !12, i64 480, !12, i64 484, !12, i64 488, !12, i64 492, !12, i64 496, !12, i64 500, !12, i64 504, !12, i64 508}
!15 = !{!14, !12, i64 8}
!16 = !{!14, !12, i64 16}
!17 = !{!14, !12, i64 20}
!18 = !{!10, !12, i64 20}
!19 = !{!14, !12, i64 24}
!20 = !{!21, !12, i64 152}
!21 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !7, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !7, i64 56, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !7, i64 88, !12, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !12, i64 148, !12, i64 152, !12, i64 156, !12, i64 160, !12, i64 164, !12, i64 168}


; 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
declare dso_local i32 @HAL_MDIOS_GetWrittenRegAddress(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @HAL_MDIOS_IRQHandler(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = load volatile i32, ptr %2, align 4, !tbaa !12
  %4 = and i32 %3, 2
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %11, label %5

5:                                                ; preds = %1
  %6 = tail call i32 @HAL_MDIOS_GetWrittenRegAddress(ptr noundef nonnull %0)
  %.not15 = icmp eq i32 %6, 0
  br i1 %.not15, label %._crit_edge, label %7

._crit_edge:                                      ; preds = %5
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  br label %11

7:                                                ; preds = %5
  tail call void @HAL_MDIOS_WriteCpltCallback(ptr noundef nonnull %0)
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  %10 = load volatile i32, ptr %9, align 4, !tbaa !14
  store volatile i32 -1, ptr %9, align 4, !tbaa !14
  br label %11

11:                                               ; preds = %._crit_edge, %7, %1
  %12 = phi ptr [ %.pre, %._crit_edge ], [ %8, %7 ], [ %2, %1 ]
  %13 = load volatile i32, ptr %12, align 4, !tbaa !12
  %14 = and i32 %13, 4
  %.not16 = icmp eq i32 %14, 0
  br i1 %.not16, label %21, label %15

15:                                               ; preds = %11
  %16 = tail call i32 @HAL_MDIOS_GetReadRegAddress(ptr noundef nonnull %0)
  %.not17 = icmp eq i32 %16, 0
  br i1 %.not17, label %._crit_edge21, label %17

._crit_edge21:                                    ; preds = %15
  %.pre22 = load ptr, ptr %0, align 8, !tbaa !5
  br label %21

17:                                               ; preds = %15
  tail call void @HAL_MDIOS_ReadCpltCallback(ptr noundef nonnull %0)
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %20 = load volatile i32, ptr %19, align 4, !tbaa !15
  store volatile i32 -1, ptr %19, align 4, !tbaa !15
  br label %21

21:                                               ; preds = %._crit_edge21, %17, %11
  %22 = phi ptr [ %.pre22, %._crit_edge21 ], [ %18, %17 ], [ %12, %11 ]
  %23 = load volatile i32, ptr %22, align 4, !tbaa !12
  %24 = and i32 %23, 8
  %.not18 = icmp eq i32 %24, 0
  br i1 %.not18, label %39, label %25

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %22, i64 20
  %27 = load volatile i32, ptr %26, align 4, !tbaa !16
  %28 = and i32 %27, 7
  %.not19 = icmp eq i32 %28, 0
  br i1 %.not19, label %37, label %29

29:                                               ; preds = %25
  %30 = getelementptr inbounds i8, ptr %0, i64 20
  %31 = load volatile i32, ptr %30, align 4, !tbaa !17
  %32 = or i32 %31, 16
  store volatile i32 %32, ptr %30, align 4, !tbaa !17
  tail call void @HAL_MDIOS_ErrorCallback(ptr noundef nonnull %0)
  %33 = load ptr, ptr %0, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 24
  %35 = load volatile i32, ptr %34, align 4, !tbaa !18
  %36 = or i32 %35, 7
  store volatile i32 %36, ptr %34, align 4, !tbaa !18
  br label %37

37:                                               ; preds = %29, %25
  %38 = getelementptr inbounds i8, ptr %0, i64 20
  store volatile i32 0, ptr %38, align 4, !tbaa !17
  br label %39

39:                                               ; preds = %37, %21
  %40 = load volatile i32, ptr inttoptr (i64 1476395160 to ptr), align 8, !tbaa !19
  %41 = and i32 %40, 1024
  %.not20 = icmp eq i32 %41, 0
  br i1 %.not20, label %43, label %42

42:                                               ; preds = %39
  store volatile i32 1024, ptr inttoptr (i64 1476395160 to ptr), align 8, !tbaa !19
  tail call void @HAL_MDIOS_WakeUpCallback(ptr noundef nonnull %0)
  br label %43

43:                                               ; preds = %42, %39
  ret void
}

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_MDIOS_WakeUpCallback(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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 20, !11, i64 24}
!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 = !{!"int", !8, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !8, i64 28, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !11, i64 280, !11, i64 284, !11, i64 288, !11, i64 292, !11, i64 296, !11, i64 300, !11, i64 304, !11, i64 308, !11, i64 312, !11, i64 316, !11, i64 320, !11, i64 324, !11, i64 328, !11, i64 332, !11, i64 336, !11, i64 340, !11, i64 344, !11, i64 348, !11, i64 352, !11, i64 356, !11, i64 360, !11, i64 364, !11, i64 368, !11, i64 372, !11, i64 376, !11, i64 380, !11, i64 384, !11, i64 388, !11, i64 392, !11, i64 396, !11, i64 400, !11, i64 404, !11, i64 408, !11, i64 412, !11, i64 416, !11, i64 420, !11, i64 424, !11, i64 428, !11, i64 432, !11, i64 436, !11, i64 440, !11, i64 444, !11, i64 448, !11, i64 452, !11, i64 456, !11, i64 460, !11, i64 464, !11, i64 468, !11, i64 472, !11, i64 476, !11, i64 480, !11, i64 484, !11, i64 488, !11, i64 492, !11, i64 496, !11, i64 500, !11, i64 504, !11, i64 508}
!14 = !{!13, !11, i64 8}
!15 = !{!13, !11, i64 16}
!16 = !{!13, !11, i64 20}
!17 = !{!6, !11, i64 20}
!18 = !{!13, !11, i64 24}
!19 = !{!20, !11, i64 152}
!20 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !8, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !8, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !8, 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}


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