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

; 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
define dso_local i32 @HAL_JPEG_SetUserQuantTables(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %5
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %13, i32 0, i32 15
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %18

17:                                               ; preds = %12
  store i32 2, ptr %6, align 4
  br label %57

18:                                               ; preds = %12
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %19, i32 0, i32 15
  store i32 1, ptr %20, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %18
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %23, i32 0, i32 16
  %25 = load volatile i32, ptr %24, align 4, !tbaa !13
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %52

27:                                               ; preds = %22
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %28, i32 0, i32 16
  store volatile i32 2, ptr %29, align 4, !tbaa !13
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %30, i32 0, i32 18
  %32 = load volatile i32, ptr %31, align 4, !tbaa !14
  %33 = or i32 %32, 16384
  store volatile i32 %33, ptr %31, align 4, !tbaa !14
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %35, i32 0, i32 11
  store ptr %34, ptr %36, align 8, !tbaa !15
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %38, i32 0, i32 12
  store ptr %37, ptr %39, align 8, !tbaa !16
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %41, i32 0, i32 13
  store ptr %40, ptr %42, align 8, !tbaa !17
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %44, i32 0, i32 14
  store ptr %43, ptr %45, align 8, !tbaa !18
  br label %46

46:                                               ; preds = %27
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %47, i32 0, i32 15
  store i32 0, ptr %48, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %46
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %50, i32 0, i32 16
  store volatile i32 1, ptr %51, align 4, !tbaa !13
  store i32 0, ptr %6, align 4
  br label %57

52:                                               ; preds = %22
  br label %53

53:                                               ; preds = %52
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %54, i32 0, i32 15
  store i32 0, ptr %55, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %53
  store i32 2, ptr %6, align 4
  br label %57

57:                                               ; preds = %56, %49, %17
  %58 = load i32, ptr %6, align 4
  ret i32 %58
}

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 120}
!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 124}
!14 = !{!10, !12, i64 132}
!15 = !{!10, !6, i64 88}
!16 = !{!10, !6, i64 96}
!17 = !{!10, !6, i64 104}
!18 = !{!10, !6, i64 112}


; 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 memory(argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local range(i32 0, 3) i32 @HAL_JPEG_SetUserQuantTables(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 120
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %22, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 124
  %11 = load volatile i32, ptr %10, align 4, !tbaa !12
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %13, label %21

13:                                               ; preds = %9
  store volatile i32 2, ptr %10, align 4, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %0, i64 132
  %15 = load volatile i32, ptr %14, align 4, !tbaa !13
  %16 = or i32 %15, 16384
  store volatile i32 %16, ptr %14, align 4, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %1, ptr %17, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %0, i64 96
  store ptr %2, ptr %18, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %0, i64 104
  store ptr %3, ptr %19, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %0, i64 112
  store ptr %4, ptr %20, align 8, !tbaa !17
  store i32 0, ptr %6, align 8, !tbaa !5
  store volatile i32 1, ptr %10, align 4, !tbaa !12
  br label %22

21:                                               ; preds = %9
  store i32 0, ptr %6, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %5, %21, %13
  %.0 = phi i32 [ 0, %13 ], [ 2, %21 ], [ 2, %5 ]
  ret i32 %.0
}

attributes #0 = { nofree norecurse nounwind memory(argmem: readwrite, inaccessiblemem: readwrite) 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 120}
!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 124}
!13 = !{!6, !11, i64 132}
!14 = !{!6, !7, i64 88}
!15 = !{!6, !7, i64 96}
!16 = !{!6, !7, i64 104}
!17 = !{!6, !7, i64 112}


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