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

; 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.FDCAN_HandleTypeDef = type { ptr, ptr, %struct.FDCAN_InitTypeDef, %struct.FDCAN_MsgRamAddressTypeDef, i32, i32, i32, i32 }
%struct.FDCAN_InitTypeDef = 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.FDCAN_MsgRamAddressTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.FDCAN_GlobalTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i32], i32, i32, i32, i32, i32, i32, i32, i32, [8 x 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, [2 x i32], i32, i32, i32, i32 }
%struct.FDCAN_ClockCalibrationUnit_TypeDef = type { 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
define dso_local i32 @HAL_FDCAN_ActivateNotification(ptr noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %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 %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %10, i32 0, i32 5
  %12 = load volatile i32, ptr %11, align 8, !tbaa !11
  store i32 %12, ptr %8, align 4, !tbaa !9
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %18, label %15

15:                                               ; preds = %3
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = icmp eq i32 %16, 2
  br i1 %17, label %18, label %100

18:                                               ; preds = %15, %3
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %22, i32 0, i32 19
  %24 = load volatile i32, ptr %23, align 4, !tbaa !16
  %25 = and i32 %19, %24
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %34

27:                                               ; preds = %18
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %30, i32 0, i32 20
  %32 = load volatile i32, ptr %31, align 4, !tbaa !18
  %33 = or i32 %32, 1
  store volatile i32 %33, ptr %31, align 4, !tbaa !18
  br label %57

34:                                               ; preds = %18
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %38, i32 0, i32 19
  %40 = load volatile i32, ptr %39, align 4, !tbaa !16
  %41 = and i32 %35, %40
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = icmp eq i32 %41, %42
  br i1 %43, label %44, label %51

44:                                               ; preds = %34
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  %48 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %47, i32 0, i32 20
  %49 = load volatile i32, ptr %48, align 4, !tbaa !18
  %50 = or i32 %49, 2
  store volatile i32 %50, ptr %48, align 4, !tbaa !18
  br label %56

51:                                               ; preds = %34
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %54, i32 0, i32 20
  store volatile i32 3, ptr %55, align 4, !tbaa !18
  br label %56

56:                                               ; preds = %51, %44
  br label %57

57:                                               ; preds = %56, %27
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = zext i32 %58 to i64
  %60 = and i64 %59, 512
  %61 = icmp ne i64 %60, 0
  br i1 %61, label %62, label %70

62:                                               ; preds = %57
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !15
  %67 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %66, i32 0, i32 46
  %68 = load volatile i32, ptr %67, align 4, !tbaa !19
  %69 = or i32 %68, %63
  store volatile i32 %69, ptr %67, align 4, !tbaa !19
  br label %70

70:                                               ; preds = %62, %57
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = zext i32 %71 to i64
  %73 = and i64 %72, 1024
  %74 = icmp ne i64 %73, 0
  br i1 %74, label %75, label %83

75:                                               ; preds = %70
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !15
  %80 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %79, i32 0, i32 47
  %81 = load volatile i32, ptr %80, align 4, !tbaa !20
  %82 = or i32 %81, %76
  store volatile i32 %82, ptr %80, align 4, !tbaa !20
  br label %83

83:                                               ; preds = %75, %70
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %6, align 4, !tbaa !9
  %86 = and i32 %85, 1070596095
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !15
  %90 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %89, i32 0, i32 18
  %91 = load volatile i32, ptr %90, align 4, !tbaa !21
  %92 = or i32 %91, %86
  store volatile i32 %92, ptr %90, align 4, !tbaa !21
  %93 = load i32, ptr %6, align 4, !tbaa !9
  %94 = and i32 %93, -1073741824
  %95 = lshr i32 %94, 30
  %96 = load volatile i32, ptr getelementptr inbounds (%struct.FDCAN_ClockCalibrationUnit_TypeDef, ptr inttoptr (i64 1073784832 to ptr), i32 0, i32 5), align 4, !tbaa !22
  %97 = or i32 %96, %95
  store volatile i32 %97, ptr getelementptr inbounds (%struct.FDCAN_ClockCalibrationUnit_TypeDef, ptr inttoptr (i64 1073784832 to ptr), i32 0, i32 5), align 4, !tbaa !22
  br label %98

98:                                               ; preds = %84
  br label %99

99:                                               ; preds = %98
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %105

100:                                              ; preds = %15
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %101, i32 0, i32 7
  %103 = load volatile i32, ptr %102, align 8, !tbaa !24
  %104 = or i32 %103, 2
  store volatile i32 %104, ptr %102, align 8, !tbaa !24
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %105

105:                                              ; preds = %100, %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %106 = load i32, ptr %4, align 4
  ret i32 %106
}

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, !10, i64 168}
!12 = !{!"", !6, i64 0, !6, i64 8, !13, i64 16, !14, i64 124, !10, i64 164, !10, i64 168, !10, i64 172, !10, i64 176}
!13 = !{!"", !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}
!14 = !{!"", !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}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !10, i64 88}
!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, !10, i64 40, !10, i64 44, !7, i64 48, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !7, i64 96, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192, !10, i64 196, !10, i64 200, !10, i64 204, !10, i64 208, !10, i64 212, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !7, i64 232, !10, i64 240, !10, i64 244, !10, i64 248, !10, i64 252}
!18 = !{!17, !10, i64 92}
!19 = !{!17, !10, i64 224}
!20 = !{!17, !10, i64 228}
!21 = !{!17, !10, i64 84}
!22 = !{!23, !10, i64 20}
!23 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!24 = !{!12, !10, i64 176}


; 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: nofree norecurse nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_FDCAN_ActivateNotification(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 168
  %5 = load volatile i32, ptr %4, align 8, !tbaa !5
  %6 = add i32 %5, -1
  %or.cond = icmp ult i32 %6, 2
  br i1 %or.cond, label %7, label %47

7:                                                ; preds = %3
  %8 = load ptr, ptr %0, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %8, i64 88
  %10 = load volatile i32, ptr %9, align 4, !tbaa !14
  %11 = and i32 %10, %1
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %17

13:                                               ; preds = %7
  %14 = getelementptr inbounds i8, ptr %8, i64 92
  %15 = load volatile i32, ptr %14, align 4, !tbaa !16
  %16 = or i32 %15, 1
  store volatile i32 %16, ptr %14, align 4, !tbaa !16
  br label %26

17:                                               ; preds = %7
  %18 = load volatile i32, ptr %9, align 4, !tbaa !14
  %19 = and i32 %18, %1
  %20 = icmp eq i32 %19, %1
  %21 = getelementptr inbounds i8, ptr %8, i64 92
  br i1 %20, label %22, label %25

22:                                               ; preds = %17
  %23 = load volatile i32, ptr %21, align 4, !tbaa !16
  %24 = or i32 %23, 2
  store volatile i32 %24, ptr %21, align 4, !tbaa !16
  br label %26

25:                                               ; preds = %17
  store volatile i32 3, ptr %21, align 4, !tbaa !16
  br label %26

26:                                               ; preds = %22, %25, %13
  %27 = zext i32 %1 to i64
  %28 = and i64 %27, 512
  %.not = icmp eq i64 %28, 0
  br i1 %.not, label %33, label %29

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %8, i64 224
  %31 = load volatile i32, ptr %30, align 4, !tbaa !17
  %32 = or i32 %31, %2
  store volatile i32 %32, ptr %30, align 4, !tbaa !17
  br label %33

33:                                               ; preds = %29, %26
  %34 = and i64 %27, 1024
  %.not22 = icmp eq i64 %34, 0
  br i1 %.not22, label %39, label %35

35:                                               ; preds = %33
  %36 = getelementptr inbounds i8, ptr %8, i64 228
  %37 = load volatile i32, ptr %36, align 4, !tbaa !18
  %38 = or i32 %37, %2
  store volatile i32 %38, ptr %36, align 4, !tbaa !18
  br label %39

39:                                               ; preds = %33, %35
  %40 = and i32 %1, 1070596095
  %41 = getelementptr inbounds i8, ptr %8, i64 84
  %42 = load volatile i32, ptr %41, align 4, !tbaa !19
  %43 = or i32 %42, %40
  store volatile i32 %43, ptr %41, align 4, !tbaa !19
  %44 = lshr i32 %1, 30
  %45 = load volatile i32, ptr inttoptr (i64 1073784852 to ptr), align 4, !tbaa !20
  %46 = or i32 %45, %44
  store volatile i32 %46, ptr inttoptr (i64 1073784852 to ptr), align 4, !tbaa !20
  br label %51

47:                                               ; preds = %3
  %48 = getelementptr inbounds i8, ptr %0, i64 176
  %49 = load volatile i32, ptr %48, align 8, !tbaa !22
  %50 = or i32 %49, 2
  store volatile i32 %50, ptr %48, align 8, !tbaa !22
  br label %51

51:                                               ; preds = %47, %39
  %.0 = phi i32 [ 0, %39 ], [ 1, %47 ]
  ret i32 %.0
}

attributes #0 = { nofree norecurse 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 168}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !12, i64 124, !11, i64 164, !11, i64 168, !11, i64 172, !11, i64 176}
!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, 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}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !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}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !11, i64 88}
!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, !8, i64 48, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !8, i64 96, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !11, i64 152, !11, i64 156, !11, i64 160, !11, i64 164, !11, i64 168, !11, i64 172, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192, !11, i64 196, !11, i64 200, !11, i64 204, !11, i64 208, !11, i64 212, !11, i64 216, !11, i64 220, !11, i64 224, !11, i64 228, !8, i64 232, !11, i64 240, !11, i64 244, !11, i64 248, !11, i64 252}
!16 = !{!15, !11, i64 92}
!17 = !{!15, !11, i64 224}
!18 = !{!15, !11, i64 228}
!19 = !{!15, !11, i64 84}
!20 = !{!21, !11, i64 20}
!21 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!22 = !{!6, !11, i64 176}


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