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

; 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.__RAMECC_HandleTypeDef = type { ptr, i32, ptr }
%struct.RAMECC_TypeDef = type { i32 }
%struct.RAMECC_MonitorTypeDef = 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_RAMECC_DisableNotification(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
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store i32 1, ptr %3, align 4
  br label %81

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.__RAMECC_HandleTypeDef, ptr %12, i32 0, i32 1
  %14 = load volatile i32, ptr %13, align 8, !tbaa !11
  store i32 %14, ptr %6, align 4, !tbaa !9
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %20, label %17

17:                                               ; preds = %11
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 2
  br i1 %19, label %20, label %76

20:                                               ; preds = %17, %11
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = and i64 %22, 268435457
  %24 = icmp eq i64 %23, 268435457
  br i1 %24, label %45, label %25

25:                                               ; preds = %20
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = and i64 %27, 268435458
  %29 = icmp eq i64 %28, 268435458
  br i1 %29, label %45, label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = and i64 %32, 268435460
  %34 = icmp eq i64 %33, 268435460
  br i1 %34, label %45, label %35

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

40:                                               ; preds = %35
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = and i64 %42, 268435471
  %44 = icmp eq i64 %43, 268435471
  br i1 %44, label %45, label %61

45:                                               ; preds = %40, %35, %30, %25, %20
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = and i64 %47, -268435457
  %49 = xor i64 %48, -1
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.__RAMECC_HandleTypeDef, ptr %50, i32 0, i32 0
  %52 = ptrtoint ptr %51 to i32
  %53 = and i32 %52, -256
  %54 = zext i32 %53 to i64
  %55 = inttoptr i64 %54 to ptr
  %56 = getelementptr inbounds %struct.RAMECC_TypeDef, ptr %55, i32 0, i32 0
  %57 = load volatile i32, ptr %56, align 4, !tbaa !13
  %58 = zext i32 %57 to i64
  %59 = and i64 %58, %49
  %60 = trunc i64 %59 to i32
  store volatile i32 %60, ptr %56, align 4, !tbaa !13
  br label %74

61:                                               ; preds = %40
  %62 = load i32, ptr %5, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = and i64 %63, -536870913
  %65 = xor i64 %64, -1
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.__RAMECC_HandleTypeDef, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = getelementptr inbounds %struct.RAMECC_MonitorTypeDef, ptr %68, i32 0, i32 0
  %70 = load volatile i32, ptr %69, align 4, !tbaa !16
  %71 = zext i32 %70 to i64
  %72 = and i64 %71, %65
  %73 = trunc i64 %72 to i32
  store volatile i32 %73, ptr %69, align 4, !tbaa !16
  br label %74

74:                                               ; preds = %61, %45
  %75 = phi i32 [ %60, %45 ], [ %73, %61 ]
  br label %79

76:                                               ; preds = %17
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.__RAMECC_HandleTypeDef, ptr %77, i32 0, i32 1
  store volatile i32 3, ptr %78, align 8, !tbaa !11
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %80

79:                                               ; preds = %74
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %80

80:                                               ; preds = %79, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %81

81:                                               ; preds = %80, %10
  %82 = load i32, ptr %3, align 4
  ret i32 %82
}

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 8}
!12 = !{!"__RAMECC_HandleTypeDef", !6, i64 0, !10, i64 8, !6, i64 16}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0}
!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}


; 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_RAMECC_DisableNotification(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %33, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load volatile i32, ptr %5, align 8, !tbaa !5
  %7 = add i32 %6, -1
  %or.cond = icmp ult i32 %7, 2
  br i1 %or.cond, label %8, label %32

8:                                                ; preds = %4
  %9 = zext i32 %1 to i64
  %10 = and i64 %9, 268435457
  %11 = icmp eq i64 %10, 268435457
  %12 = and i64 %9, 268435458
  %13 = icmp eq i64 %12, 268435458
  %or.cond17 = or i1 %11, %13
  %14 = and i64 %9, 268435460
  %15 = icmp eq i64 %14, 268435460
  %or.cond19 = or i1 %15, %or.cond17
  %16 = and i64 %9, 268435464
  %17 = icmp eq i64 %16, 268435464
  %or.cond23 = or i1 %17, %or.cond19
  br i1 %or.cond23, label %18, label %26

18:                                               ; preds = %8
  %19 = and i32 %1, -268435457
  %20 = xor i32 %19, -1
  %21 = ptrtoint ptr %0 to i64
  %22 = and i64 %21, 4294967040
  %23 = inttoptr i64 %22 to ptr
  %24 = load volatile i32, ptr %23, align 256, !tbaa !11
  %25 = and i32 %24, %20
  store volatile i32 %25, ptr %23, align 256, !tbaa !11
  br label %33

26:                                               ; preds = %8
  %27 = and i32 %1, -536870913
  %28 = xor i32 %27, -1
  %29 = load ptr, ptr %0, align 8, !tbaa !13
  %30 = load volatile i32, ptr %29, align 4, !tbaa !14
  %31 = and i32 %30, %28
  store volatile i32 %31, ptr %29, align 4, !tbaa !14
  br label %33

32:                                               ; preds = %4
  store volatile i32 3, ptr %5, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %32, %18, %26, %2
  %.1 = phi i32 [ 1, %2 ], [ 1, %32 ], [ 0, %18 ], [ 0, %26 ]
  ret i32 %.1
}

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, !10, i64 8}
!6 = !{!"__RAMECC_HandleTypeDef", !7, i64 0, !10, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}


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