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

; 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.__MDMA_HandleTypeDef = type { ptr, %struct.MDMA_InitTypeDef, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32 }
%struct.MDMA_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.MDMA_Channel_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_MDMA_DeInit(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  store i32 1, ptr %2, align 4
  br label %82

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %8, i32 0, i32 3
  %10 = load volatile i32, ptr %9, align 4, !tbaa !9
  %11 = icmp eq i32 %10, 2
  br i1 %11, label %12, label %15

12:                                               ; preds = %7
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %13, i32 0, i32 14
  store volatile i32 256, ptr %14, align 4, !tbaa !13
  store i32 1, ptr %2, align 4
  br label %82

15:                                               ; preds = %7
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %18, i32 0, i32 3
  %20 = load volatile i32, ptr %19, align 4, !tbaa !15
  %21 = zext i32 %20 to i64
  %22 = and i64 %21, -2
  %23 = trunc i64 %22 to i32
  store volatile i32 %23, ptr %19, align 4, !tbaa !15
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %26, i32 0, i32 3
  store volatile i32 0, ptr %27, align 4, !tbaa !15
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %30, i32 0, i32 4
  store volatile i32 0, ptr %31, align 4, !tbaa !16
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %34, i32 0, i32 5
  store volatile i32 0, ptr %35, align 4, !tbaa !17
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %38, i32 0, i32 6
  store volatile i32 0, ptr %39, align 4, !tbaa !18
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !14
  %43 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %42, i32 0, i32 7
  store volatile i32 0, ptr %43, align 4, !tbaa !19
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  %47 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %46, i32 0, i32 8
  store volatile i32 0, ptr %47, align 4, !tbaa !20
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %50, i32 0, i32 9
  store volatile i32 0, ptr %51, align 4, !tbaa !21
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !14
  %55 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %54, i32 0, i32 10
  store volatile i32 0, ptr %55, align 4, !tbaa !22
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !14
  %59 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %58, i32 0, i32 12
  store volatile i32 0, ptr %59, align 4, !tbaa !23
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !14
  %63 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %62, i32 0, i32 13
  store volatile i32 0, ptr %63, align 4, !tbaa !24
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %66, i32 0, i32 1
  store volatile i32 31, ptr %67, align 4, !tbaa !25
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %68, i32 0, i32 11
  store ptr null, ptr %69, align 8, !tbaa !26
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %70, i32 0, i32 12
  store ptr null, ptr %71, align 8, !tbaa !27
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %72, i32 0, i32 13
  store i32 0, ptr %73, align 8, !tbaa !28
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %74, i32 0, i32 14
  store volatile i32 0, ptr %75, align 4, !tbaa !13
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %76, i32 0, i32 3
  store volatile i32 0, ptr %77, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %15
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %79, i32 0, i32 2
  store i32 0, ptr %80, align 8, !tbaa !29
  br label %81

81:                                               ; preds = %78
  store i32 0, ptr %2, align 4
  br label %82

82:                                               ; preds = %81, %12, %6
  %83 = load i32, ptr %2, align 4
  ret i32 %83
}

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, !12, i64 68}
!10 = !{!"__MDMA_HandleTypeDef", !6, i64 0, !11, i64 8, !12, i64 64, !12, i64 68, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !12, i64 144, !12, i64 148}
!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, i64 48, !12, i64 52}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 148}
!14 = !{!10, !6, i64 0}
!15 = !{!11, !12, i64 12}
!16 = !{!11, !12, i64 16}
!17 = !{!11, !12, i64 20}
!18 = !{!11, !12, i64 24}
!19 = !{!11, !12, i64 28}
!20 = !{!11, !12, i64 32}
!21 = !{!11, !12, i64 36}
!22 = !{!11, !12, i64 40}
!23 = !{!11, !12, i64 48}
!24 = !{!11, !12, i64 52}
!25 = !{!11, !12, i64 4}
!26 = !{!10, !6, i64 128}
!27 = !{!10, !6, i64 136}
!28 = !{!10, !12, i64 144}
!29 = !{!10, !12, i64 64}


; 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: nofree norecurse nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_MDMA_DeInit(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %27, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 68
  %5 = load volatile i32, ptr %4, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 2
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 148
  store volatile i32 256, ptr %8, align 4, !tbaa !12
  br label %27

9:                                                ; preds = %3
  %10 = load ptr, ptr %0, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %10, i64 12
  %12 = load volatile i32, ptr %11, align 4, !tbaa !14
  %13 = and i32 %12, -2
  store volatile i32 %13, ptr %11, align 4, !tbaa !14
  store volatile i32 0, ptr %11, align 4, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %10, i64 16
  store volatile i32 0, ptr %14, align 4, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %10, i64 20
  store volatile i32 0, ptr %15, align 4, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %10, i64 24
  store volatile i32 0, ptr %16, align 4, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %10, i64 28
  store volatile i32 0, ptr %17, align 4, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %10, i64 32
  store volatile i32 0, ptr %18, align 4, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %10, i64 36
  store volatile i32 0, ptr %19, align 4, !tbaa !20
  %20 = getelementptr inbounds i8, ptr %10, i64 40
  store volatile i32 0, ptr %20, align 4, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %10, i64 48
  store volatile i32 0, ptr %21, align 4, !tbaa !22
  %22 = getelementptr inbounds i8, ptr %10, i64 52
  store volatile i32 0, ptr %22, align 4, !tbaa !23
  %23 = getelementptr inbounds i8, ptr %10, i64 4
  store volatile i32 31, ptr %23, align 4, !tbaa !24
  %24 = getelementptr inbounds i8, ptr %0, i64 128
  %25 = getelementptr inbounds i8, ptr %0, i64 148
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %24, i8 0, i64 20, i1 false)
  store volatile i32 0, ptr %25, align 4, !tbaa !12
  store volatile i32 0, ptr %4, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 0, ptr %26, align 8, !tbaa !25
  br label %27

27:                                               ; preds = %1, %9, %7
  %.0 = phi i32 [ 1, %7 ], [ 0, %9 ], [ 1, %1 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { nofree norecurse 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !11, i64 68}
!6 = !{!"__MDMA_HandleTypeDef", !7, i64 0, !10, i64 8, !11, i64 64, !11, i64 68, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !11, i64 144, !11, i64 148}
!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, i64 48, !11, i64 52}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 148}
!13 = !{!6, !7, i64 0}
!14 = !{!10, !11, i64 12}
!15 = !{!10, !11, i64 16}
!16 = !{!10, !11, i64 20}
!17 = !{!10, !11, i64 24}
!18 = !{!10, !11, i64 28}
!19 = !{!10, !11, i64 32}
!20 = !{!10, !11, i64 36}
!21 = !{!10, !11, i64 40}
!22 = !{!10, !11, i64 48}
!23 = !{!10, !11, i64 52}
!24 = !{!10, !11, i64 4}
!25 = !{!6, !11, i64 64}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass