; 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.__SAI_HandleTypeDef = type { ptr, %struct.SAI_InitTypeDef, %struct.SAI_FrameInitTypeDef, %struct.SAI_SlotInitTypeDef, ptr, i16, i16, ptr, ptr, ptr, ptr, i32, i32, i32 }
%struct.SAI_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.SAI_PdmInitTypeDef, i32, i32, i32, i32 }
%struct.SAI_PdmInitTypeDef = type { i32, i32, i32 }
%struct.SAI_FrameInitTypeDef = type { i32, i32, i32, i32, i32 }
%struct.SAI_SlotInitTypeDef = type { i32, i32, i32, i32 }
%struct.SAI_Block_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.SAI_TypeDef = type { i32, [16 x 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 i32 @SAI_Disable(ptr noundef) #1

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

8:                                                ; preds = %1
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %75

9:                                                ; preds = %1
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %10, i32 0, i32 12
  store volatile i32 2, ptr %11, align 4, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %15 = getelementptr inbounds %struct.SAI_Block_TypeDef, ptr %14, i32 0, i32 4
  store volatile i32 0, ptr %15, align 4, !tbaa !18
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = getelementptr inbounds %struct.SAI_Block_TypeDef, ptr %18, i32 0, i32 6
  store volatile i32 -1, ptr %19, align 4, !tbaa !20
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = call i32 @SAI_Disable(ptr noundef %20)
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %31

23:                                               ; preds = %9
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %24, i32 0, i32 12
  store volatile i32 1, ptr %25, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %23
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %27, i32 0, i32 11
  store i32 0, ptr %28, align 8, !tbaa !21
  br label %29

29:                                               ; preds = %26
  br label %30

30:                                               ; preds = %29
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %75

31:                                               ; preds = %9
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = getelementptr inbounds %struct.SAI_Block_TypeDef, ptr %34, i32 0, i32 1
  %36 = load volatile i32, ptr %35, align 4, !tbaa !22
  %37 = zext i32 %36 to i64
  %38 = or i64 %37, 8
  %39 = trunc i64 %38 to i32
  store volatile i32 %39, ptr %35, align 4, !tbaa !22
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = icmp eq ptr %42, inttoptr (i64 1073829892 to ptr)
  br i1 %43, label %49, label %44

44:                                               ; preds = %31
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = icmp eq ptr %47, inttoptr (i64 1476416516 to ptr)
  br i1 %48, label %49, label %64

49:                                               ; preds = %44, %31
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  %53 = icmp eq ptr %52, inttoptr (i64 1073829892 to ptr)
  %54 = zext i1 %53 to i64
  %55 = select i1 %53, ptr inttoptr (i64 1073829888 to ptr), ptr inttoptr (i64 1476416512 to ptr)
  store ptr %55, ptr %4, align 8, !tbaa !5
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.SAI_TypeDef, ptr %56, i32 0, i32 3
  store volatile i32 0, ptr %57, align 4, !tbaa !23
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.SAI_TypeDef, ptr %58, i32 0, i32 2
  %60 = load volatile i32, ptr %59, align 4, !tbaa !25
  %61 = zext i32 %60 to i64
  %62 = and i64 %61, -2
  %63 = trunc i64 %62 to i32
  store volatile i32 %63, ptr %59, align 4, !tbaa !25
  br label %64

64:                                               ; preds = %49, %44
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  call void @HAL_SAI_MspDeInit(ptr noundef %65)
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %66, i32 0, i32 13
  store volatile i32 0, ptr %67, align 8, !tbaa !26
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %68, i32 0, i32 12
  store volatile i32 0, ptr %69, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %64
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.__SAI_HandleTypeDef, ptr %71, i32 0, i32 11
  store i32 0, ptr %72, align 8, !tbaa !21
  br label %73

73:                                               ; preds = %70
  br label %74

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

75:                                               ; preds = %74, %30, %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %76 = load i32, ptr %2, align 4
  ret i32 %76
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_SAI_MspDeInit(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, !12, i64 180}
!10 = !{!"__SAI_HandleTypeDef", !6, i64 0, !11, i64 8, !14, i64 88, !15, i64 108, !6, i64 128, !16, i64 136, !16, i64 138, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !12, i64 176, !12, i64 180, !12, i64 184}
!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, !13, i64 52, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!14 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!16 = !{!"short", !7, i64 0}
!17 = !{!10, !6, i64 0}
!18 = !{!19, !12, i64 16}
!19 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28}
!20 = !{!19, !12, i64 24}
!21 = !{!10, !12, i64 176}
!22 = !{!19, !12, i64 4}
!23 = !{!24, !12, i64 72}
!24 = !{!"", !12, i64 0, !7, i64 4, !12, i64 68, !12, i64 72}
!25 = !{!24, !12, i64 68}
!26 = !{!10, !12, i64 184}


; 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 i32 @SAI_Disable(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_SAI_DeInit(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %23, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 180
  store volatile i32 2, ptr %4, align 4, !tbaa !5
  %5 = load ptr, ptr %0, align 8, !tbaa !16
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  store volatile i32 0, ptr %6, align 4, !tbaa !17
  %7 = getelementptr inbounds i8, ptr %5, i64 24
  store volatile i32 -1, ptr %7, align 4, !tbaa !19
  %8 = tail call i32 @SAI_Disable(ptr noundef nonnull %0)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %.sink.split

9:                                                ; preds = %3
  %10 = load ptr, ptr %0, align 8, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %10, i64 4
  %12 = load volatile i32, ptr %11, align 4, !tbaa !20
  %13 = or i32 %12, 8
  store volatile i32 %13, ptr %11, align 4, !tbaa !20
  %magicptr = ptrtoint ptr %10 to i64
  switch i64 %magicptr, label %20 [
    i64 1073829892, label %14
    i64 1476416516, label %14
  ]

14:                                               ; preds = %9, %9
  %15 = icmp eq ptr %10, inttoptr (i64 1073829892 to ptr)
  %16 = select i1 %15, ptr inttoptr (i64 1073829960 to ptr), ptr inttoptr (i64 1476416584 to ptr)
  store volatile i32 0, ptr %16, align 8, !tbaa !21
  %17 = select i1 %15, ptr inttoptr (i64 1073829956 to ptr), ptr inttoptr (i64 1476416580 to ptr)
  %18 = load volatile i32, ptr %17, align 4, !tbaa !23
  %19 = and i32 %18, -2
  store volatile i32 %19, ptr %17, align 4, !tbaa !23
  br label %20

20:                                               ; preds = %9, %14
  tail call void @HAL_SAI_MspDeInit(ptr noundef nonnull %0)
  %21 = getelementptr inbounds i8, ptr %0, i64 184
  store volatile i32 0, ptr %21, align 8, !tbaa !24
  br label %.sink.split

.sink.split:                                      ; preds = %3, %20
  %.sink = phi i32 [ 0, %20 ], [ 1, %3 ]
  store volatile i32 %.sink, ptr %4, align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 176
  store i32 0, ptr %22, align 8, !tbaa !25
  br label %23

23:                                               ; preds = %.sink.split, %1
  %.0 = phi i32 [ 1, %1 ], [ %.sink, %.sink.split ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_SAI_MspDeInit(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, !11, i64 180}
!6 = !{!"__SAI_HandleTypeDef", !7, i64 0, !10, i64 8, !13, i64 88, !14, i64 108, !7, i64 128, !15, i64 136, !15, i64 138, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !11, i64 176, !11, i64 180, !11, i64 184}
!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, !12, i64 52, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!14 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!15 = !{!"short", !8, i64 0}
!16 = !{!6, !7, i64 0}
!17 = !{!18, !11, i64 16}
!18 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!19 = !{!18, !11, i64 24}
!20 = !{!18, !11, i64 4}
!21 = !{!22, !11, i64 72}
!22 = !{!"", !11, i64 0, !8, i64 4, !11, i64 68, !11, i64 72}
!23 = !{!22, !11, i64 68}
!24 = !{!6, !11, i64 184}
!25 = !{!6, !11, i64 176}


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