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

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

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

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

36:                                               ; preds = %33
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 1
  br i1 %38, label %39, label %40

39:                                               ; preds = %36, %33, %30, %2
  store i32 1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %113

40:                                               ; preds = %36
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %41, i32 0, i32 6
  %43 = getelementptr inbounds [6 x i32], ptr %42, i64 0, i64 0
  store volatile i32 2, ptr %43, align 8, !tbaa !9
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %44, i32 0, i32 6
  %46 = getelementptr inbounds [6 x i32], ptr %45, i64 0, i64 1
  store volatile i32 2, ptr %46, align 4, !tbaa !9
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %47, i32 0, i32 7
  %49 = getelementptr inbounds [4 x i32], ptr %48, i64 0, i64 0
  store volatile i32 2, ptr %49, align 8, !tbaa !9
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %50, i32 0, i32 7
  %52 = getelementptr inbounds [4 x i32], ptr %51, i64 0, i64 1
  store volatile i32 2, ptr %52, align 4, !tbaa !9
  %53 = load ptr, ptr %4, 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 = getelementptr inbounds %struct.TIM_TypeDef, ptr %55, i32 0, i32 3
  %57 = load volatile i32, ptr %56, align 4, !tbaa !14
  %58 = zext i32 %57 to i64
  %59 = or i64 %58, 2
  %60 = trunc i64 %59 to i32
  store volatile i32 %60, ptr %56, align 4, !tbaa !14
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !11
  %64 = getelementptr inbounds %struct.TIM_TypeDef, ptr %63, i32 0, i32 3
  %65 = load volatile i32, ptr %64, align 4, !tbaa !14
  %66 = zext i32 %65 to i64
  %67 = or i64 %66, 4
  %68 = trunc i64 %67 to i32
  store volatile i32 %68, ptr %64, align 4, !tbaa !14
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  call void @TIM_CCxChannelCmd(ptr noundef %71, i32 noundef 0, i32 noundef 1)
  %72 = load ptr, ptr %4, 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
  call void @TIM_CCxChannelCmd(ptr noundef %74, i32 noundef 4, i32 noundef 1)
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !11
  %78 = icmp eq ptr %77, inttoptr (i64 1073807360 to ptr)
  br i1 %78, label %99, label %79

79:                                               ; preds = %40
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !11
  %83 = icmp eq ptr %82, inttoptr (i64 1073808384 to ptr)
  br i1 %83, label %99, label %84

84:                                               ; preds = %79
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !11
  %88 = icmp eq ptr %87, inttoptr (i64 1073823744 to ptr)
  br i1 %88, label %99, label %89

89:                                               ; preds = %84
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !11
  %93 = icmp eq ptr %92, inttoptr (i64 1073824768 to ptr)
  br i1 %93, label %99, label %94

94:                                               ; preds = %89
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !11
  %98 = icmp eq ptr %97, inttoptr (i64 1073825792 to ptr)
  br label %99

99:                                               ; preds = %94, %89, %84, %79, %40
  %100 = phi i1 [ true, %89 ], [ true, %84 ], [ true, %79 ], [ true, %40 ], [ %98, %94 ]
  %101 = zext i1 %100 to i32
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %103, label %112

103:                                              ; preds = %99
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %104, i32 0, i32 0
  %106 = load ptr, ptr %105, align 8, !tbaa !11
  %107 = getelementptr inbounds %struct.TIM_TypeDef, ptr %106, i32 0, i32 17
  %108 = load volatile i32, ptr %107, align 4, !tbaa !16
  %109 = zext i32 %108 to i64
  %110 = or i64 %109, 32768
  %111 = trunc i64 %110 to i32
  store volatile i32 %111, ptr %107, align 4, !tbaa !16
  br label %112

112:                                              ; preds = %103, %99
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %113

113:                                              ; preds = %112, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %114 = load i32, ptr %3, align 4
  ret i32 %114
}

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


; 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 range(i32 0, 2) i32 @HAL_TIM_OnePulse_Start_IT(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 104
  %4 = load volatile i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 108
  %6 = load volatile i32, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 128
  %8 = load volatile i32, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 132
  %10 = load volatile i32, ptr %9, align 4, !tbaa !5
  %11 = icmp ne i32 %4, 1
  %12 = icmp ne i32 %6, 1
  %or.cond = select i1 %11, i1 true, i1 %12
  %13 = icmp ne i32 %8, 1
  %or.cond3 = select i1 %or.cond, i1 true, i1 %13
  %14 = icmp ne i32 %10, 1
  %or.cond5 = select i1 %or.cond3, i1 true, i1 %14
  br i1 %or.cond5, label %27, label %15

15:                                               ; preds = %2
  store volatile i32 2, ptr %3, align 8, !tbaa !5
  store volatile i32 2, ptr %5, align 4, !tbaa !5
  store volatile i32 2, ptr %7, align 8, !tbaa !5
  store volatile i32 2, ptr %9, align 4, !tbaa !5
  %16 = load ptr, ptr %0, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %16, i64 12
  %18 = load volatile i32, ptr %17, align 4, !tbaa !13
  %19 = or i32 %18, 2
  store volatile i32 %19, ptr %17, align 4, !tbaa !13
  %20 = load volatile i32, ptr %17, align 4, !tbaa !13
  %21 = or i32 %20, 4
  store volatile i32 %21, ptr %17, align 4, !tbaa !13
  tail call void @TIM_CCxChannelCmd(ptr noundef %16, i32 noundef 0, i32 noundef 1)
  %22 = load ptr, ptr %0, align 8, !tbaa !9
  tail call void @TIM_CCxChannelCmd(ptr noundef %22, i32 noundef 4, i32 noundef 1)
  %23 = load ptr, ptr %0, align 8, !tbaa !9
  %magicptr30 = ptrtoint ptr %23 to i64
  switch i64 %magicptr30, label %27 [
    i64 1073807360, label %.critedge
    i64 1073808384, label %.critedge
    i64 1073823744, label %.critedge
    i64 1073824768, label %.critedge
    i64 1073825792, label %.critedge
  ]

.critedge:                                        ; preds = %15, %15, %15, %15, %15
  %24 = getelementptr inbounds i8, ptr %23, i64 68
  %25 = load volatile i32, ptr %24, align 4, !tbaa !15
  %26 = or i32 %25, 32768
  store volatile i32 %26, ptr %24, align 4, !tbaa !15
  br label %27

27:                                               ; preds = %15, %.critedge, %2
  %.0 = phi i32 [ 1, %2 ], [ 0, %.critedge ], [ 0, %15 ]
  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 = !{!"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 68}


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