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

; 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: 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

declare void @TIM_CCxChannelCmd(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_TIMEx_HallSensor_Start_IT(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %10, i32 0, i32 6
  %12 = getelementptr inbounds [6 x i32], ptr %11, i64 0, i64 0
  %13 = load volatile i32, ptr %12, align 8, !tbaa !9
  store i32 %13, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %14, i32 0, i32 6
  %16 = getelementptr inbounds [6 x i32], ptr %15, i64 0, i64 1
  %17 = load volatile i32, ptr %16, align 4, !tbaa !9
  store i32 %17, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %18, i32 0, i32 7
  %20 = getelementptr inbounds [4 x i32], ptr %19, i64 0, i64 0
  %21 = load volatile i32, ptr %20, align 8, !tbaa !9
  store i32 %21, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %22, i32 0, i32 7
  %24 = getelementptr inbounds [4 x i32], ptr %23, i64 0, i64 1
  %25 = load volatile i32, ptr %24, align 4, !tbaa !9
  store i32 %25, ptr %8, align 4, !tbaa !9
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 1
  br i1 %27, label %37, label %28

28:                                               ; preds = %1
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 1
  br i1 %30, label %37, label %31

31:                                               ; preds = %28
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = icmp ne i32 %32, 1
  br i1 %33, label %37, label %34

34:                                               ; preds = %31
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = icmp ne i32 %35, 1
  br i1 %36, label %37, label %38

37:                                               ; preds = %34, %31, %28, %1
  store i32 1, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %147

38:                                               ; preds = %34
  %39 = load ptr, ptr %3, 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 2, ptr %41, align 8, !tbaa !9
  %42 = load ptr, ptr %3, 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 2, ptr %44, align 4, !tbaa !9
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %45, i32 0, i32 7
  %47 = getelementptr inbounds [4 x i32], ptr %46, i64 0, i64 0
  store volatile i32 2, ptr %47, align 8, !tbaa !9
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %48, i32 0, i32 7
  %50 = getelementptr inbounds [4 x i32], ptr %49, i64 0, i64 1
  store volatile i32 2, ptr %50, align 4, !tbaa !9
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !11
  %54 = getelementptr inbounds %struct.TIM_TypeDef, ptr %53, i32 0, i32 3
  %55 = load volatile i32, ptr %54, align 4, !tbaa !14
  %56 = zext i32 %55 to i64
  %57 = or i64 %56, 2
  %58 = trunc i64 %57 to i32
  store volatile i32 %58, ptr %54, align 4, !tbaa !14
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  call void @TIM_CCxChannelCmd(ptr noundef %61, i32 noundef 0, i32 noundef 1)
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !11
  %65 = icmp eq ptr %64, inttoptr (i64 1073807360 to ptr)
  br i1 %65, label %111, label %66

66:                                               ; preds = %38
  %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 = icmp eq ptr %69, inttoptr (i64 1073741824 to ptr)
  br i1 %70, label %111, label %71

71:                                               ; preds = %66
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !11
  %75 = icmp eq ptr %74, inttoptr (i64 1073742848 to ptr)
  br i1 %75, label %111, label %76

76:                                               ; preds = %71
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !11
  %80 = icmp eq ptr %79, inttoptr (i64 1073743872 to ptr)
  br i1 %80, label %111, label %81

81:                                               ; preds = %76
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !11
  %85 = icmp eq ptr %84, inttoptr (i64 1073744896 to ptr)
  br i1 %85, label %111, label %86

86:                                               ; preds = %81
  %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 = icmp eq ptr %89, inttoptr (i64 1073808384 to ptr)
  br i1 %90, label %111, label %91

91:                                               ; preds = %86
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !11
  %95 = icmp eq ptr %94, inttoptr (i64 1073747968 to ptr)
  br i1 %95, label %111, label %96

96:                                               ; preds = %91
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !11
  %100 = icmp eq ptr %99, inttoptr (i64 1073823744 to ptr)
  br i1 %100, label %111, label %101

101:                                              ; preds = %96
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %102, i32 0, i32 0
  %104 = load ptr, ptr %103, align 8, !tbaa !11
  %105 = icmp eq ptr %104, inttoptr (i64 1073799168 to ptr)
  br i1 %105, label %111, label %106

106:                                              ; preds = %101
  %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 = icmp eq ptr %109, inttoptr (i64 1073800192 to ptr)
  br i1 %110, label %111, label %137

111:                                              ; preds = %106, %101, %96, %91, %86, %81, %76, %71, %66, %38
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %112, i32 0, i32 0
  %114 = load ptr, ptr %113, align 8, !tbaa !11
  %115 = getelementptr inbounds %struct.TIM_TypeDef, ptr %114, i32 0, i32 2
  %116 = load volatile i32, ptr %115, align 4, !tbaa !16
  %117 = zext i32 %116 to i64
  %118 = and i64 %117, 65543
  %119 = trunc i64 %118 to i32
  store i32 %119, ptr %4, align 4, !tbaa !9
  %120 = load i32, ptr %4, align 4, !tbaa !9
  %121 = zext i32 %120 to i64
  %122 = icmp eq i64 %121, 6
  br i1 %122, label %136, label %123

123:                                              ; preds = %111
  %124 = load i32, ptr %4, align 4, !tbaa !9
  %125 = zext i32 %124 to i64
  %126 = icmp eq i64 %125, 65536
  br i1 %126, label %136, label %127

127:                                              ; preds = %123
  %128 = load ptr, ptr %3, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %128, i32 0, i32 0
  %130 = load ptr, ptr %129, align 8, !tbaa !11
  %131 = getelementptr inbounds %struct.TIM_TypeDef, ptr %130, i32 0, i32 0
  %132 = load volatile i32, ptr %131, align 4, !tbaa !17
  %133 = zext i32 %132 to i64
  %134 = or i64 %133, 1
  %135 = trunc i64 %134 to i32
  store volatile i32 %135, ptr %131, align 4, !tbaa !17
  br label %136

136:                                              ; preds = %127, %123, %111
  br label %146

137:                                              ; preds = %106
  %138 = load ptr, ptr %3, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %138, i32 0, i32 0
  %140 = load ptr, ptr %139, align 8, !tbaa !11
  %141 = getelementptr inbounds %struct.TIM_TypeDef, ptr %140, i32 0, i32 0
  %142 = load volatile i32, ptr %141, align 4, !tbaa !17
  %143 = zext i32 %142 to i64
  %144 = or i64 %143, 1
  %145 = trunc i64 %144 to i32
  store volatile i32 %145, ptr %141, align 4, !tbaa !17
  br label %146

146:                                              ; preds = %137, %136
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %147

147:                                              ; preds = %146, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %148 = load i32, ptr %2, align 4
  ret i32 %148
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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, !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 8}
!17 = !{!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"

declare void @TIM_CCxChannelCmd(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_TIMEx_HallSensor_Start_IT(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 104
  %3 = load volatile i32, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 108
  %5 = load volatile i32, ptr %4, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 128
  %7 = load volatile i32, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 132
  %9 = load volatile i32, ptr %8, align 4, !tbaa !5
  %10 = icmp ne i32 %3, 1
  %11 = icmp ne i32 %5, 1
  %or.cond = select i1 %10, i1 true, i1 %11
  %12 = icmp ne i32 %7, 1
  %or.cond3 = select i1 %or.cond, i1 true, i1 %12
  %13 = icmp ne i32 %9, 1
  %or.cond5 = select i1 %or.cond3, i1 true, i1 %13
  br i1 %or.cond5, label %26, label %14

14:                                               ; preds = %1
  store volatile i32 2, ptr %2, align 8, !tbaa !5
  store volatile i32 2, ptr %4, align 4, !tbaa !5
  store volatile i32 2, ptr %6, align 8, !tbaa !5
  store volatile i32 2, ptr %8, align 4, !tbaa !5
  %15 = load ptr, ptr %0, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %15, i64 12
  %17 = load volatile i32, ptr %16, align 4, !tbaa !13
  %18 = or i32 %17, 2
  store volatile i32 %18, ptr %16, align 4, !tbaa !13
  tail call void @TIM_CCxChannelCmd(ptr noundef %15, i32 noundef 0, i32 noundef 1) #2
  %19 = load ptr, ptr %0, align 8, !tbaa !9
  %magicptr = ptrtoint ptr %19 to i64
  switch i64 %magicptr, label %.sink.split [
    i64 1073807360, label %20
    i64 1073741824, label %20
    i64 1073742848, label %20
    i64 1073743872, label %20
    i64 1073744896, label %20
    i64 1073808384, label %20
    i64 1073747968, label %20
    i64 1073823744, label %20
    i64 1073799168, label %20
    i64 1073800192, label %20
  ]

20:                                               ; preds = %14, %14, %14, %14, %14, %14, %14, %14, %14, %14
  %21 = getelementptr inbounds i8, ptr %19, i64 8
  %22 = load volatile i32, ptr %21, align 4, !tbaa !15
  %23 = and i32 %22, 65543
  switch i32 %23, label %.sink.split [
    i32 65536, label %26
    i32 6, label %26
  ]

.sink.split:                                      ; preds = %14, %20
  %24 = load volatile i32, ptr %19, align 4, !tbaa !16
  %25 = or i32 %24, 1
  store volatile i32 %25, ptr %19, align 4, !tbaa !16
  br label %26

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

attributes #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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !12, i64 8, !6, i64 32, !7, i64 40, !6, i64 96, !6, i64 100, !7, i64 104, !7, i64 128, !6, i64 144}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20}
!13 = !{!14, !6, i64 12}
!14 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !6, i64 100, !6, i64 104}
!15 = !{!14, !6, i64 8}
!16 = !{!14, !6, i64 0}


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