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

; 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.DFSDM_Filter_HandleTypeDef = type { ptr, %struct.DFSDM_Filter_InitTypeDef, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.DFSDM_Filter_InitTypeDef = type { %struct.DFSDM_Filter_RegularParamTypeDef, %struct.DFSDM_Filter_InjectedParamTypeDef, %struct.DFSDM_Filter_FilterParamTypeDef }
%struct.DFSDM_Filter_RegularParamTypeDef = type { i32, i32, i32 }
%struct.DFSDM_Filter_InjectedParamTypeDef = type { i32, i32, i32, i32, i32 }
%struct.DFSDM_Filter_FilterParamTypeDef = type { i32, i32, i32 }
%struct.DFSDM_Filter_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.__DMA_HandleTypeDef = type { ptr, %struct.DMA_InitTypeDef, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i32, ptr, ptr, i32 }
%struct.DMA_InitTypeDef = type { 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
declare hidden void @DFSDM_DMAError(ptr noundef) #1

declare i32 @HAL_DMA_Start_IT(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_DFSDM_FilterInjectedMsbStart_DMA(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %13, label %10

10:                                               ; preds = %3
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %10, %3
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %115

14:                                               ; preds = %10
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds %struct.DFSDM_Filter_TypeDef, ptr %17, i32 0, i32 0
  %19 = load volatile i32, ptr %18, align 4, !tbaa !16
  %20 = zext i32 %19 to i64
  %21 = and i64 %20, 32
  %22 = icmp ne i64 %21, 32
  br i1 %22, label %23, label %24

23:                                               ; preds = %14
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %114

24:                                               ; preds = %14
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %25, i32 0, i32 6
  %27 = load i32, ptr %26, align 8, !tbaa !18
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %44

29:                                               ; preds = %24
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  %33 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds %struct.DMA_InitTypeDef, ptr %33, i32 0, i32 6
  %35 = load i32, ptr %34, align 8, !tbaa !20
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %44

37:                                               ; preds = %29
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %39, i32 0, i32 10
  %41 = load i32, ptr %40, align 8, !tbaa !23
  %42 = icmp ugt i32 %38, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %37
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %113

44:                                               ; preds = %37, %29, %24
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %45, i32 0, i32 6
  %47 = load i32, ptr %46, align 8, !tbaa !18
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %58

49:                                               ; preds = %44
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !19
  %53 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.DMA_InitTypeDef, ptr %53, i32 0, i32 6
  %55 = load i32, ptr %54, align 8, !tbaa !20
  %56 = icmp eq i32 %55, 256
  br i1 %56, label %57, label %58

57:                                               ; preds = %49
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %112

58:                                               ; preds = %49, %44
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %59, i32 0, i32 11
  %61 = load i32, ptr %60, align 4, !tbaa !24
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %68, label %63

63:                                               ; preds = %58
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %64, i32 0, i32 11
  %66 = load i32, ptr %65, align 4, !tbaa !24
  %67 = icmp eq i32 %66, 2
  br i1 %67, label %68, label %110

68:                                               ; preds = %63, %58
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %69, i32 0, i32 3
  %71 = load ptr, ptr %70, align 8, !tbaa !19
  %72 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %71, i32 0, i32 5
  store ptr @DFSDM_DMAInjectedConvCplt, ptr %72, align 8, !tbaa !25
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %73, i32 0, i32 3
  %75 = load ptr, ptr %74, align 8, !tbaa !19
  %76 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %75, i32 0, i32 9
  store ptr @DFSDM_DMAError, ptr %76, align 8, !tbaa !26
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !19
  %80 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %79, i32 0, i32 1
  %81 = getelementptr inbounds %struct.DMA_InitTypeDef, ptr %80, i32 0, i32 6
  %82 = load i32, ptr %81, align 8, !tbaa !20
  %83 = icmp eq i32 %82, 256
  %84 = zext i1 %83 to i64
  %85 = select i1 %83, ptr @DFSDM_DMAInjectedHalfConvCplt, ptr null
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %86, i32 0, i32 3
  %88 = load ptr, ptr %87, align 8, !tbaa !19
  %89 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %88, i32 0, i32 6
  store ptr %85, ptr %89, align 8, !tbaa !27
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %90, i32 0, i32 3
  %92 = load ptr, ptr %91, align 8, !tbaa !19
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !11
  %96 = getelementptr inbounds %struct.DFSDM_Filter_TypeDef, ptr %95, i32 0, i32 6
  %97 = ptrtoint ptr %96 to i32
  %98 = add i32 %97, 2
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = ptrtoint ptr %99 to i32
  %101 = load i32, ptr %6, align 4, !tbaa !9
  %102 = call i32 @HAL_DMA_Start_IT(ptr noundef %92, i32 noundef %98, i32 noundef %100, i32 noundef %101)
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %107

104:                                              ; preds = %68
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.DFSDM_Filter_HandleTypeDef, ptr %105, i32 0, i32 11
  store i32 255, ptr %106, align 4, !tbaa !24
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %109

107:                                              ; preds = %68
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  call void @DFSDM_InjConvStart(ptr noundef %108)
  br label %109

109:                                              ; preds = %107, %104
  br label %111

110:                                              ; preds = %63
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %110, %109
  br label %112

112:                                              ; preds = %111, %57
  br label %113

113:                                              ; preds = %112, %43
  br label %114

114:                                              ; preds = %113, %23
  br label %115

115:                                              ; preds = %114, %13
  %116 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 %116
}

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 = { "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 #3 = { 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, !6, i64 0}
!12 = !{!"", !6, i64 0, !13, i64 8, !6, i64 56, !6, i64 64, !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}
!13 = !{!"", !14, i64 0, !15, i64 12, !14, i64 32}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!16 = !{!17, !10, i64 0}
!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}
!18 = !{!12, !10, i64 80}
!19 = !{!12, !6, i64 64}
!20 = !{!21, !10, i64 32}
!21 = !{!"__DMA_HandleTypeDef", !6, i64 0, !22, i64 8, !10, i64 56, !10, i64 60, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !10, i64 120, !10, i64 124, !10, i64 128, !6, i64 136, !6, i64 144, !10, i64 152, !6, i64 160, !6, i64 168, !10, i64 176}
!22 = !{!"", !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}
!23 = !{!12, !10, i64 96}
!24 = !{!12, !10, i64 100}
!25 = !{!21, !6, i64 72}
!26 = !{!21, !6, i64 104}
!27 = !{!21, !6, i64 80}


; 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 hidden void @DFSDM_DMAError(ptr noundef) #0

declare i32 @HAL_DMA_Start_IT(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_DFSDM_FilterInjectedMsbStart_DMA(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %1, null
  %5 = icmp eq i32 %2, 0
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %44, label %6

6:                                                ; preds = %3
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = load volatile i32, ptr %7, align 4, !tbaa !14
  %9 = and i32 %8, 32
  %.not.not = icmp eq i32 %9, 0
  br i1 %.not.not, label %44, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  %12 = load i32, ptr %11, align 8, !tbaa !16
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %.thread

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 64
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %16, i64 32
  %18 = load i32, ptr %17, align 8, !tbaa !18
  switch i32 %18, label %.thread [
    i32 0, label %19
    i32 256, label %44
  ]

19:                                               ; preds = %14
  %20 = getelementptr inbounds i8, ptr %0, i64 96
  %21 = load i32, ptr %20, align 8, !tbaa !21
  %22 = icmp ult i32 %21, %2
  br i1 %22, label %44, label %.thread

.thread:                                          ; preds = %14, %19, %10
  %23 = getelementptr inbounds i8, ptr %0, i64 100
  %24 = load i32, ptr %23, align 4, !tbaa !22
  %.off = add i32 %24, -1
  %switch = icmp ult i32 %.off, 2
  br i1 %switch, label %25, label %44

25:                                               ; preds = %.thread
  %26 = getelementptr inbounds i8, ptr %0, i64 64
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %27, i64 72
  store ptr @DFSDM_DMAInjectedConvCplt, ptr %28, align 8, !tbaa !23
  %29 = getelementptr inbounds i8, ptr %27, i64 104
  store ptr @DFSDM_DMAError, ptr %29, align 8, !tbaa !24
  %30 = getelementptr inbounds i8, ptr %27, i64 32
  %31 = load i32, ptr %30, align 8, !tbaa !18
  %32 = icmp eq i32 %31, 256
  %33 = select i1 %32, ptr @DFSDM_DMAInjectedHalfConvCplt, ptr null
  %34 = getelementptr inbounds i8, ptr %27, i64 80
  store ptr %33, ptr %34, align 8, !tbaa !25
  %35 = getelementptr inbounds i8, ptr %7, i64 24
  %36 = ptrtoint ptr %35 to i64
  %37 = trunc i64 %36 to i32
  %38 = add i32 %37, 2
  %39 = ptrtoint ptr %1 to i64
  %40 = trunc i64 %39 to i32
  %41 = tail call i32 @HAL_DMA_Start_IT(ptr noundef %27, i32 noundef %38, i32 noundef %40, i32 noundef %2) #2
  %.not = icmp eq i32 %41, 0
  br i1 %.not, label %43, label %42

42:                                               ; preds = %25
  store i32 255, ptr %23, align 4, !tbaa !22
  br label %44

43:                                               ; preds = %25
  tail call void @DFSDM_InjConvStart(ptr noundef nonnull %0)
  br label %44

44:                                               ; preds = %14, %.thread, %19, %6, %3, %42, %43
  %.0 = phi i32 [ 1, %42 ], [ 0, %43 ], [ 1, %3 ], [ 1, %6 ], [ 1, %19 ], [ 1, %.thread ], [ 1, %14 ]
  ret i32 %.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" }
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 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 56, !7, i64 64, !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}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !13, i64 12, !11, i64 32}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!12 = !{!"int", !8, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16}
!14 = !{!15, !12, i64 0}
!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}
!16 = !{!6, !12, i64 80}
!17 = !{!6, !7, i64 64}
!18 = !{!19, !12, i64 32}
!19 = !{!"__DMA_HandleTypeDef", !7, i64 0, !20, i64 8, !12, i64 56, !12, i64 60, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !12, i64 120, !12, i64 124, !12, i64 128, !7, i64 136, !7, i64 144, !12, i64 152, !7, i64 160, !7, i64 168, !12, i64 176}
!20 = !{!"", !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}
!21 = !{!6, !12, i64 96}
!22 = !{!6, !12, i64 100}
!23 = !{!19, !7, i64 72}
!24 = !{!19, !7, i64 104}
!25 = !{!19, !7, i64 80}


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