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

; 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 }
%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_OC_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
  switch i32 %5, label %42 [
    i32 0, label %6
    i32 4, label %15
    i32 8, label %24
    i32 12, label %33
  ]

6:                                                ; preds = %2
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %7, i32 0, i32 0
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds %struct.TIM_TypeDef, ptr %9, i32 0, i32 3
  %11 = load volatile i32, ptr %10, align 4, !tbaa !14
  %12 = zext i32 %11 to i64
  %13 = and i64 %12, -3
  %14 = trunc i64 %13 to i32
  store volatile i32 %14, ptr %10, align 4, !tbaa !14
  br label %43

15:                                               ; preds = %2
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = getelementptr inbounds %struct.TIM_TypeDef, ptr %18, i32 0, i32 3
  %20 = load volatile i32, ptr %19, align 4, !tbaa !14
  %21 = zext i32 %20 to i64
  %22 = and i64 %21, -5
  %23 = trunc i64 %22 to i32
  store volatile i32 %23, ptr %19, align 4, !tbaa !14
  br label %43

24:                                               ; preds = %2
  %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
  %28 = getelementptr inbounds %struct.TIM_TypeDef, ptr %27, i32 0, i32 3
  %29 = load volatile i32, ptr %28, align 4, !tbaa !14
  %30 = zext i32 %29 to i64
  %31 = and i64 %30, -9
  %32 = trunc i64 %31 to i32
  store volatile i32 %32, ptr %28, align 4, !tbaa !14
  br label %43

33:                                               ; preds = %2
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.TIM_TypeDef, ptr %36, i32 0, i32 3
  %38 = load volatile i32, ptr %37, align 4, !tbaa !14
  %39 = zext i32 %38 to i64
  %40 = and i64 %39, -17
  %41 = trunc i64 %40 to i32
  store volatile i32 %41, ptr %37, align 4, !tbaa !14
  br label %43

42:                                               ; preds = %2
  br label %43

43:                                               ; preds = %42, %33, %24, %15, %6
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !11
  %47 = load i32, ptr %4, align 4, !tbaa !9
  call void @TIM_CCxChannelCmd(ptr noundef %46, i32 noundef %47, i32 noundef 0)
  %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 1073807360 to ptr)
  br i1 %51, label %72, label %52

52:                                               ; preds = %43
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = icmp eq ptr %55, inttoptr (i64 1073808384 to ptr)
  br i1 %56, label %72, label %57

57:                                               ; preds = %52
  %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 = icmp eq ptr %60, inttoptr (i64 1073823744 to ptr)
  br i1 %61, label %72, label %62

62:                                               ; preds = %57
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !11
  %66 = icmp eq ptr %65, inttoptr (i64 1073824768 to ptr)
  br i1 %66, label %72, label %67

67:                                               ; preds = %62
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !11
  %71 = icmp eq ptr %70, inttoptr (i64 1073825792 to ptr)
  br label %72

72:                                               ; preds = %67, %62, %57, %52, %43
  %73 = phi i1 [ true, %62 ], [ true, %57 ], [ true, %52 ], [ true, %43 ], [ %71, %67 ]
  %74 = zext i1 %73 to i32
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %107

76:                                               ; preds = %72
  br label %77

77:                                               ; preds = %76
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !11
  %81 = getelementptr inbounds %struct.TIM_TypeDef, ptr %80, i32 0, i32 8
  %82 = load volatile i32, ptr %81, align 4, !tbaa !16
  %83 = and i32 %82, 4369
  %84 = zext i32 %83 to i64
  %85 = icmp eq i64 %84, 0
  br i1 %85, label %86, label %105

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

95:                                               ; preds = %86
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %96, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8, !tbaa !11
  %99 = getelementptr inbounds %struct.TIM_TypeDef, ptr %98, i32 0, i32 17
  %100 = load volatile i32, ptr %99, align 4, !tbaa !17
  %101 = zext i32 %100 to i64
  %102 = and i64 %101, -32769
  %103 = trunc i64 %102 to i32
  store volatile i32 %103, ptr %99, align 4, !tbaa !17
  br label %104

104:                                              ; preds = %95, %86
  br label %105

105:                                              ; preds = %104, %77
  br label %106

106:                                              ; preds = %105
  br label %107

107:                                              ; preds = %106, %72
  br label %108

108:                                              ; preds = %107
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %109, i32 0, i32 0
  %111 = load ptr, ptr %110, align 8, !tbaa !11
  %112 = getelementptr inbounds %struct.TIM_TypeDef, ptr %111, i32 0, i32 8
  %113 = load volatile i32, ptr %112, align 4, !tbaa !16
  %114 = and i32 %113, 4369
  %115 = zext i32 %114 to i64
  %116 = icmp eq i64 %115, 0
  br i1 %116, label %117, label %136

117:                                              ; preds = %108
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %118, i32 0, i32 0
  %120 = load ptr, ptr %119, align 8, !tbaa !11
  %121 = getelementptr inbounds %struct.TIM_TypeDef, ptr %120, i32 0, i32 8
  %122 = load volatile i32, ptr %121, align 4, !tbaa !16
  %123 = and i32 %122, 1092
  %124 = zext i32 %123 to i64
  %125 = icmp eq i64 %124, 0
  br i1 %125, label %126, label %135

126:                                              ; preds = %117
  %127 = load ptr, ptr %3, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %127, i32 0, i32 0
  %129 = load ptr, ptr %128, align 8, !tbaa !11
  %130 = getelementptr inbounds %struct.TIM_TypeDef, ptr %129, i32 0, i32 0
  %131 = load volatile i32, ptr %130, align 4, !tbaa !18
  %132 = zext i32 %131 to i64
  %133 = and i64 %132, -2
  %134 = trunc i64 %133 to i32
  store volatile i32 %134, ptr %130, align 4, !tbaa !18
  br label %135

135:                                              ; preds = %126, %117
  br label %136

136:                                              ; preds = %135, %108
  br label %137

137:                                              ; preds = %136
  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}
!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"

@switch.table.HAL_TIM_OC_Stop_IT = private unnamed_addr constant [4 x i32] [i32 -3, i32 -5, i32 -9, i32 -17], align 4

; 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_OC_Stop_IT(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @llvm.fshl.i32(i32 %1, i32 %1, i32 30)
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  %4 = icmp ult i32 %3, 4
  br i1 %4, label %switch.lookup, label %._crit_edge

switch.lookup:                                    ; preds = %2
  %5 = zext nneg i32 %3 to i64
  %switch.gep = getelementptr inbounds [4 x i32], ptr @switch.table.HAL_TIM_OC_Stop_IT, i64 0, i64 %5
  %switch.load = load i32, ptr %switch.gep, align 4
  %6 = getelementptr inbounds i8, ptr %.pre, i64 12
  %7 = load volatile i32, ptr %6, align 4, !tbaa !12
  %8 = and i32 %7, %switch.load
  store volatile i32 %8, ptr %6, align 4, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %2, %switch.lookup
  tail call void @TIM_CCxChannelCmd(ptr noundef %.pre, i32 noundef %1, i32 noundef 0)
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %magicptr18 = ptrtoint ptr %9 to i64
  switch i64 %magicptr18, label %22 [
    i64 1073807360, label %.critedge
    i64 1073808384, label %.critedge
    i64 1073823744, label %.critedge
    i64 1073824768, label %.critedge
    i64 1073825792, label %.critedge
  ]

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

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

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

22:                                               ; preds = %._crit_edge, %.critedge, %18, %14
  %23 = getelementptr inbounds i8, ptr %9, i64 32
  %24 = load volatile i32, ptr %23, align 4, !tbaa !14
  %25 = and i32 %24, 4369
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %34

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

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

34:                                               ; preds = %22, %31, %27
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.fshl.i32(i32, i32, i32) #1

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" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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}
!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}


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