; 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.__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 }
%struct.DMAMUX_ChannelStatus_TypeDef = type { i32, i32 }
%struct.DMAMUX_Channel_TypeDef = type { i32 }
%struct.DMAMUX_RequestGenStatus_TypeDef = type { i32, i32 }
%struct.DMAMUX_RequestGen_TypeDef = type { i32 }

; Function Attrs: nounwind uwtable
define dso_local void @HAL_DMAEx_MUX_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.__DMA_HandleTypeDef, ptr %3, i32 0, i32 15
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %struct.DMAMUX_ChannelStatus_TypeDef, ptr %5, i32 0, i32 0
  %7 = load volatile i32, ptr %6, align 4, !tbaa !13
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %8, i32 0, i32 16
  %10 = load i32, ptr %9, align 8, !tbaa !15
  %11 = and i32 %7, %10
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %43

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %14, i32 0, i32 14
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = getelementptr inbounds %struct.DMAMUX_Channel_TypeDef, ptr %16, i32 0, i32 0
  %18 = load volatile i32, ptr %17, align 4, !tbaa !17
  %19 = zext i32 %18 to i64
  %20 = and i64 %19, -257
  %21 = trunc i64 %20 to i32
  store volatile i32 %21, ptr %17, align 4, !tbaa !17
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %22, i32 0, i32 16
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %25, i32 0, i32 15
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.DMAMUX_ChannelStatus_TypeDef, ptr %27, i32 0, i32 1
  store volatile i32 %24, ptr %28, align 4, !tbaa !19
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %29, i32 0, i32 11
  %31 = load volatile i32, ptr %30, align 8, !tbaa !20
  %32 = or i32 %31, 512
  store volatile i32 %32, ptr %30, align 8, !tbaa !20
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %33, i32 0, i32 9
  %35 = load ptr, ptr %34, align 8, !tbaa !21
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %42

37:                                               ; preds = %13
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %38, i32 0, i32 9
  %40 = load ptr, ptr %39, align 8, !tbaa !21
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  call void %40(ptr noundef %41)
  br label %42

42:                                               ; preds = %37, %13
  br label %43

43:                                               ; preds = %42, %1
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %44, i32 0, i32 17
  %46 = load ptr, ptr %45, align 8, !tbaa !22
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %90

48:                                               ; preds = %43
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %49, i32 0, i32 18
  %51 = load ptr, ptr %50, align 8, !tbaa !23
  %52 = getelementptr inbounds %struct.DMAMUX_RequestGenStatus_TypeDef, ptr %51, i32 0, i32 0
  %53 = load volatile i32, ptr %52, align 4, !tbaa !13
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %54, i32 0, i32 19
  %56 = load i32, ptr %55, align 8, !tbaa !24
  %57 = and i32 %53, %56
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %89

59:                                               ; preds = %48
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %60, i32 0, i32 17
  %62 = load ptr, ptr %61, align 8, !tbaa !22
  %63 = getelementptr inbounds %struct.DMAMUX_RequestGen_TypeDef, ptr %62, i32 0, i32 0
  %64 = load volatile i32, ptr %63, align 4, !tbaa !17
  %65 = zext i32 %64 to i64
  %66 = and i64 %65, -257
  %67 = trunc i64 %66 to i32
  store volatile i32 %67, ptr %63, align 4, !tbaa !17
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %68, i32 0, i32 19
  %70 = load i32, ptr %69, align 8, !tbaa !24
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %71, i32 0, i32 18
  %73 = load ptr, ptr %72, align 8, !tbaa !23
  %74 = getelementptr inbounds %struct.DMAMUX_RequestGenStatus_TypeDef, ptr %73, i32 0, i32 1
  store volatile i32 %70, ptr %74, align 4, !tbaa !19
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %75, i32 0, i32 11
  %77 = load volatile i32, ptr %76, align 8, !tbaa !20
  %78 = or i32 %77, 1024
  store volatile i32 %78, ptr %76, align 8, !tbaa !20
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %79, i32 0, i32 9
  %81 = load ptr, ptr %80, align 8, !tbaa !21
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %88

83:                                               ; preds = %59
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %84, i32 0, i32 9
  %86 = load ptr, ptr %85, align 8, !tbaa !21
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  call void %86(ptr noundef %87)
  br label %88

88:                                               ; preds = %83, %59
  br label %89

89:                                               ; preds = %88, %48
  br label %90

90:                                               ; preds = %89, %43
  ret void
}

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


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

8:                                                ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 136
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = load volatile i32, ptr %10, align 4, !tbaa !16
  %12 = and i32 %11, -257
  store volatile i32 %12, ptr %10, align 4, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %3, i64 4
  store volatile i32 %6, ptr %13, align 4, !tbaa !18
  %14 = getelementptr inbounds i8, ptr %0, i64 120
  %15 = load volatile i32, ptr %14, align 8, !tbaa !19
  %16 = or i32 %15, 512
  store volatile i32 %16, ptr %14, align 8, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %0, i64 104
  %18 = load ptr, ptr %17, align 8, !tbaa !20
  %.not20 = icmp eq ptr %18, null
  br i1 %.not20, label %20, label %19

19:                                               ; preds = %8
  tail call void %18(ptr noundef nonnull %0) #1
  br label %20

20:                                               ; preds = %8, %19, %1
  %21 = getelementptr inbounds i8, ptr %0, i64 160
  %22 = load ptr, ptr %21, align 8, !tbaa !21
  %.not21 = icmp eq ptr %22, null
  br i1 %.not21, label %40, label %23

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %0, i64 168
  %25 = load ptr, ptr %24, align 8, !tbaa !22
  %26 = load volatile i32, ptr %25, align 4, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %0, i64 176
  %28 = load i32, ptr %27, align 8, !tbaa !23
  %29 = and i32 %28, %26
  %.not22 = icmp eq i32 %29, 0
  br i1 %.not22, label %40, label %30

30:                                               ; preds = %23
  %31 = load volatile i32, ptr %22, align 4, !tbaa !16
  %32 = and i32 %31, -257
  store volatile i32 %32, ptr %22, align 4, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %25, i64 4
  store volatile i32 %28, ptr %33, align 4, !tbaa !18
  %34 = getelementptr inbounds i8, ptr %0, i64 120
  %35 = load volatile i32, ptr %34, align 8, !tbaa !19
  %36 = or i32 %35, 1024
  store volatile i32 %36, ptr %34, align 8, !tbaa !19
  %37 = getelementptr inbounds i8, ptr %0, i64 104
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %.not23 = icmp eq ptr %38, null
  br i1 %.not23, label %40, label %39

39:                                               ; preds = %30
  tail call void %38(ptr noundef nonnull %0) #1
  br label %40

40:                                               ; preds = %23, %39, %30, %20
  ret void
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass