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

; 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.RNG_HandleTypeDef = type { ptr, %struct.RNG_InitTypeDef, i32, i32, i32, i32 }
%struct.RNG_InitTypeDef = type { i32 }
%struct.RNG_TypeDef = type { 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 void @HAL_RNG_IRQHandler(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %4, i32 0, i32 0
  %6 = load ptr, ptr %5, align 8, !tbaa !11
  %7 = getelementptr inbounds %struct.RNG_TypeDef, ptr %6, i32 0, i32 1
  %8 = load volatile i32, ptr %7, align 4, !tbaa !14
  %9 = zext i32 %8 to i64
  %10 = and i64 %9, 32
  %11 = icmp eq i64 %10, 32
  %12 = zext i1 %11 to i32
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %15

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

15:                                               ; preds = %1
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = getelementptr inbounds %struct.RNG_TypeDef, ptr %18, i32 0, i32 1
  %20 = load volatile i32, ptr %19, align 4, !tbaa !14
  %21 = zext i32 %20 to i64
  %22 = and i64 %21, 64
  %23 = icmp eq i64 %22, 64
  %24 = zext i1 %23 to i32
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %15
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %28

27:                                               ; preds = %15
  br label %28

28:                                               ; preds = %27, %26
  br label %29

29:                                               ; preds = %28, %14
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = icmp eq i32 %30, 1
  br i1 %31, label %32, label %40

32:                                               ; preds = %29
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %33, i32 0, i32 3
  store volatile i32 4, ptr %34, align 8, !tbaa !16
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_RNG_ErrorCallback(ptr noundef %35)
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct.RNG_TypeDef, ptr %38, i32 0, i32 1
  store volatile i32 -97, ptr %39, align 4, !tbaa !14
  br label %40

40:                                               ; preds = %32, %29
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct.RNG_TypeDef, ptr %43, i32 0, i32 1
  %45 = load volatile i32, ptr %44, align 4, !tbaa !14
  %46 = zext i32 %45 to i64
  %47 = and i64 %46, 1
  %48 = icmp eq i64 %47, 1
  %49 = zext i1 %48 to i32
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %84

51:                                               ; preds = %40
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct.RNG_TypeDef, ptr %54, i32 0, i32 0
  %56 = load volatile i32, ptr %55, align 4, !tbaa !17
  %57 = zext i32 %56 to i64
  %58 = and i64 %57, -9
  %59 = trunc i64 %58 to i32
  store volatile i32 %59, ptr %55, align 4, !tbaa !17
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !11
  %63 = getelementptr inbounds %struct.RNG_TypeDef, ptr %62, i32 0, i32 2
  %64 = load volatile i32, ptr %63, align 4, !tbaa !18
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %65, i32 0, i32 5
  store i32 %64, ptr %66, align 8, !tbaa !19
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %67, i32 0, i32 3
  %69 = load volatile i32, ptr %68, align 8, !tbaa !16
  %70 = icmp ne i32 %69, 4
  br i1 %70, label %71, label %83

71:                                               ; preds = %51
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %72, i32 0, i32 3
  store volatile i32 1, ptr %73, align 8, !tbaa !16
  br label %74

74:                                               ; preds = %71
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %75, i32 0, i32 2
  store i32 0, ptr %76, align 4, !tbaa !20
  br label %77

77:                                               ; preds = %74
  br label %78

78:                                               ; preds = %77
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.RNG_HandleTypeDef, ptr %80, i32 0, i32 5
  %82 = load i32, ptr %81, align 8, !tbaa !19
  call void @HAL_RNG_ReadyDataCallback(ptr noundef %79, i32 noundef %82)
  br label %83

83:                                               ; preds = %78, %51
  br label %84

84:                                               ; preds = %83, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_RNG_ErrorCallback(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_RNG_ReadyDataCallback(ptr noundef, i32 noundef) #1

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, !6, i64 0}
!12 = !{!"", !6, i64 0, !13, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!13 = !{!"", !10, i64 0}
!14 = !{!15, !10, i64 4}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!16 = !{!12, !10, i64 16}
!17 = !{!15, !10, i64 0}
!18 = !{!15, !10, i64 8}
!19 = !{!12, !10, i64 24}
!20 = !{!12, !10, i64 12}


; 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 void @HAL_RNG_IRQHandler(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 4
  %4 = load volatile i32, ptr %3, align 4, !tbaa !12
  %5 = and i32 %4, 32
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %.critedge

6:                                                ; preds = %1
  %7 = load volatile i32, ptr %3, align 4, !tbaa !12
  %8 = and i32 %7, 64
  %.not14.not = icmp eq i32 %8, 0
  br i1 %.not14.not, label %12, label %.critedge

.critedge:                                        ; preds = %1, %6
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store volatile i32 4, ptr %9, align 8, !tbaa !14
  tail call void @HAL_RNG_ErrorCallback(ptr noundef nonnull %0)
  %10 = load ptr, ptr %0, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 4
  store volatile i32 -97, ptr %11, align 4, !tbaa !12
  br label %12

12:                                               ; preds = %.critedge, %6
  %13 = phi ptr [ %10, %.critedge ], [ %2, %6 ]
  %14 = getelementptr inbounds i8, ptr %13, i64 4
  %15 = load volatile i32, ptr %14, align 4, !tbaa !12
  %16 = and i32 %15, 1
  %.not15 = icmp eq i32 %16, 0
  br i1 %.not15, label %27, label %17

17:                                               ; preds = %12
  %18 = load volatile i32, ptr %13, align 4, !tbaa !15
  %19 = and i32 %18, -9
  store volatile i32 %19, ptr %13, align 4, !tbaa !15
  %20 = getelementptr inbounds i8, ptr %13, i64 8
  %21 = load volatile i32, ptr %20, align 4, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %21, ptr %22, align 8, !tbaa !17
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = load volatile i32, ptr %23, align 8, !tbaa !14
  %.not16 = icmp eq i32 %24, 4
  br i1 %.not16, label %27, label %25

25:                                               ; preds = %17
  store volatile i32 1, ptr %23, align 8, !tbaa !14
  %26 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 0, ptr %26, align 4, !tbaa !18
  tail call void @HAL_RNG_ReadyDataCallback(ptr noundef nonnull %0, i32 noundef %21)
  br label %27

27:                                               ; preds = %17, %25, %12
  ret void
}

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

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_RNG_ReadyDataCallback(ptr 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" }

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


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