; LLVM IR from ctlst-tech/catpilot :: bsp/mcu/core/stm32/h753/hal/src (stm32h7xx_hal_tim)

; 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.TIM_HandleTypeDef = type { ptr, %struct.TIM_Base_InitTypeDef, i32, [7 x ptr], i32, i32, [6 x i32], [4 x i32], i32 }
%struct.TIM_Base_InitTypeDef = type { i32, i32, i32, i32, i32, i32 }
%struct.TIM_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_TIM_Base_DeInit(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.TIM_HandleTypeDef, ptr %3, i32 0, i32 5
  store volatile i32 2, ptr %4, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %1
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds %struct.TIM_TypeDef, ptr %8, i32 0, i32 8
  %10 = load volatile i32, ptr %9, align 4, !tbaa !14
  %11 = and i32 %10, 4369
  %12 = zext i32 %11 to i64
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %14, label %33

14:                                               ; preds = %5
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %18 = getelementptr inbounds %struct.TIM_TypeDef, ptr %17, i32 0, i32 8
  %19 = load volatile i32, ptr %18, align 4, !tbaa !14
  %20 = and i32 %19, 1092
  %21 = zext i32 %20 to i64
  %22 = icmp eq i64 %21, 0
  br i1 %22, label %23, label %32

23:                                               ; preds = %14
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.TIM_TypeDef, ptr %26, i32 0, i32 0
  %28 = load volatile i32, ptr %27, align 4, !tbaa !16
  %29 = zext i32 %28 to i64
  %30 = and i64 %29, -2
  %31 = trunc i64 %30 to i32
  store volatile i32 %31, ptr %27, align 4, !tbaa !16
  br label %32

32:                                               ; preds = %23, %14
  br label %33

33:                                               ; preds = %32, %5
  br label %34

34:                                               ; preds = %33
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_TIM_Base_MspDeInit(ptr noundef %35)
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %36, i32 0, i32 8
  store volatile i32 0, ptr %37, align 8, !tbaa !17
  br label %38

38:                                               ; preds = %34
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %39, i32 0, i32 6
  %41 = getelementptr inbounds [6 x i32], ptr %40, i64 0, i64 0
  store volatile i32 0, ptr %41, align 8, !tbaa !18
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %42, i32 0, i32 6
  %44 = getelementptr inbounds [6 x i32], ptr %43, i64 0, i64 1
  store volatile i32 0, ptr %44, align 4, !tbaa !18
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %45, i32 0, i32 6
  %47 = getelementptr inbounds [6 x i32], ptr %46, i64 0, i64 2
  store volatile i32 0, ptr %47, align 8, !tbaa !18
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %48, i32 0, i32 6
  %50 = getelementptr inbounds [6 x i32], ptr %49, i64 0, i64 3
  store volatile i32 0, ptr %50, align 4, !tbaa !18
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %51, i32 0, i32 6
  %53 = getelementptr inbounds [6 x i32], ptr %52, i64 0, i64 4
  store volatile i32 0, ptr %53, align 8, !tbaa !18
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %54, i32 0, i32 6
  %56 = getelementptr inbounds [6 x i32], ptr %55, i64 0, i64 5
  store volatile i32 0, ptr %56, align 4, !tbaa !18
  br label %57

57:                                               ; preds = %38
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %59, i32 0, i32 7
  %61 = getelementptr inbounds [4 x i32], ptr %60, i64 0, i64 0
  store volatile i32 0, ptr %61, align 8, !tbaa !18
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %62, i32 0, i32 7
  %64 = getelementptr inbounds [4 x i32], ptr %63, i64 0, i64 1
  store volatile i32 0, ptr %64, align 4, !tbaa !18
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %65, i32 0, i32 7
  %67 = getelementptr inbounds [4 x i32], ptr %66, i64 0, i64 2
  store volatile i32 0, ptr %67, align 8, !tbaa !18
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %68, i32 0, i32 7
  %70 = getelementptr inbounds [4 x i32], ptr %69, i64 0, i64 3
  store volatile i32 0, ptr %70, align 4, !tbaa !18
  br label %71

71:                                               ; preds = %58
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %72, i32 0, i32 5
  store volatile i32 0, ptr %73, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %71
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %75, i32 0, i32 4
  store i32 0, ptr %76, align 8, !tbaa !19
  br label %77

77:                                               ; preds = %74
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_TIM_Base_MspDeInit(ptr noundef) #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 100}
!10 = !{!"", !6, i64 0, !11, i64 8, !12, i64 32, !7, i64 40, !12, i64 96, !12, i64 100, !7, i64 104, !7, i64 128, !12, i64 144}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 0}
!14 = !{!15, !12, i64 32}
!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, !12, i64 60, !12, i64 64, !12, i64 68, !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}
!16 = !{!15, !12, i64 0}
!17 = !{!10, !12, i64 144}
!18 = !{!12, !12, i64 0}
!19 = !{!10, !12, i64 96}


; 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 noundef i32 @HAL_TIM_Base_DeInit(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 100
  store volatile i32 2, ptr %2, align 4, !tbaa !5
  %3 = load ptr, ptr %0, align 8, !tbaa !12
  %4 = getelementptr inbounds i8, ptr %3, i64 32
  %5 = load volatile i32, ptr %4, align 4, !tbaa !13
  %6 = and i32 %5, 4369
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %15

8:                                                ; preds = %1
  %9 = load volatile i32, ptr %4, align 4, !tbaa !13
  %10 = and i32 %9, 1092
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %15

12:                                               ; preds = %8
  %13 = load volatile i32, ptr %3, align 4, !tbaa !15
  %14 = and i32 %13, -2
  store volatile i32 %14, ptr %3, align 4, !tbaa !15
  br label %15

15:                                               ; preds = %1, %12, %8
  tail call void @HAL_TIM_Base_MspDeInit(ptr noundef nonnull %0)
  %16 = getelementptr inbounds i8, ptr %0, i64 144
  store volatile i32 0, ptr %16, align 8, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %0, i64 104
  store volatile i32 0, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %0, i64 108
  store volatile i32 0, ptr %18, align 4, !tbaa !17
  %19 = getelementptr inbounds i8, ptr %0, i64 112
  store volatile i32 0, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %0, i64 116
  store volatile i32 0, ptr %20, align 4, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %0, i64 120
  store volatile i32 0, ptr %21, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %0, i64 124
  store volatile i32 0, ptr %22, align 4, !tbaa !17
  %23 = getelementptr inbounds i8, ptr %0, i64 128
  store volatile i32 0, ptr %23, align 8, !tbaa !17
  %24 = getelementptr inbounds i8, ptr %0, i64 132
  store volatile i32 0, ptr %24, align 4, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %0, i64 136
  store volatile i32 0, ptr %25, align 8, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %0, i64 140
  store volatile i32 0, ptr %26, align 4, !tbaa !17
  store volatile i32 0, ptr %2, align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 0, ptr %27, align 8, !tbaa !18
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_TIM_Base_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 100}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 32, !8, i64 40, !11, i64 96, !11, i64 100, !8, i64 104, !8, i64 128, !11, i64 144}
!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 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!14, !11, i64 32}
!14 = !{!"", !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, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104}
!15 = !{!14, !11, i64 0}
!16 = !{!6, !11, i64 144}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !11, i64 96}


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