; 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.JPEG_HandleTypeDef = type { ptr, %struct.JPEG_ConfTypeDef, ptr, ptr, i32, i32, i32, i32, ptr, ptr, i8, ptr, ptr, ptr, ptr, i32, i32, i32, i32 }
%struct.JPEG_ConfTypeDef = type { i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare hidden i32 @JPEG_Process(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @HAL_JPEG_IRQHandler(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %3, i32 0, i32 16
  %5 = load volatile i32, ptr %4, align 4, !tbaa !9
  switch i32 %5, label %26 [
    i32 3, label %6
    i32 4, label %6
  ]

6:                                                ; preds = %1, %1
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %7, i32 0, i32 18
  %9 = load volatile i32, ptr %8, align 4, !tbaa !13
  %10 = and i32 %9, 12
  %11 = icmp eq i32 %10, 8
  br i1 %11, label %12, label %15

12:                                               ; preds = %6
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call i32 @JPEG_Process(ptr noundef %13)
  br label %25

15:                                               ; preds = %6
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %16, i32 0, i32 18
  %18 = load volatile i32, ptr %17, align 4, !tbaa !13
  %19 = and i32 %18, 12
  %20 = icmp eq i32 %19, 12
  br i1 %20, label %21, label %23

21:                                               ; preds = %15
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  call void @JPEG_DMA_ContinueProcess(ptr noundef %22)
  br label %24

23:                                               ; preds = %15
  br label %24

24:                                               ; preds = %23, %21
  br label %25

25:                                               ; preds = %24, %12
  br label %27

26:                                               ; preds = %1
  br label %27

27:                                               ; preds = %26, %25
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @JPEG_DMA_ContinueProcess(ptr noundef) #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, !12, i64 124}
!10 = !{!"", !6, i64 0, !11, i64 8, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !6, i64 64, !6, i64 72, !7, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 132}


; 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
declare hidden i32 @JPEG_Process(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @HAL_JPEG_IRQHandler(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 124
  %3 = load volatile i32, ptr %2, align 4, !tbaa !5
  %.off = add i32 %3, -3
  %switch = icmp ult i32 %.off, 2
  br i1 %switch, label %4, label %16

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 132
  %6 = load volatile i32, ptr %5, align 4, !tbaa !12
  %7 = and i32 %6, 12
  %8 = icmp eq i32 %7, 8
  br i1 %8, label %9, label %11

9:                                                ; preds = %4
  %10 = tail call i32 @JPEG_Process(ptr noundef nonnull %0)
  br label %16

11:                                               ; preds = %4
  %12 = load volatile i32, ptr %5, align 4, !tbaa !12
  %13 = and i32 %12, 12
  %14 = icmp eq i32 %13, 12
  br i1 %14, label %15, label %16

15:                                               ; preds = %11
  tail call void @JPEG_DMA_ContinueProcess(ptr noundef nonnull %0)
  br label %16

16:                                               ; preds = %1, %9, %11, %15
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @JPEG_DMA_ContinueProcess(ptr 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, !11, i64 124}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 32, !7, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !7, i64 64, !7, i64 72, !8, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132}
!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 = !{!6, !11, i64 132}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass