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

; 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.HRTIM_HandleTypeDef = type { ptr, %struct.HRTIM_InitTypeDef, [6 x %struct.HRTIM_TimerParamTypeDef], i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.HRTIM_InitTypeDef = type { i32, i32, i32, i32, i32 }
%struct.HRTIM_TimerParamTypeDef = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.HRTIM_TimerCfgTypeDef = type { 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_HRTIM_WaveformTimerConfig(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %8, i32 0, i32 4
  %10 = load volatile i32, ptr %9, align 8, !tbaa !11
  %11 = icmp eq i32 %10, 2
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  store i32 2, ptr %4, align 4
  br label %90

13:                                               ; preds = %3
  br label %14

14:                                               ; preds = %13
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %15, i32 0, i32 3
  %17 = load i32, ptr %16, align 4, !tbaa !14
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  store i32 2, ptr %4, align 4
  br label %90

20:                                               ; preds = %14
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %21, i32 0, i32 3
  store i32 1, ptr %22, align 4, !tbaa !14
  br label %23

23:                                               ; preds = %20
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %25, i32 0, i32 4
  store volatile i32 2, ptr %26, align 8, !tbaa !11
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = icmp eq i32 %27, 5
  br i1 %28, label %29, label %32

29:                                               ; preds = %24
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  call void @HRTIM_MasterWaveform_Config(ptr noundef %30, ptr noundef %31)
  br label %36

32:                                               ; preds = %24
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  call void @HRTIM_TimingUnitWaveform_Config(ptr noundef %33, i32 noundef %34, ptr noundef %35)
  br label %36

36:                                               ; preds = %32, %29
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.HRTIM_TimerCfgTypeDef, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %40, i32 0, i32 2
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds [6 x %struct.HRTIM_TimerParamTypeDef], ptr %41, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.HRTIM_TimerParamTypeDef, ptr %44, i32 0, i32 2
  store i32 %39, ptr %45, align 4, !tbaa !17
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.HRTIM_TimerCfgTypeDef, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !19
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds [6 x %struct.HRTIM_TimerParamTypeDef], ptr %50, i64 0, i64 %52
  %54 = getelementptr inbounds %struct.HRTIM_TimerParamTypeDef, ptr %53, i32 0, i32 3
  store i32 %48, ptr %54, align 4, !tbaa !20
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.HRTIM_TimerCfgTypeDef, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 4, !tbaa !21
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %58, i32 0, i32 2
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds [6 x %struct.HRTIM_TimerParamTypeDef], ptr %59, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.HRTIM_TimerParamTypeDef, ptr %62, i32 0, i32 4
  store i32 %57, ptr %63, align 4, !tbaa !22
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.HRTIM_TimerCfgTypeDef, ptr %64, i32 0, i32 3
  %66 = load i32, ptr %65, align 4, !tbaa !23
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %67, i32 0, i32 2
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds [6 x %struct.HRTIM_TimerParamTypeDef], ptr %68, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.HRTIM_TimerParamTypeDef, ptr %71, i32 0, i32 5
  store i32 %66, ptr %72, align 4, !tbaa !24
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.HRTIM_TimerCfgTypeDef, ptr %73, i32 0, i32 4
  %75 = load i32, ptr %74, align 4, !tbaa !25
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %76, i32 0, i32 2
  %78 = load i32, ptr %6, align 4, !tbaa !9
  %79 = zext i32 %78 to i64
  %80 = getelementptr inbounds [6 x %struct.HRTIM_TimerParamTypeDef], ptr %77, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.HRTIM_TimerParamTypeDef, ptr %80, i32 0, i32 6
  store i32 %75, ptr %81, align 4, !tbaa !26
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = load i32, ptr %6, align 4, !tbaa !9
  call void @HRTIM_ForceRegistersUpdate(ptr noundef %82, i32 noundef %83)
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %84, i32 0, i32 4
  store volatile i32 1, ptr %85, align 8, !tbaa !11
  br label %86

86:                                               ; preds = %36
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.HRTIM_HandleTypeDef, ptr %87, i32 0, i32 3
  store i32 0, ptr %88, align 4, !tbaa !14
  br label %89

89:                                               ; preds = %86
  store i32 0, ptr %4, align 4
  br label %90

90:                                               ; preds = %89, %19, %12
  %91 = load i32, ptr %4, align 4
  ret i32 %91
}

; Function Attrs: nounwind uwtable
declare hidden void @HRTIM_MasterWaveform_Config(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @HRTIM_TimingUnitWaveform_Config(ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @HRTIM_ForceRegistersUpdate(ptr noundef, i32 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 200}
!12 = !{!"", !6, i64 0, !13, i64 8, !7, i64 28, !10, i64 196, !10, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!14 = !{!12, !10, i64 196}
!15 = !{!16, !10, i64 0}
!16 = !{!"", !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}
!17 = !{!18, !10, i64 8}
!18 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!19 = !{!16, !10, i64 4}
!20 = !{!18, !10, i64 12}
!21 = !{!16, !10, i64 8}
!22 = !{!18, !10, i64 16}
!23 = !{!16, !10, i64 12}
!24 = !{!18, !10, i64 20}
!25 = !{!16, !10, i64 16}
!26 = !{!18, !10, i64 24}


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

%struct.HRTIM_TimerParamTypeDef = type { i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @HAL_HRTIM_WaveformTimerConfig(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 200
  %5 = load volatile i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 2
  br i1 %6, label %24, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 196
  %9 = load i32, ptr %8, align 4, !tbaa !12
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %24, label %11

11:                                               ; preds = %7
  store i32 1, ptr %8, align 4, !tbaa !12
  store volatile i32 2, ptr %4, align 8, !tbaa !5
  %12 = icmp eq i32 %1, 5
  br i1 %12, label %13, label %14

13:                                               ; preds = %11
  tail call void @HRTIM_MasterWaveform_Config(ptr noundef nonnull %0, ptr noundef %2)
  br label %15

14:                                               ; preds = %11
  tail call void @HRTIM_TimingUnitWaveform_Config(ptr noundef nonnull %0, i32 noundef %1, ptr noundef %2)
  br label %15

15:                                               ; preds = %14, %13
  %16 = getelementptr inbounds i8, ptr %0, i64 28
  %17 = zext i32 %1 to i64
  %18 = getelementptr inbounds [6 x %struct.HRTIM_TimerParamTypeDef], ptr %16, i64 0, i64 %17
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load <4 x i32>, ptr %2, align 4, !tbaa !13
  store <4 x i32> %20, ptr %19, align 4, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %2, i64 16
  %22 = load i32, ptr %21, align 4, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %18, i64 24
  store i32 %22, ptr %23, align 4, !tbaa !16
  tail call void @HRTIM_ForceRegistersUpdate(ptr noundef nonnull %0, i32 noundef %1)
  store volatile i32 1, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !12
  br label %24

24:                                               ; preds = %7, %3, %15
  %.0 = phi i32 [ 0, %15 ], [ 2, %3 ], [ 2, %7 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden void @HRTIM_MasterWaveform_Config(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @HRTIM_TimingUnitWaveform_Config(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @HRTIM_ForceRegistersUpdate(ptr noundef, i32 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 200}
!6 = !{!"", !7, i64 0, !10, i64 8, !8, i64 28, !11, i64 196, !11, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !7, i64 240, !7, i64 248}
!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 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 196}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !11, i64 16}
!15 = !{!"", !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}
!16 = !{!17, !11, i64 24}
!17 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}


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