; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/modules/juce_graphics/image_formats/jpglib (jquant1)

; 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_decompress_struct = type { ptr, ptr, ptr, ptr, i8, i32, ptr, i32, i32, i32, i32, i32, i32, i32, double, i8, i8, i32, i8, i8, i8, i32, i8, i32, i8, i8, i8, i32, i32, i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32, ptr, [4 x ptr], [4 x ptr], [4 x ptr], i32, ptr, i8, i8, [16 x i8], [16 x i8], [16 x i8], i32, i8, i8, i8, i8, i16, i16, i8, i8, i8, ptr, i32, i32, i32, i32, ptr, i32, [4 x ptr], i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.jpeg_memory_mgr = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64 }
%struct.my_cquantizer = type { %struct.jpeg_color_quantizer, ptr, i32, ptr, i8, [4 x i32], i32, [4 x ptr], [4 x ptr], i8 }
%struct.jpeg_color_quantizer = type { ptr, ptr, ptr, ptr }
%struct.jpeg_error_mgr = type { ptr, ptr, ptr, ptr, ptr, i32, %union.anon, i32, i64, ptr, i32, ptr, i32, i32 }
%union.anon = type { [8 x i32], [48 x i8] }

; Function Attrs: nounwind uwtable
define dso_local void @jinit_1pass_quantizer(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %4, i32 0, i32 1
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds %struct.jpeg_memory_mgr, ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call ptr %8(ptr noundef %9, i32 noundef 1, i64 noundef 152)
  store ptr %10, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %12, i32 0, i32 87
  store ptr %11, ptr %13, align 8, !tbaa !17
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.my_cquantizer, ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds %struct.jpeg_color_quantizer, ptr %15, i32 0, i32 0
  store ptr @start_pass_1_quant, ptr %16, align 8, !tbaa !18
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.my_cquantizer, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.jpeg_color_quantizer, ptr %18, i32 0, i32 2
  store ptr @finish_pass_1_quant, ptr %19, align 8, !tbaa !21
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.my_cquantizer, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %struct.jpeg_color_quantizer, ptr %21, i32 0, i32 3
  store ptr @new_color_map_1_quant, ptr %22, align 8, !tbaa !22
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.my_cquantizer, ptr %23, i32 0, i32 8
  %25 = getelementptr inbounds [4 x ptr], ptr %24, i64 0, i64 0
  store ptr null, ptr %25, align 8, !tbaa !5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.my_cquantizer, ptr %26, i32 0, i32 7
  %28 = getelementptr inbounds [4 x ptr], ptr %27, i64 0, i64 0
  store ptr null, ptr %28, align 8, !tbaa !5
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %29, i32 0, i32 29
  %31 = load i32, ptr %30, align 4, !tbaa !23
  %32 = icmp sgt i32 %31, 4
  br i1 %32, label %33, label %49

33:                                               ; preds = %1
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !24
  %37 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %36, i32 0, i32 5
  store i32 55, ptr %37, align 8, !tbaa !25
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !24
  %41 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %40, i32 0, i32 6
  %42 = getelementptr inbounds [8 x i32], ptr %41, i64 0, i64 0
  store i32 4, ptr %42, align 4, !tbaa !27
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !24
  %46 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !28
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  call void %47(ptr noundef %48)
  br label %49

49:                                               ; preds = %33, %1
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %50, i32 0, i32 23
  %52 = load i32, ptr %51, align 4, !tbaa !29
  %53 = icmp sgt i32 %52, 256
  br i1 %53, label %54, label %70

54:                                               ; preds = %49
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !24
  %58 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %57, i32 0, i32 5
  store i32 57, ptr %58, align 8, !tbaa !25
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !24
  %62 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %61, i32 0, i32 6
  %63 = getelementptr inbounds [8 x i32], ptr %62, i64 0, i64 0
  store i32 256, ptr %63, align 4, !tbaa !27
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !24
  %67 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !28
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  call void %68(ptr noundef %69)
  br label %70

70:                                               ; preds = %54, %49
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  call void @create_colormap(ptr noundef %71)
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  call void @create_colorindex(ptr noundef %72)
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %73, i32 0, i32 21
  %75 = load i32, ptr %74, align 4, !tbaa !30
  %76 = icmp eq i32 %75, 2
  br i1 %76, label %77, label %79

77:                                               ; preds = %70
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  call void @alloc_fs_workspace(ptr noundef %78)
  br label %79

79:                                               ; preds = %77, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden void @start_pass_1_quant(ptr noundef, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden void @finish_pass_1_quant(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @new_color_map_1_quant(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @create_colormap(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @create_colorindex(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @alloc_fs_workspace(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 8}
!10 = !{!"jpeg_decompress_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !11, i64 36, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !12, i64 80, !7, i64 88, !7, i64 89, !11, i64 92, !7, i64 96, !7, i64 97, !7, i64 98, !11, i64 100, !7, i64 104, !11, i64 108, !7, i64 112, !7, i64 113, !7, i64 114, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !6, i64 144, !11, i64 152, !11, i64 156, !11, i64 160, !11, i64 164, !11, i64 168, !6, i64 176, !7, i64 184, !7, i64 216, !7, i64 248, !11, i64 280, !6, i64 288, !7, i64 296, !7, i64 297, !7, i64 298, !7, i64 314, !7, i64 330, !11, i64 348, !7, i64 352, !7, i64 353, !7, i64 354, !7, i64 355, !13, i64 356, !13, i64 358, !7, i64 360, !7, i64 361, !7, i64 362, !6, i64 368, !11, i64 376, !11, i64 380, !11, i64 384, !11, i64 388, !6, i64 392, !11, i64 400, !7, i64 408, !11, i64 440, !11, i64 444, !11, i64 448, !7, i64 452, !11, i64 492, !11, i64 496, !11, i64 500, !11, i64 504, !11, i64 508, !6, i64 512, !6, i64 520, !6, i64 528, !6, i64 536, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !6, i64 576, !6, i64 584, !6, i64 592}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"jpeg_memory_mgr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !16, i64 88, !16, i64 96}
!16 = !{!"long", !7, i64 0}
!17 = !{!10, !6, i64 592}
!18 = !{!19, !6, i64 0}
!19 = !{!"", !20, i64 0, !6, i64 32, !11, i64 40, !6, i64 48, !7, i64 56, !7, i64 60, !11, i64 76, !7, i64 80, !7, i64 112, !7, i64 144}
!20 = !{!"jpeg_color_quantizer", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!21 = !{!19, !6, i64 16}
!22 = !{!19, !6, i64 24}
!23 = !{!10, !11, i64 124}
!24 = !{!10, !6, i64 0}
!25 = !{!26, !11, i64 40}
!26 = !{!"jpeg_error_mgr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !7, i64 44, !11, i64 124, !16, i64 128, !6, i64 136, !11, i64 144, !6, i64 152, !11, i64 160, !11, i64 164}
!27 = !{!7, !7, i64 0}
!28 = !{!26, !6, i64 0}
!29 = !{!10, !11, i64 108}
!30 = !{!10, !11, i64 100}


; 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 @jinit_1pass_quantizer(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !13
  %5 = tail call ptr %4(ptr noundef %0, i32 noundef 1, i64 noundef 152) #1
  %6 = getelementptr inbounds i8, ptr %0, i64 592
  store ptr %5, ptr %6, align 8, !tbaa !16
  store ptr @start_pass_1_quant, ptr %5, align 8, !tbaa !17
  %7 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr @finish_pass_1_quant, ptr %7, align 8, !tbaa !20
  %8 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr @new_color_map_1_quant, ptr %8, align 8, !tbaa !21
  %9 = getelementptr inbounds i8, ptr %5, i64 112
  store ptr null, ptr %9, align 8, !tbaa !22
  %10 = getelementptr inbounds i8, ptr %5, i64 80
  store ptr null, ptr %10, align 8, !tbaa !22
  %11 = getelementptr inbounds i8, ptr %0, i64 124
  %12 = load i32, ptr %11, align 4, !tbaa !23
  %13 = icmp sgt i32 %12, 4
  br i1 %13, label %14, label %20

14:                                               ; preds = %1
  %15 = load ptr, ptr %0, align 8, !tbaa !24
  %16 = getelementptr inbounds i8, ptr %15, i64 40
  store i32 55, ptr %16, align 8, !tbaa !25
  %17 = getelementptr inbounds i8, ptr %15, i64 44
  store i32 4, ptr %17, align 4, !tbaa !27
  %18 = load ptr, ptr %0, align 8, !tbaa !24
  %19 = load ptr, ptr %18, align 8, !tbaa !28
  tail call void %19(ptr noundef nonnull %0) #1
  br label %20

20:                                               ; preds = %14, %1
  %21 = getelementptr inbounds i8, ptr %0, i64 108
  %22 = load i32, ptr %21, align 4, !tbaa !29
  %23 = icmp sgt i32 %22, 256
  br i1 %23, label %24, label %30

24:                                               ; preds = %20
  %25 = load ptr, ptr %0, align 8, !tbaa !24
  %26 = getelementptr inbounds i8, ptr %25, i64 40
  store i32 57, ptr %26, align 8, !tbaa !25
  %27 = getelementptr inbounds i8, ptr %25, i64 44
  store i32 256, ptr %27, align 4, !tbaa !27
  %28 = load ptr, ptr %0, align 8, !tbaa !24
  %29 = load ptr, ptr %28, align 8, !tbaa !28
  tail call void %29(ptr noundef nonnull %0) #1
  br label %30

30:                                               ; preds = %24, %20
  tail call void @create_colormap(ptr noundef nonnull %0)
  tail call void @create_colorindex(ptr noundef nonnull %0)
  %31 = getelementptr inbounds i8, ptr %0, i64 100
  %32 = load i32, ptr %31, align 4, !tbaa !30
  %33 = icmp eq i32 %32, 2
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  tail call void @alloc_fs_workspace(ptr noundef nonnull %0)
  br label %35

35:                                               ; preds = %34, %30
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @start_pass_1_quant(ptr noundef, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden void @finish_pass_1_quant(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @new_color_map_1_quant(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare hidden void @alloc_fs_workspace(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" }
attributes #1 = { 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, !7, i64 8}
!6 = !{!"jpeg_decompress_struct", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !8, i64 32, !10, i64 36, !7, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !11, i64 80, !8, i64 88, !8, i64 89, !10, i64 92, !8, i64 96, !8, i64 97, !8, i64 98, !10, i64 100, !8, i64 104, !10, i64 108, !8, i64 112, !8, i64 113, !8, i64 114, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !7, i64 144, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !10, i64 168, !7, i64 176, !8, i64 184, !8, i64 216, !8, i64 248, !10, i64 280, !7, i64 288, !8, i64 296, !8, i64 297, !8, i64 298, !8, i64 314, !8, i64 330, !10, i64 348, !8, i64 352, !8, i64 353, !8, i64 354, !8, i64 355, !12, i64 356, !12, i64 358, !8, i64 360, !8, i64 361, !8, i64 362, !7, i64 368, !10, i64 376, !10, i64 380, !10, i64 384, !10, i64 388, !7, i64 392, !10, i64 400, !8, i64 408, !10, i64 440, !10, i64 444, !10, i64 448, !8, i64 452, !10, i64 492, !10, i64 496, !10, i64 500, !10, i64 504, !10, i64 508, !7, i64 512, !7, i64 520, !7, i64 528, !7, i64 536, !7, i64 544, !7, i64 552, !7, i64 560, !7, i64 568, !7, i64 576, !7, i64 584, !7, i64 592}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"jpeg_memory_mgr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !15, i64 88, !15, i64 96}
!15 = !{!"long", !8, i64 0}
!16 = !{!6, !7, i64 592}
!17 = !{!18, !7, i64 0}
!18 = !{!"", !19, i64 0, !7, i64 32, !10, i64 40, !7, i64 48, !8, i64 56, !8, i64 60, !10, i64 76, !8, i64 80, !8, i64 112, !8, i64 144}
!19 = !{!"jpeg_color_quantizer", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!20 = !{!18, !7, i64 16}
!21 = !{!18, !7, i64 24}
!22 = !{!7, !7, i64 0}
!23 = !{!6, !10, i64 124}
!24 = !{!6, !7, i64 0}
!25 = !{!26, !10, i64 40}
!26 = !{!"jpeg_error_mgr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !8, i64 44, !10, i64 124, !15, i64 128, !7, i64 136, !10, i64 144, !7, i64 152, !10, i64 160, !10, i64 164}
!27 = !{!8, !8, i64 0}
!28 = !{!26, !7, i64 0}
!29 = !{!6, !10, i64 108}
!30 = !{!6, !10, i64 100}


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