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

; 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 }
%struct.TIM_Encoder_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_TIM_Encoder_Init(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

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

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %14, i32 0, i32 5
  %16 = load volatile i32, ptr %15, align 4, !tbaa !9
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %22

18:                                               ; preds = %13
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %19, i32 0, i32 4
  store i32 0, ptr %20, align 8, !tbaa !13
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  call void @HAL_TIM_Encoder_MspInit(ptr noundef %21)
  br label %22

22:                                               ; preds = %18, %13
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %23, i32 0, i32 5
  store volatile i32 2, ptr %24, align 4, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = getelementptr inbounds %struct.TIM_TypeDef, ptr %27, i32 0, i32 2
  %29 = load volatile i32, ptr %28, align 4, !tbaa !15
  %30 = zext i32 %29 to i64
  %31 = and i64 %30, -81928
  %32 = trunc i64 %31 to i32
  store volatile i32 %32, ptr %28, align 4, !tbaa !15
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %36, i32 0, i32 1
  call void @TIM_Base_SetConfig(ptr noundef %35, ptr noundef %37)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = getelementptr inbounds %struct.TIM_TypeDef, ptr %40, i32 0, i32 2
  %42 = load volatile i32, ptr %41, align 4, !tbaa !15
  store i32 %42, ptr %6, align 4, !tbaa !17
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = getelementptr inbounds %struct.TIM_TypeDef, ptr %45, i32 0, i32 6
  %47 = load volatile i32, ptr %46, align 4, !tbaa !18
  store i32 %47, ptr %7, align 4, !tbaa !17
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds %struct.TIM_TypeDef, ptr %50, i32 0, i32 8
  %52 = load volatile i32, ptr %51, align 4, !tbaa !19
  store i32 %52, ptr %8, align 4, !tbaa !17
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.TIM_Encoder_InitTypeDef, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 4, !tbaa !20
  %56 = load i32, ptr %6, align 4, !tbaa !17
  %57 = or i32 %56, %55
  store i32 %57, ptr %6, align 4, !tbaa !17
  %58 = load i32, ptr %7, align 4, !tbaa !17
  %59 = zext i32 %58 to i64
  %60 = and i64 %59, -772
  %61 = trunc i64 %60 to i32
  store i32 %61, ptr %7, align 4, !tbaa !17
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.TIM_Encoder_InitTypeDef, ptr %62, i32 0, i32 2
  %64 = load i32, ptr %63, align 4, !tbaa !22
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.TIM_Encoder_InitTypeDef, ptr %65, i32 0, i32 6
  %67 = load i32, ptr %66, align 4, !tbaa !23
  %68 = shl i32 %67, 8
  %69 = or i32 %64, %68
  %70 = load i32, ptr %7, align 4, !tbaa !17
  %71 = or i32 %70, %69
  store i32 %71, ptr %7, align 4, !tbaa !17
  %72 = load i32, ptr %7, align 4, !tbaa !17
  %73 = zext i32 %72 to i64
  %74 = and i64 %73, -3085
  %75 = trunc i64 %74 to i32
  store i32 %75, ptr %7, align 4, !tbaa !17
  %76 = load i32, ptr %7, align 4, !tbaa !17
  %77 = zext i32 %76 to i64
  %78 = and i64 %77, -61681
  %79 = trunc i64 %78 to i32
  store i32 %79, ptr %7, align 4, !tbaa !17
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.TIM_Encoder_InitTypeDef, ptr %80, i32 0, i32 3
  %82 = load i32, ptr %81, align 4, !tbaa !24
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.TIM_Encoder_InitTypeDef, ptr %83, i32 0, i32 7
  %85 = load i32, ptr %84, align 4, !tbaa !25
  %86 = shl i32 %85, 8
  %87 = or i32 %82, %86
  %88 = load i32, ptr %7, align 4, !tbaa !17
  %89 = or i32 %88, %87
  store i32 %89, ptr %7, align 4, !tbaa !17
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.TIM_Encoder_InitTypeDef, ptr %90, i32 0, i32 4
  %92 = load i32, ptr %91, align 4, !tbaa !26
  %93 = shl i32 %92, 4
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.TIM_Encoder_InitTypeDef, ptr %94, i32 0, i32 8
  %96 = load i32, ptr %95, align 4, !tbaa !27
  %97 = shl i32 %96, 12
  %98 = or i32 %93, %97
  %99 = load i32, ptr %7, align 4, !tbaa !17
  %100 = or i32 %99, %98
  store i32 %100, ptr %7, align 4, !tbaa !17
  %101 = load i32, ptr %8, align 4, !tbaa !17
  %102 = zext i32 %101 to i64
  %103 = and i64 %102, -35
  %104 = trunc i64 %103 to i32
  store i32 %104, ptr %8, align 4, !tbaa !17
  %105 = load i32, ptr %8, align 4, !tbaa !17
  %106 = zext i32 %105 to i64
  %107 = and i64 %106, -137
  %108 = trunc i64 %107 to i32
  store i32 %108, ptr %8, align 4, !tbaa !17
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.TIM_Encoder_InitTypeDef, ptr %109, i32 0, i32 1
  %111 = load i32, ptr %110, align 4, !tbaa !28
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.TIM_Encoder_InitTypeDef, ptr %112, i32 0, i32 5
  %114 = load i32, ptr %113, align 4, !tbaa !29
  %115 = shl i32 %114, 4
  %116 = or i32 %111, %115
  %117 = load i32, ptr %8, align 4, !tbaa !17
  %118 = or i32 %117, %116
  store i32 %118, ptr %8, align 4, !tbaa !17
  %119 = load i32, ptr %6, align 4, !tbaa !17
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %120, i32 0, i32 0
  %122 = load ptr, ptr %121, align 8, !tbaa !14
  %123 = getelementptr inbounds %struct.TIM_TypeDef, ptr %122, i32 0, i32 2
  store volatile i32 %119, ptr %123, align 4, !tbaa !15
  %124 = load i32, ptr %7, align 4, !tbaa !17
  %125 = load ptr, ptr %4, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %125, i32 0, i32 0
  %127 = load ptr, ptr %126, align 8, !tbaa !14
  %128 = getelementptr inbounds %struct.TIM_TypeDef, ptr %127, i32 0, i32 6
  store volatile i32 %124, ptr %128, align 4, !tbaa !18
  %129 = load i32, ptr %8, align 4, !tbaa !17
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %130, i32 0, i32 0
  %132 = load ptr, ptr %131, align 8, !tbaa !14
  %133 = getelementptr inbounds %struct.TIM_TypeDef, ptr %132, i32 0, i32 8
  store volatile i32 %129, ptr %133, align 4, !tbaa !19
  %134 = load ptr, ptr %4, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %134, i32 0, i32 5
  store volatile i32 1, ptr %135, align 4, !tbaa !9
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %136

136:                                              ; preds = %22, %12
  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
  %137 = load i32, ptr %3, align 4
  ret i32 %137
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_TIM_Encoder_MspInit(ptr 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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 100}
!10 = !{!"", !6, i64 0, !11, i64 8, !12, i64 32, !7, i64 40, !12, i64 96, !12, i64 100}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 96}
!14 = !{!10, !6, i64 0}
!15 = !{!16, !12, i64 8}
!16 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104}
!17 = !{!12, !12, i64 0}
!18 = !{!16, !12, i64 24}
!19 = !{!16, !12, i64 32}
!20 = !{!21, !12, i64 0}
!21 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32}
!22 = !{!21, !12, i64 8}
!23 = !{!21, !12, i64 24}
!24 = !{!21, !12, i64 12}
!25 = !{!21, !12, i64 28}
!26 = !{!21, !12, i64 16}
!27 = !{!21, !12, i64 32}
!28 = !{!21, !12, i64 4}
!29 = !{!21, !12, i64 20}


; 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_Base_SetConfig(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_TIM_Encoder_Init(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %56, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 100
  %6 = load volatile i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 0, ptr %9, align 8, !tbaa !12
  tail call void @HAL_TIM_Encoder_MspInit(ptr noundef nonnull %0)
  br label %10

10:                                               ; preds = %8, %4
  store volatile i32 2, ptr %5, align 4, !tbaa !5
  %11 = load ptr, ptr %0, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load volatile i32, ptr %12, align 4, !tbaa !14
  %14 = and i32 %13, -81928
  store volatile i32 %14, ptr %12, align 4, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @TIM_Base_SetConfig(ptr noundef %11, ptr noundef nonnull %15)
  %16 = load ptr, ptr %0, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = load volatile i32, ptr %17, align 4, !tbaa !14
  %19 = getelementptr inbounds i8, ptr %16, i64 24
  %20 = load volatile i32, ptr %19, align 4, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %16, i64 32
  %22 = load volatile i32, ptr %21, align 4, !tbaa !17
  %23 = load i32, ptr %1, align 4, !tbaa !18
  %24 = or i32 %23, %18
  %25 = and i32 %20, -65536
  %26 = getelementptr inbounds i8, ptr %1, i64 8
  %27 = load i32, ptr %26, align 4, !tbaa !20
  %28 = getelementptr inbounds i8, ptr %1, i64 24
  %29 = load i32, ptr %28, align 4, !tbaa !21
  %30 = shl i32 %29, 8
  %31 = or i32 %30, %27
  %.masked = and i32 %31, -64765
  %32 = getelementptr inbounds i8, ptr %1, i64 12
  %33 = load i32, ptr %32, align 4, !tbaa !22
  %34 = getelementptr inbounds i8, ptr %1, i64 28
  %35 = load i32, ptr %34, align 4, !tbaa !23
  %36 = shl i32 %35, 8
  %37 = getelementptr inbounds i8, ptr %1, i64 16
  %38 = load i32, ptr %37, align 4, !tbaa !24
  %39 = shl i32 %38, 4
  %40 = getelementptr inbounds i8, ptr %1, i64 32
  %41 = load i32, ptr %40, align 4, !tbaa !25
  %42 = shl i32 %41, 12
  %43 = or i32 %33, %25
  %44 = or i32 %43, %.masked
  %45 = or i32 %44, %36
  %46 = or i32 %45, %39
  %47 = or i32 %46, %42
  %48 = and i32 %22, -171
  %49 = getelementptr inbounds i8, ptr %1, i64 4
  %50 = load i32, ptr %49, align 4, !tbaa !26
  %51 = getelementptr inbounds i8, ptr %1, i64 20
  %52 = load i32, ptr %51, align 4, !tbaa !27
  %53 = shl i32 %52, 4
  %54 = or i32 %50, %48
  %55 = or i32 %54, %53
  store volatile i32 %24, ptr %17, align 4, !tbaa !14
  store volatile i32 %47, ptr %19, align 4, !tbaa !16
  store volatile i32 %55, ptr %21, align 4, !tbaa !17
  store volatile i32 1, ptr %5, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %2, %10
  %.0 = phi i32 [ 0, %10 ], [ 1, %2 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_TIM_Encoder_MspInit(ptr 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 100}
!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 = !{!6, !11, i64 96}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !11, i64 8}
!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, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104}
!16 = !{!15, !11, i64 24}
!17 = !{!15, !11, i64 32}
!18 = !{!19, !11, i64 0}
!19 = !{!"", !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}
!20 = !{!19, !11, i64 8}
!21 = !{!19, !11, i64 24}
!22 = !{!19, !11, i64 12}
!23 = !{!19, !11, i64 28}
!24 = !{!19, !11, i64 16}
!25 = !{!19, !11, i64 32}
!26 = !{!19, !11, i64 4}
!27 = !{!19, !11, i64 20}


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