; 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
declare dso_local void @TIM_CCxChannelCmd(ptr noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_TIM_OnePulse_Stop_IT(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds %struct.TIM_TypeDef, ptr %8, i32 0, i32 3
  %10 = load volatile i32, ptr %9, align 4, !tbaa !14
  %11 = zext i32 %10 to i64
  %12 = and i64 %11, -3
  %13 = trunc i64 %12 to i32
  store volatile i32 %13, ptr %9, align 4, !tbaa !14
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = getelementptr inbounds %struct.TIM_TypeDef, ptr %16, i32 0, i32 3
  %18 = load volatile i32, ptr %17, align 4, !tbaa !14
  %19 = zext i32 %18 to i64
  %20 = and i64 %19, -5
  %21 = trunc i64 %20 to i32
  store volatile i32 %21, ptr %17, align 4, !tbaa !14
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  call void @TIM_CCxChannelCmd(ptr noundef %24, i32 noundef 0, i32 noundef 0)
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  call void @TIM_CCxChannelCmd(ptr noundef %27, i32 noundef 4, i32 noundef 0)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = icmp eq ptr %30, inttoptr (i64 1073807360 to ptr)
  br i1 %31, label %52, label %32

32:                                               ; preds = %2
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = icmp eq ptr %35, inttoptr (i64 1073808384 to ptr)
  br i1 %36, label %52, label %37

37:                                               ; preds = %32
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = icmp eq ptr %40, inttoptr (i64 1073823744 to ptr)
  br i1 %41, label %52, label %42

42:                                               ; preds = %37
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = icmp eq ptr %45, inttoptr (i64 1073824768 to ptr)
  br i1 %46, label %52, label %47

47:                                               ; preds = %42
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  %51 = icmp eq ptr %50, inttoptr (i64 1073825792 to ptr)
  br label %52

52:                                               ; preds = %47, %42, %37, %32, %2
  %53 = phi i1 [ true, %42 ], [ true, %37 ], [ true, %32 ], [ true, %2 ], [ %51, %47 ]
  %54 = zext i1 %53 to i32
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %87

56:                                               ; preds = %52
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.TIM_TypeDef, ptr %60, i32 0, i32 8
  %62 = load volatile i32, ptr %61, align 4, !tbaa !16
  %63 = and i32 %62, 4369
  %64 = zext i32 %63 to i64
  %65 = icmp eq i64 %64, 0
  br i1 %65, label %66, label %85

66:                                               ; preds = %57
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !11
  %70 = getelementptr inbounds %struct.TIM_TypeDef, ptr %69, i32 0, i32 8
  %71 = load volatile i32, ptr %70, align 4, !tbaa !16
  %72 = and i32 %71, 1092
  %73 = zext i32 %72 to i64
  %74 = icmp eq i64 %73, 0
  br i1 %74, label %75, label %84

75:                                               ; preds = %66
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !11
  %79 = getelementptr inbounds %struct.TIM_TypeDef, ptr %78, i32 0, i32 17
  %80 = load volatile i32, ptr %79, align 4, !tbaa !17
  %81 = zext i32 %80 to i64
  %82 = and i64 %81, -32769
  %83 = trunc i64 %82 to i32
  store volatile i32 %83, ptr %79, align 4, !tbaa !17
  br label %84

84:                                               ; preds = %75, %66
  br label %85

85:                                               ; preds = %84, %57
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86, %52
  br label %88

88:                                               ; preds = %87
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !11
  %92 = getelementptr inbounds %struct.TIM_TypeDef, ptr %91, i32 0, i32 8
  %93 = load volatile i32, ptr %92, align 4, !tbaa !16
  %94 = and i32 %93, 4369
  %95 = zext i32 %94 to i64
  %96 = icmp eq i64 %95, 0
  br i1 %96, label %97, label %116

97:                                               ; preds = %88
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !11
  %101 = getelementptr inbounds %struct.TIM_TypeDef, ptr %100, i32 0, i32 8
  %102 = load volatile i32, ptr %101, align 4, !tbaa !16
  %103 = and i32 %102, 1092
  %104 = zext i32 %103 to i64
  %105 = icmp eq i64 %104, 0
  br i1 %105, label %106, label %115

106:                                              ; preds = %97
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %107, i32 0, i32 0
  %109 = load ptr, ptr %108, align 8, !tbaa !11
  %110 = getelementptr inbounds %struct.TIM_TypeDef, ptr %109, i32 0, i32 0
  %111 = load volatile i32, ptr %110, align 4, !tbaa !18
  %112 = zext i32 %111 to i64
  %113 = and i64 %112, -2
  %114 = trunc i64 %113 to i32
  store volatile i32 %114, ptr %110, align 4, !tbaa !18
  br label %115

115:                                              ; preds = %106, %97
  br label %116

116:                                              ; preds = %115, %88
  br label %117

117:                                              ; preds = %116
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %118, i32 0, i32 6
  %120 = getelementptr inbounds [6 x i32], ptr %119, i64 0, i64 0
  store volatile i32 1, ptr %120, align 8, !tbaa !9
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %121, i32 0, i32 6
  %123 = getelementptr inbounds [6 x i32], ptr %122, i64 0, i64 1
  store volatile i32 1, ptr %123, align 4, !tbaa !9
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %124, i32 0, i32 7
  %126 = getelementptr inbounds [4 x i32], ptr %125, i64 0, i64 0
  store volatile i32 1, ptr %126, align 8, !tbaa !9
  %127 = load ptr, ptr %3, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %127, i32 0, i32 7
  %129 = getelementptr inbounds [4 x i32], ptr %128, i64 0, i64 1
  store volatile i32 1, ptr %129, align 4, !tbaa !9
  ret i32 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !13, i64 8, !10, i64 32, !7, i64 40, !10, i64 96, !10, i64 100, !7, i64 104, !7, i64 128, !10, i64 144}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!14 = !{!15, !10, i64 12}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104}
!16 = !{!15, !10, i64 32}
!17 = !{!15, !10, i64 68}
!18 = !{!15, !10, i64 0}


; 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 dso_local void @TIM_CCxChannelCmd(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @HAL_TIM_OnePulse_Stop_IT(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 12
  %5 = load volatile i32, ptr %4, align 4, !tbaa !12
  %6 = and i32 %5, -3
  store volatile i32 %6, ptr %4, align 4, !tbaa !12
  %7 = load volatile i32, ptr %4, align 4, !tbaa !12
  %8 = and i32 %7, -5
  store volatile i32 %8, ptr %4, align 4, !tbaa !12
  tail call void @TIM_CCxChannelCmd(ptr noundef %3, i32 noundef 0, i32 noundef 0)
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @TIM_CCxChannelCmd(ptr noundef %9, i32 noundef 4, i32 noundef 0)
  %10 = load ptr, ptr %0, align 8, !tbaa !5
  %magicptr20 = ptrtoint ptr %10 to i64
  switch i64 %magicptr20, label %23 [
    i64 1073807360, label %.critedge
    i64 1073808384, label %.critedge
    i64 1073823744, label %.critedge
    i64 1073824768, label %.critedge
    i64 1073825792, label %.critedge
  ]

.critedge:                                        ; preds = %2, %2, %2, %2, %2
  %11 = getelementptr inbounds i8, ptr %10, i64 32
  %12 = load volatile i32, ptr %11, align 4, !tbaa !14
  %13 = and i32 %12, 4369
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %23

15:                                               ; preds = %.critedge
  %16 = load volatile i32, ptr %11, align 4, !tbaa !14
  %17 = and i32 %16, 1092
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %23

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %10, i64 68
  %21 = load volatile i32, ptr %20, align 4, !tbaa !15
  %22 = and i32 %21, -32769
  store volatile i32 %22, ptr %20, align 4, !tbaa !15
  br label %23

23:                                               ; preds = %2, %.critedge, %19, %15
  %24 = getelementptr inbounds i8, ptr %10, i64 32
  %25 = load volatile i32, ptr %24, align 4, !tbaa !14
  %26 = and i32 %25, 4369
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %35

28:                                               ; preds = %23
  %29 = load volatile i32, ptr %24, align 4, !tbaa !14
  %30 = and i32 %29, 1092
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %35

32:                                               ; preds = %28
  %33 = load volatile i32, ptr %10, align 4, !tbaa !16
  %34 = and i32 %33, -2
  store volatile i32 %34, ptr %10, align 4, !tbaa !16
  br label %35

35:                                               ; preds = %23, %32, %28
  %36 = getelementptr inbounds i8, ptr %0, i64 104
  store volatile i32 1, ptr %36, align 8, !tbaa !17
  %37 = getelementptr inbounds i8, ptr %0, i64 108
  store volatile i32 1, ptr %37, align 4, !tbaa !17
  %38 = getelementptr inbounds i8, ptr %0, i64 128
  store volatile i32 1, ptr %38, align 8, !tbaa !17
  %39 = getelementptr inbounds i8, ptr %0, i64 132
  store volatile i32 1, ptr %39, align 4, !tbaa !17
  ret i32 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, !7, i64 0}
!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 = !{!13, !11, i64 12}
!13 = !{!"", !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}
!14 = !{!13, !11, i64 32}
!15 = !{!13, !11, i64 68}
!16 = !{!13, !11, i64 0}
!17 = !{!11, !11, i64 0}


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