; 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.CRYP_HandleTypeDef = type { ptr, %struct.CRYP_ConfigTypeDef, ptr, ptr, i16, i16, i16, i16, i32, ptr, ptr, i32, i32, i32, i32 }
%struct.CRYP_ConfigTypeDef = type { i32, i32, ptr, ptr, i32, ptr, i32, ptr, i32 }
%struct.CRYP_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 }

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

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

; Function Attrs: nounwind uwtable
define dso_local void @HAL_CRYP_IRQHandler(ptr noundef %0) #1 {
  %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
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %4, i32 0, i32 0
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds %struct.CRYP_TypeDef, ptr %6, i32 0, i32 7
  %8 = load volatile i32, ptr %7, align 4, !tbaa !14
  store i32 %8, ptr %3, align 4, !tbaa !16
  %9 = load i32, ptr %3, align 4, !tbaa !16
  %10 = zext i32 %9 to i64
  %11 = and i64 %10, 3
  %12 = icmp ne i64 %11, 0
  br i1 %12, label %13, label %97

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %14, i32 0, i32 1
  %16 = getelementptr inbounds %struct.CRYP_ConfigTypeDef, ptr %15, i32 0, i32 4
  %17 = load i32, ptr %16, align 8, !tbaa !17
  %18 = zext i32 %17 to i64
  %19 = icmp eq i64 %18, 16
  br i1 %19, label %40, label %20

20:                                               ; preds = %13
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds %struct.CRYP_ConfigTypeDef, ptr %22, i32 0, i32 4
  %24 = load i32, ptr %23, align 8, !tbaa !17
  %25 = zext i32 %24 to i64
  %26 = icmp eq i64 %25, 24
  br i1 %26, label %40, label %27

27:                                               ; preds = %20
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds %struct.CRYP_ConfigTypeDef, ptr %29, i32 0, i32 4
  %31 = load i32, ptr %30, align 8, !tbaa !17
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %40, label %33

33:                                               ; preds = %27
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds %struct.CRYP_ConfigTypeDef, ptr %35, i32 0, i32 4
  %37 = load i32, ptr %36, align 8, !tbaa !17
  %38 = zext i32 %37 to i64
  %39 = icmp eq i64 %38, 8
  br i1 %39, label %40, label %42

40:                                               ; preds = %33, %27, %20, %13
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  call void @CRYP_TDES_IT(ptr noundef %41)
  br label %96

42:                                               ; preds = %33
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %struct.CRYP_ConfigTypeDef, ptr %44, i32 0, i32 4
  %46 = load i32, ptr %45, align 8, !tbaa !17
  %47 = zext i32 %46 to i64
  %48 = icmp eq i64 %47, 32
  br i1 %48, label %63, label %49

49:                                               ; preds = %42
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %struct.CRYP_ConfigTypeDef, ptr %51, i32 0, i32 4
  %53 = load i32, ptr %52, align 8, !tbaa !17
  %54 = zext i32 %53 to i64
  %55 = icmp eq i64 %54, 40
  br i1 %55, label %63, label %56

56:                                               ; preds = %49
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %57, i32 0, i32 1
  %59 = getelementptr inbounds %struct.CRYP_ConfigTypeDef, ptr %58, i32 0, i32 4
  %60 = load i32, ptr %59, align 8, !tbaa !17
  %61 = zext i32 %60 to i64
  %62 = icmp eq i64 %61, 48
  br i1 %62, label %63, label %65

63:                                               ; preds = %56, %49, %42
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  call void @CRYP_AES_IT(ptr noundef %64)
  br label %95

65:                                               ; preds = %56
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %66, i32 0, i32 1
  %68 = getelementptr inbounds %struct.CRYP_ConfigTypeDef, ptr %67, i32 0, i32 4
  %69 = load i32, ptr %68, align 8, !tbaa !17
  %70 = zext i32 %69 to i64
  %71 = icmp eq i64 %70, 524288
  br i1 %71, label %79, label %72

72:                                               ; preds = %65
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %73, i32 0, i32 1
  %75 = getelementptr inbounds %struct.CRYP_ConfigTypeDef, ptr %74, i32 0, i32 4
  %76 = load i32, ptr %75, align 8, !tbaa !17
  %77 = zext i32 %76 to i64
  %78 = icmp eq i64 %77, 524296
  br i1 %78, label %79, label %93

79:                                               ; preds = %72, %65
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.CRYP_HandleTypeDef, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.CRYP_TypeDef, ptr %82, i32 0, i32 0
  %84 = load volatile i32, ptr %83, align 4, !tbaa !18
  %85 = zext i32 %84 to i64
  %86 = and i64 %85, 65536
  %87 = icmp eq i64 %86, 65536
  br i1 %87, label %88, label %90

88:                                               ; preds = %79
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  call void @CRYP_GCMCCM_SetHeaderPhase_IT(ptr noundef %89)
  br label %92

90:                                               ; preds = %79
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  call void @CRYP_GCMCCM_SetPayloadPhase_IT(ptr noundef %91)
  br label %92

92:                                               ; preds = %90, %88
  br label %94

93:                                               ; preds = %72
  br label %94

94:                                               ; preds = %93, %92
  br label %95

95:                                               ; preds = %94, %63
  br label %96

96:                                               ; preds = %95, %40
  br label %97

97:                                               ; preds = %96, %1
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @CRYP_TDES_IT(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @CRYP_AES_IT(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @CRYP_GCMCCM_SetHeaderPhase_IT(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @CRYP_GCMCCM_SetPayloadPhase_IT(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !6, i64 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !6, i64 72, !6, i64 80, !13, i64 88, !13, i64 90, !13, i64 92, !13, i64 94, !12, i64 96, !6, i64 104, !6, i64 112, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132}
!11 = !{!"", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !12, i64 24, !6, i64 32, !12, i64 40, !6, i64 48, !12, i64 56}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !12, i64 28}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132, !12, i64 136, !12, i64 140}
!16 = !{!12, !12, i64 0}
!17 = !{!10, !12, i64 32}
!18 = !{!15, !12, i64 0}


; 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_CRYP_IRQHandler(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 28
  %4 = load volatile i32, ptr %3, align 4, !tbaa !13
  %5 = and i32 %4, 3
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %16, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load i32, ptr %7, align 8, !tbaa !15
  switch i32 %8, label %16 [
    i32 16, label %9
    i32 24, label %9
    i32 0, label %9
    i32 8, label %9
    i32 32, label %10
    i32 40, label %10
    i32 48, label %10
    i32 524288, label %11
    i32 524296, label %11
  ]

9:                                                ; preds = %6, %6, %6, %6
  tail call void @CRYP_TDES_IT(ptr noundef nonnull %0)
  br label %16

10:                                               ; preds = %6, %6, %6
  tail call void @CRYP_AES_IT(ptr noundef nonnull %0)
  br label %16

11:                                               ; preds = %6, %6
  %12 = load volatile i32, ptr %2, align 4, !tbaa !16
  %13 = and i32 %12, 65536
  %.not15 = icmp eq i32 %13, 0
  br i1 %.not15, label %15, label %14

14:                                               ; preds = %11
  tail call void @CRYP_GCMCCM_SetHeaderPhase_IT(ptr noundef nonnull %0)
  br label %16

15:                                               ; preds = %11
  tail call void @CRYP_GCMCCM_SetPayloadPhase_IT(ptr noundef nonnull %0)
  br label %16

16:                                               ; preds = %6, %9, %15, %14, %10, %1
  ret void
}

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @CRYP_GCMCCM_SetPayloadPhase_IT(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, !7, i64 72, !7, i64 80, !12, i64 88, !12, i64 90, !12, i64 92, !12, i64 94, !11, i64 96, !7, i64 104, !7, i64 112, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 16, !11, i64 24, !7, i64 32, !11, i64 40, !7, i64 48, !11, i64 56}
!11 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!14, !11, i64 28}
!14 = !{!"", !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}
!15 = !{!6, !11, i64 32}
!16 = !{!14, !11, i64 0}


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