; 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.NAND_HandleTypeDef = type { ptr, %struct.FMC_NAND_InitTypeDef, i32, i32, %struct.NAND_DeviceConfigTypeDef }
%struct.FMC_NAND_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.NAND_DeviceConfigTypeDef = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.FMC_Bank3_TypeDef = type { i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @HAL_NAND_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.NAND_HandleTypeDef, ptr %3, i32 0, i32 0
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %struct.FMC_Bank3_TypeDef, ptr %5, i32 0, i32 1
  %7 = load volatile i32, ptr %6, align 4, !tbaa !13
  %8 = and i32 %7, 1
  %9 = icmp eq i32 %8, 1
  br i1 %9, label %10, label %18

10:                                               ; preds = %1
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_NAND_ITCallback(ptr noundef %11)
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.NAND_HandleTypeDef, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.FMC_Bank3_TypeDef, ptr %14, i32 0, i32 1
  %16 = load volatile i32, ptr %15, align 4, !tbaa !13
  %17 = and i32 %16, -2
  store volatile i32 %17, ptr %15, align 4, !tbaa !13
  br label %18

18:                                               ; preds = %10, %1
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.NAND_HandleTypeDef, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.FMC_Bank3_TypeDef, ptr %21, i32 0, i32 1
  %23 = load volatile i32, ptr %22, align 4, !tbaa !13
  %24 = and i32 %23, 2
  %25 = icmp eq i32 %24, 2
  br i1 %25, label %26, label %34

26:                                               ; preds = %18
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_NAND_ITCallback(ptr noundef %27)
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.NAND_HandleTypeDef, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.FMC_Bank3_TypeDef, ptr %30, i32 0, i32 1
  %32 = load volatile i32, ptr %31, align 4, !tbaa !13
  %33 = and i32 %32, -3
  store volatile i32 %33, ptr %31, align 4, !tbaa !13
  br label %34

34:                                               ; preds = %26, %18
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.NAND_HandleTypeDef, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.FMC_Bank3_TypeDef, ptr %37, i32 0, i32 1
  %39 = load volatile i32, ptr %38, align 4, !tbaa !13
  %40 = and i32 %39, 4
  %41 = icmp eq i32 %40, 4
  br i1 %41, label %42, label %50

42:                                               ; preds = %34
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_NAND_ITCallback(ptr noundef %43)
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.NAND_HandleTypeDef, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.FMC_Bank3_TypeDef, ptr %46, i32 0, i32 1
  %48 = load volatile i32, ptr %47, align 4, !tbaa !13
  %49 = and i32 %48, -5
  store volatile i32 %49, ptr %47, align 4, !tbaa !13
  br label %50

50:                                               ; preds = %42, %34
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.NAND_HandleTypeDef, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.FMC_Bank3_TypeDef, ptr %53, i32 0, i32 1
  %55 = load volatile i32, ptr %54, align 4, !tbaa !13
  %56 = and i32 %55, 64
  %57 = icmp eq i32 %56, 64
  br i1 %57, label %58, label %66

58:                                               ; preds = %50
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_NAND_ITCallback(ptr noundef %59)
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.NAND_HandleTypeDef, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.FMC_Bank3_TypeDef, ptr %62, i32 0, i32 1
  %64 = load volatile i32, ptr %63, align 4, !tbaa !13
  %65 = and i32 %64, -65
  store volatile i32 %65, ptr %63, align 4, !tbaa !13
  br label %66

66:                                               ; preds = %58, %50
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_NAND_ITCallback(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 36, !12, i64 40, !11, i64 44}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 4}
!14 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, 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_NAND_IRQHandler(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 4
  %4 = load volatile i32, ptr %3, align 4, !tbaa !12
  %5 = and i32 %4, 1
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %11, label %6

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

11:                                               ; preds = %6, %1
  %12 = phi ptr [ %7, %6 ], [ %2, %1 ]
  %13 = getelementptr inbounds i8, ptr %12, i64 4
  %14 = load volatile i32, ptr %13, align 4, !tbaa !12
  %15 = and i32 %14, 2
  %.not12 = icmp eq i32 %15, 0
  br i1 %.not12, label %21, label %16

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

21:                                               ; preds = %16, %11
  %22 = phi ptr [ %17, %16 ], [ %12, %11 ]
  %23 = getelementptr inbounds i8, ptr %22, i64 4
  %24 = load volatile i32, ptr %23, align 4, !tbaa !12
  %25 = and i32 %24, 4
  %.not13 = icmp eq i32 %25, 0
  br i1 %.not13, label %31, label %26

26:                                               ; preds = %21
  tail call void @HAL_NAND_ITCallback(ptr noundef nonnull %0)
  %27 = load ptr, ptr %0, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 4
  %29 = load volatile i32, ptr %28, align 4, !tbaa !12
  %30 = and i32 %29, -5
  store volatile i32 %30, ptr %28, align 4, !tbaa !12
  br label %31

31:                                               ; preds = %26, %21
  %32 = phi ptr [ %27, %26 ], [ %22, %21 ]
  %33 = getelementptr inbounds i8, ptr %32, i64 4
  %34 = load volatile i32, ptr %33, align 4, !tbaa !12
  %35 = and i32 %34, 64
  %.not14 = icmp eq i32 %35, 0
  br i1 %.not14, label %41, label %36

36:                                               ; preds = %31
  tail call void @HAL_NAND_ITCallback(ptr noundef nonnull %0)
  %37 = load ptr, ptr %0, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 4
  %39 = load volatile i32, ptr %38, align 4, !tbaa !12
  %40 = and i32 %39, -65
  store volatile i32 %40, ptr %38, align 4, !tbaa !12
  br label %41

41:                                               ; preds = %36, %31
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_NAND_ITCallback(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 36, !11, i64 40, !10, i64 44}
!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 = !{!13, !11, i64 4}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}


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