; 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.SWPMI_HandleTypeDef = type { ptr, %struct.SWPMI_InitTypeDef, ptr, i32, i32, ptr, i32, i32, ptr, ptr, i32, i32, i32 }
%struct.SWPMI_InitTypeDef = type { i32, i32, i32, i32 }
%struct.SWPMI_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

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

8:                                                ; preds = %1
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %117

9:                                                ; preds = %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %10, i32 0, i32 11
  %12 = load volatile i32, ptr %11, align 4, !tbaa !11
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %18

14:                                               ; preds = %9
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %15, i32 0, i32 10
  store i32 0, ptr %16, align 8, !tbaa !14
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_SWPMI_MspInit(ptr noundef %17)
  br label %18

18:                                               ; preds = %14, %9
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %19, i32 0, i32 11
  store volatile i32 2, ptr %20, align 4, !tbaa !11
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %23, i32 0, i32 0
  %25 = load volatile i32, ptr %24, align 4, !tbaa !16
  %26 = zext i32 %25 to i64
  %27 = and i64 %26, -33
  %28 = trunc i64 %27 to i32
  store volatile i32 %28, ptr %24, align 4, !tbaa !16
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %31, i32 0, i32 4
  store volatile i32 2463, ptr %32, align 4, !tbaa !18
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !15
  %36 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %35, i32 0, i32 9
  %37 = load volatile i32, ptr %36, align 4, !tbaa !19
  %38 = zext i32 %37 to i64
  %39 = and i64 %38, -3
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %40, i32 0, i32 1
  %42 = getelementptr inbounds %struct.SWPMI_InitTypeDef, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 8, !tbaa !20
  %44 = zext i32 %43 to i64
  %45 = or i64 %39, %44
  %46 = trunc i64 %45 to i32
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %49, i32 0, i32 9
  store volatile i32 %46, ptr %50, align 4, !tbaa !19
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds %struct.SWPMI_InitTypeDef, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !21
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %57, i32 0, i32 1
  store volatile i32 %54, ptr %58, align 4, !tbaa !22
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %61, i32 0, i32 0
  %63 = load volatile i32, ptr %62, align 4, !tbaa !16
  %64 = zext i32 %63 to i64
  %65 = and i64 %64, -16
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %66, i32 0, i32 1
  %68 = getelementptr inbounds %struct.SWPMI_InitTypeDef, ptr %67, i32 0, i32 2
  %69 = load i32, ptr %68, align 8, !tbaa !23
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %70, i32 0, i32 1
  %72 = getelementptr inbounds %struct.SWPMI_InitTypeDef, ptr %71, i32 0, i32 3
  %73 = load i32, ptr %72, align 4, !tbaa !24
  %74 = or i32 %69, %73
  %75 = zext i32 %74 to i64
  %76 = or i64 %65, %75
  %77 = trunc i64 %76 to i32
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %80, i32 0, i32 0
  store volatile i32 %77, ptr %81, align 4, !tbaa !16
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !15
  %85 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %84, i32 0, i32 0
  %86 = load volatile i32, ptr %85, align 4, !tbaa !16
  %87 = zext i32 %86 to i64
  %88 = or i64 %87, 2048
  %89 = trunc i64 %88 to i32
  store volatile i32 %89, ptr %85, align 4, !tbaa !16
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = load i32, ptr %4, align 4, !tbaa !9
  %92 = call i32 @SWPMI_WaitOnFlagSetUntilTimeout(ptr noundef %90, i32 noundef 2048, i32 noundef %91, i32 noundef 2000)
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %95

94:                                               ; preds = %18
  store i32 3, ptr %3, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %94, %18
  %96 = load i32, ptr %3, align 4, !tbaa !9
  %97 = icmp eq i32 %96, 0
  br i1 %97, label %98, label %111

98:                                               ; preds = %95
  %99 = load ptr, ptr %2, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %99, i32 0, i32 12
  store volatile i32 0, ptr %100, align 8, !tbaa !25
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %101, i32 0, i32 11
  store volatile i32 1, ptr %102, align 4, !tbaa !11
  %103 = load ptr, ptr %2, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8, !tbaa !15
  %106 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %105, i32 0, i32 0
  %107 = load volatile i32, ptr %106, align 4, !tbaa !16
  %108 = zext i32 %107 to i64
  %109 = or i64 %108, 32
  %110 = trunc i64 %109 to i32
  store volatile i32 %110, ptr %106, align 4, !tbaa !16
  br label %116

111:                                              ; preds = %95
  %112 = load ptr, ptr %2, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %112, i32 0, i32 12
  store volatile i32 128, ptr %113, align 8, !tbaa !25
  %114 = load ptr, ptr %2, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %114, i32 0, i32 11
  store volatile i32 4, ptr %115, align 4, !tbaa !11
  br label %116

116:                                              ; preds = %111, %98
  br label %117

117:                                              ; preds = %116, %8
  %118 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i32 %118
}

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

declare i32 @HAL_GetTick() #2

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
attributes #2 = { "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, !10, i64 76}
!12 = !{!"", !6, i64 0, !13, i64 8, !6, i64 24, !10, i64 32, !10, i64 36, !6, i64 40, !10, i64 48, !10, i64 52, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!14 = !{!12, !10, i64 72}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !10, i64 0}
!17 = !{!"", !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}
!18 = !{!17, !10, i64 16}
!19 = !{!17, !10, i64 36}
!20 = !{!12, !10, i64 8}
!21 = !{!12, !10, i64 12}
!22 = !{!17, !10, i64 4}
!23 = !{!12, !10, i64 16}
!24 = !{!12, !10, i64 20}
!25 = !{!12, !10, i64 80}


; 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
define dso_local range(i32 0, 4) i32 @HAL_SWPMI_Init(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @HAL_GetTick() #2
  %3 = icmp eq ptr %0, null
  br i1 %3, label %41, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 76
  %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 72
  store i32 0, ptr %9, align 8, !tbaa !12
  tail call void @HAL_SWPMI_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 = load volatile i32, ptr %11, align 4, !tbaa !14
  %13 = and i32 %12, -33
  store volatile i32 %13, ptr %11, align 4, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %11, i64 16
  store volatile i32 2463, ptr %14, align 4, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %11, i64 36
  %16 = load volatile i32, ptr %15, align 4, !tbaa !17
  %17 = and i32 %16, -3
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load i32, ptr %18, align 8, !tbaa !18
  %20 = or i32 %17, %19
  store volatile i32 %20, ptr %15, align 4, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %0, i64 12
  %22 = load i32, ptr %21, align 4, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %11, i64 4
  store volatile i32 %22, ptr %23, align 4, !tbaa !20
  %24 = load volatile i32, ptr %11, align 4, !tbaa !14
  %25 = and i32 %24, -16
  %26 = getelementptr inbounds i8, ptr %0, i64 16
  %27 = load i32, ptr %26, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %0, i64 20
  %29 = load i32, ptr %28, align 4, !tbaa !22
  %30 = or i32 %25, %27
  %31 = or i32 %30, %29
  store volatile i32 %31, ptr %11, align 4, !tbaa !14
  %32 = load volatile i32, ptr %11, align 4, !tbaa !14
  %33 = or i32 %32, 2048
  store volatile i32 %33, ptr %11, align 4, !tbaa !14
  %34 = tail call i32 @SWPMI_WaitOnFlagSetUntilTimeout(ptr noundef nonnull %0, i32 noundef 2048, i32 noundef %2, i32 noundef 2000)
  %.not = icmp eq i32 %34, 0
  %35 = getelementptr inbounds i8, ptr %0, i64 80
  br i1 %.not, label %36, label %40

36:                                               ; preds = %10
  store volatile i32 0, ptr %35, align 8, !tbaa !23
  store volatile i32 1, ptr %5, align 4, !tbaa !5
  %37 = load ptr, ptr %0, align 8, !tbaa !13
  %38 = load volatile i32, ptr %37, align 4, !tbaa !14
  %39 = or i32 %38, 32
  store volatile i32 %39, ptr %37, align 4, !tbaa !14
  br label %41

40:                                               ; preds = %10
  store volatile i32 128, ptr %35, align 8, !tbaa !23
  store volatile i32 4, ptr %5, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %1, %36, %40
  %.1 = phi i32 [ 0, %36 ], [ 3, %40 ], [ 1, %1 ]
  ret i32 %.1
}

declare i32 @HAL_GetTick() local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @SWPMI_WaitOnFlagSetUntilTimeout(ptr noundef, i32 noundef, i32 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" }
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 }

!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 76}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 24, !11, i64 32, !11, i64 36, !7, i64 40, !11, i64 48, !11, i64 52, !7, i64 56, !7, i64 64, !11, i64 72, !11, i64 76, !11, i64 80}
!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 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 72}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !11, i64 0}
!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}
!16 = !{!15, !11, i64 16}
!17 = !{!15, !11, i64 36}
!18 = !{!6, !11, i64 8}
!19 = !{!6, !11, i64 12}
!20 = !{!15, !11, i64 4}
!21 = !{!6, !11, i64 16}
!22 = !{!6, !11, i64 20}
!23 = !{!6, !11, i64 80}


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