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

; 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_DeactivateNotification(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
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %9, i32 0, i32 5
  %11 = load volatile i32, ptr %10, align 8, !tbaa !11
  store i32 %11, ptr %7, align 4, !tbaa !9
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %17, label %14

14:                                               ; preds = %2
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp eq i32 %15, 2
  br i1 %16, label %17, label %94

17:                                               ; preds = %14, %2
  br label %18

18:                                               ; preds = %17
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = and i32 %19, 1070596095
  %21 = xor i32 %20, -1
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %24, i32 0, i32 18
  %26 = load volatile i32, ptr %25, align 4, !tbaa !16
  %27 = and i32 %26, %21
  store volatile i32 %27, ptr %25, align 4, !tbaa !16
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = and i32 %28, -1073741824
  %30 = lshr i32 %29, 30
  %31 = xor i32 %30, -1
  %32 = load volatile i32, ptr getelementptr inbounds (%struct.FDCAN_ClockCalibrationUnit_TypeDef, ptr inttoptr (i64 1073784832 to ptr), i32 0, i32 5), align 4, !tbaa !18
  %33 = and i32 %32, %31
  store volatile i32 %33, ptr getelementptr inbounds (%struct.FDCAN_ClockCalibrationUnit_TypeDef, ptr inttoptr (i64 1073784832 to ptr), i32 0, i32 5), align 4, !tbaa !18
  br label %34

34:                                               ; preds = %18
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = and i64 %37, 512
  %39 = icmp ne i64 %38, 0
  br i1 %39, label %40, label %45

40:                                               ; preds = %35
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %43, i32 0, i32 46
  store volatile i32 0, ptr %44, align 4, !tbaa !20
  br label %45

45:                                               ; preds = %40, %35
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = and i64 %47, 1024
  %49 = icmp ne i64 %48, 0
  br i1 %49, label %50, label %55

50:                                               ; preds = %45
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %53, i32 0, i32 47
  store volatile i32 0, ptr %54, align 4, !tbaa !21
  br label %55

55:                                               ; preds = %50, %45
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %58, i32 0, i32 19
  %60 = load volatile i32, ptr %59, align 4, !tbaa !22
  store i32 %60, ptr %6, align 4, !tbaa !9
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  %64 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %63, i32 0, i32 18
  %65 = load volatile i32, ptr %64, align 4, !tbaa !16
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = or i32 %65, %66
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = icmp eq i32 %67, %68
  br i1 %69, label %70, label %77

70:                                               ; preds = %55
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !15
  %74 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %73, i32 0, i32 20
  %75 = load volatile i32, ptr %74, align 4, !tbaa !23
  %76 = and i32 %75, -2
  store volatile i32 %76, ptr %74, align 4, !tbaa !23
  br label %77

77:                                               ; preds = %70, %55
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = getelementptr inbounds %struct.FDCAN_GlobalTypeDef, ptr %80, i32 0, i32 18
  %82 = load volatile i32, ptr %81, align 4, !tbaa !16
  %83 = load i32, ptr %6, align 4, !tbaa !9
  %84 = and i32 %82, %83
  %85 = icmp eq i32 %84, 0
  br i1 %85, label %86, label %93

86:                                               ; preds = %77
  %87 = load ptr, ptr %4, 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 20
  %91 = load volatile i32, ptr %90, align 4, !tbaa !23
  %92 = and i32 %91, -3
  store volatile i32 %92, ptr %90, align 4, !tbaa !23
  br label %93

93:                                               ; preds = %86, %77
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %99

94:                                               ; preds = %14
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %95, i32 0, i32 7
  %97 = load volatile i32, ptr %96, align 8, !tbaa !24
  %98 = or i32 %97, 2
  store volatile i32 %98, ptr %96, align 8, !tbaa !24
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %99

99:                                               ; preds = %94, %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %100 = load i32, ptr %3, align 4
  ret i32 %100
}

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 84}
!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 = !{!19, !10, i64 20}
!19 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!20 = !{!17, !10, i64 224}
!21 = !{!17, !10, i64 228}
!22 = !{!17, !10, i64 88}
!23 = !{!17, !10, i64 92}
!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_DeactivateNotification(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 168
  %4 = load volatile i32, ptr %3, align 8, !tbaa !5
  %5 = add i32 %4, -1
  %or.cond = icmp ult i32 %5, 2
  br i1 %or.cond, label %6, label %43

6:                                                ; preds = %2
  %7 = and i32 %1, 1070596095
  %8 = xor i32 %7, -1
  %9 = load ptr, ptr %0, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %9, i64 84
  %11 = load volatile i32, ptr %10, align 4, !tbaa !14
  %12 = and i32 %11, %8
  store volatile i32 %12, ptr %10, align 4, !tbaa !14
  %13 = lshr i32 %1, 30
  %14 = xor i32 %13, -1
  %15 = load volatile i32, ptr inttoptr (i64 1073784852 to ptr), align 4, !tbaa !16
  %16 = and i32 %15, %14
  store volatile i32 %16, ptr inttoptr (i64 1073784852 to ptr), align 4, !tbaa !16
  %17 = zext i32 %1 to i64
  %18 = and i64 %17, 512
  %.not = icmp eq i64 %18, 0
  br i1 %.not, label %21, label %19

19:                                               ; preds = %6
  %20 = getelementptr inbounds i8, ptr %9, i64 224
  store volatile i32 0, ptr %20, align 4, !tbaa !18
  br label %21

21:                                               ; preds = %19, %6
  %22 = and i64 %17, 1024
  %.not20 = icmp eq i64 %22, 0
  br i1 %.not20, label %25, label %23

23:                                               ; preds = %21
  %24 = getelementptr inbounds i8, ptr %9, i64 228
  store volatile i32 0, ptr %24, align 4, !tbaa !19
  br label %25

25:                                               ; preds = %23, %21
  %26 = getelementptr inbounds i8, ptr %9, i64 88
  %27 = load volatile i32, ptr %26, align 4, !tbaa !20
  %28 = load volatile i32, ptr %10, align 4, !tbaa !14
  %29 = or i32 %28, %27
  %30 = icmp eq i32 %29, %27
  br i1 %30, label %31, label %35

31:                                               ; preds = %25
  %32 = getelementptr inbounds i8, ptr %9, i64 92
  %33 = load volatile i32, ptr %32, align 4, !tbaa !21
  %34 = and i32 %33, -2
  store volatile i32 %34, ptr %32, align 4, !tbaa !21
  br label %35

35:                                               ; preds = %31, %25
  %36 = load volatile i32, ptr %10, align 4, !tbaa !14
  %37 = and i32 %36, %27
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %47

39:                                               ; preds = %35
  %40 = getelementptr inbounds i8, ptr %9, i64 92
  %41 = load volatile i32, ptr %40, align 4, !tbaa !21
  %42 = and i32 %41, -3
  store volatile i32 %42, ptr %40, align 4, !tbaa !21
  br label %47

43:                                               ; preds = %2
  %44 = getelementptr inbounds i8, ptr %0, i64 176
  %45 = load volatile i32, ptr %44, align 8, !tbaa !22
  %46 = or i32 %45, 2
  store volatile i32 %46, ptr %44, align 8, !tbaa !22
  br label %47

47:                                               ; preds = %35, %39, %43
  %.0 = phi i32 [ 1, %43 ], [ 0, %39 ], [ 0, %35 ]
  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 84}
!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 = !{!17, !11, i64 20}
!17 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!18 = !{!15, !11, i64 224}
!19 = !{!15, !11, i64 228}
!20 = !{!15, !11, i64 88}
!21 = !{!15, !11, i64 92}
!22 = !{!6, !11, i64 176}


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