; LLVM IR from reazon-research/OpenArm :: control/canfd_control/Drivers/STM32H7xx_HAL_Driver/Src (stm32h7xx_hal_mdma)

; 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 %74

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %10, i32 0, i32 3
  %12 = load volatile i32, ptr %11, align 4, !tbaa !13
  %13 = zext i32 %12 to i64
  %14 = and i64 %13, -2
  %15 = trunc i64 %14 to i32
  store volatile i32 %15, ptr %11, align 4, !tbaa !13
  %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 !9
  %19 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %18, i32 0, i32 3
  store volatile i32 0, ptr %19, align 4, !tbaa !13
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %22, i32 0, i32 4
  store volatile i32 0, ptr %23, align 4, !tbaa !14
  %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 !9
  %27 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %26, i32 0, i32 5
  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 !9
  %31 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %30, i32 0, i32 6
  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 !9
  %35 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %34, i32 0, i32 7
  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 !9
  %39 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %38, i32 0, i32 8
  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 !9
  %43 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %42, i32 0, i32 9
  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 !9
  %47 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %46, i32 0, i32 10
  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 !9
  %51 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %50, i32 0, i32 12
  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 !9
  %55 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %54, i32 0, i32 13
  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 !9
  %59 = getelementptr inbounds %struct.MDMA_Channel_TypeDef, ptr %58, i32 0, i32 1
  store volatile i32 31, 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 11
  store ptr null, ptr %61, align 8, !tbaa !24
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %62, i32 0, i32 12
  store ptr null, ptr %63, align 8, !tbaa !25
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %64, i32 0, i32 13
  store i32 0, ptr %65, align 8, !tbaa !26
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %66, i32 0, i32 14
  store volatile i32 0, ptr %67, align 4, !tbaa !27
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %68, i32 0, i32 3
  store volatile i32 0, ptr %69, align 4, !tbaa !28
  br label %70

70:                                               ; preds = %7
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.__MDMA_HandleTypeDef, ptr %71, i32 0, i32 2
  store i32 0, ptr %72, align 8, !tbaa !29
  br label %73

73:                                               ; preds = %70
  store i32 0, ptr %2, align 4
  br label %74

74:                                               ; preds = %73, %6
  %75 = load i32, ptr %2, align 4
  ret i32 %75
}

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 = !{!"__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 = !{!11, !12, i64 12}
!14 = !{!11, !12, i64 16}
!15 = !{!11, !12, i64 20}
!16 = !{!11, !12, i64 24}
!17 = !{!11, !12, i64 28}
!18 = !{!11, !12, i64 32}
!19 = !{!11, !12, i64 36}
!20 = !{!11, !12, i64 40}
!21 = !{!11, !12, i64 48}
!22 = !{!11, !12, i64 52}
!23 = !{!11, !12, i64 4}
!24 = !{!10, !6, i64 128}
!25 = !{!10, !6, i64 136}
!26 = !{!10, !12, i64 144}
!27 = !{!10, !12, i64 148}
!28 = !{!10, !12, i64 68}
!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 %22, label %3

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

22:                                               ; preds = %1, %3
  %.0 = phi i32 [ 0, %3 ], [ 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, !7, i64 0}
!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 = !{!10, !11, i64 12}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 20}
!15 = !{!10, !11, i64 24}
!16 = !{!10, !11, i64 28}
!17 = !{!10, !11, i64 32}
!18 = !{!10, !11, i64 36}
!19 = !{!10, !11, i64 40}
!20 = !{!10, !11, i64 48}
!21 = !{!10, !11, i64 52}
!22 = !{!10, !11, i64 4}
!23 = !{!6, !11, i64 148}
!24 = !{!6, !11, i64 68}
!25 = !{!6, !11, i64 64}


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