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

; 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.__DMA2D_HandleTypeDef = type { ptr, %struct.DMA2D_InitTypeDef, ptr, ptr, [2 x %struct.DMA2D_LayerCfgTypeDef], i32, i32, i32 }
%struct.DMA2D_InitTypeDef = type { i32, i32, i32, i32, i32 }
%struct.DMA2D_LayerCfgTypeDef = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.DMA2D_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [236 x i32], [256 x i32], [256 x i32] }

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_DMA2D_CLUTLoading_Resume(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %7, label %30

7:                                                ; preds = %2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.__DMA2D_HandleTypeDef, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %struct.DMA2D_TypeDef, ptr %10, i32 0, i32 0
  %12 = load volatile i32, ptr %11, align 4, !tbaa !14
  %13 = zext i32 %12 to i64
  %14 = and i64 %13, 2
  %15 = icmp eq i64 %14, 2
  br i1 %15, label %16, label %29

16:                                               ; preds = %7
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.__DMA2D_HandleTypeDef, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct.DMA2D_TypeDef, ptr %19, i32 0, i32 9
  %21 = load volatile i32, ptr %20, align 4, !tbaa !16
  %22 = zext i32 %21 to i64
  %23 = and i64 %22, 32
  %24 = icmp eq i64 %23, 32
  br i1 %24, label %25, label %28

25:                                               ; preds = %16
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.__DMA2D_HandleTypeDef, ptr %26, i32 0, i32 6
  store volatile i32 2, ptr %27, align 4, !tbaa !17
  br label %28

28:                                               ; preds = %25, %16
  br label %29

29:                                               ; preds = %28, %7
  br label %53

30:                                               ; preds = %2
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.__DMA2D_HandleTypeDef, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = getelementptr inbounds %struct.DMA2D_TypeDef, ptr %33, i32 0, i32 0
  %35 = load volatile i32, ptr %34, align 4, !tbaa !14
  %36 = zext i32 %35 to i64
  %37 = and i64 %36, 2
  %38 = icmp eq i64 %37, 2
  br i1 %38, label %39, label %52

39:                                               ; preds = %30
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.__DMA2D_HandleTypeDef, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = getelementptr inbounds %struct.DMA2D_TypeDef, ptr %42, i32 0, i32 7
  %44 = load volatile i32, ptr %43, align 4, !tbaa !18
  %45 = zext i32 %44 to i64
  %46 = and i64 %45, 32
  %47 = icmp eq i64 %46, 32
  br i1 %47, label %48, label %51

48:                                               ; preds = %39
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.__DMA2D_HandleTypeDef, ptr %49, i32 0, i32 6
  store volatile i32 2, ptr %50, align 4, !tbaa !17
  br label %51

51:                                               ; preds = %48, %39
  br label %52

52:                                               ; preds = %51, %30
  br label %53

53:                                               ; preds = %52, %29
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.__DMA2D_HandleTypeDef, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !11
  %57 = getelementptr inbounds %struct.DMA2D_TypeDef, ptr %56, i32 0, i32 0
  %58 = load volatile i32, ptr %57, align 4, !tbaa !14
  %59 = zext i32 %58 to i64
  %60 = and i64 %59, -3
  %61 = trunc i64 %60 to i32
  store volatile i32 %61, ptr %57, align 4, !tbaa !14
  ret i32 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, !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 = !{!"__DMA2D_HandleTypeDef", !6, i64 0, !13, i64 8, !6, i64 32, !6, i64 40, !7, i64 48, !10, i64 104, !10, i64 108, !10, i64 112}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !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, !7, i64 80, !7, i64 1024, !7, i64 2048}
!16 = !{!15, !10, i64 36}
!17 = !{!12, !10, i64 108}
!18 = !{!15, !10, i64 28}


; 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 noundef i32 @HAL_DMA2D_CLUTLoading_Resume(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq i32 %1, 0
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = load volatile i32, ptr %4, align 4, !tbaa !12
  %6 = and i32 %5, 2
  %.not8 = icmp eq i32 %6, 0
  br i1 %3, label %7, label %12

7:                                                ; preds = %2
  br i1 %.not8, label %18, label %8

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %4, i64 36
  %10 = load volatile i32, ptr %9, align 4, !tbaa !14
  %11 = and i32 %10, 32
  %.not9 = icmp eq i32 %11, 0
  br i1 %.not9, label %18, label %.sink.split

12:                                               ; preds = %2
  br i1 %.not8, label %18, label %13

13:                                               ; preds = %12
  %14 = getelementptr inbounds i8, ptr %4, i64 28
  %15 = load volatile i32, ptr %14, align 4, !tbaa !15
  %16 = and i32 %15, 32
  %.not7 = icmp eq i32 %16, 0
  br i1 %.not7, label %18, label %.sink.split

.sink.split:                                      ; preds = %13, %8
  %17 = getelementptr inbounds i8, ptr %0, i64 108
  store volatile i32 2, ptr %17, align 4, !tbaa !16
  br label %18

18:                                               ; preds = %.sink.split, %12, %13, %7, %8
  %19 = load volatile i32, ptr %4, align 4, !tbaa !12
  %20 = and i32 %19, -3
  store volatile i32 %20, ptr %4, align 4, !tbaa !12
  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, !7, i64 0}
!6 = !{!"__DMA2D_HandleTypeDef", !7, i64 0, !10, i64 8, !7, i64 32, !7, i64 40, !8, i64 48, !11, i64 104, !11, i64 108, !11, i64 112}
!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 = !{!"int", !8, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"", !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, !8, i64 80, !8, i64 1024, !8, i64 2048}
!14 = !{!13, !11, i64 36}
!15 = !{!13, !11, i64 28}
!16 = !{!6, !11, i64 108}


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