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

; 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_compress_struct = type { ptr, ptr, ptr, ptr, i8, i32, ptr, i32, i32, i32, i32, double, i32, i32, i32, ptr, [4 x ptr], [4 x ptr], [4 x ptr], [16 x i8], [16 x i8], [16 x i8], i32, ptr, i8, i8, i8, i8, i32, i32, i32, i32, i8, i8, i8, i8, i16, i16, i8, i32, i8, i32, i32, i32, i32, [4 x ptr], i32, i32, i32, [10 x i32], i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%struct.JQUANT_TBL = type { [64 x i16], i8 }
%struct.JHUFF_TBL = type { [17 x i8], [256 x i8], i8 }

; 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 @jpeg_suppress_tables(ptr noundef %0, i8 noundef zeroext %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i32 0, ptr %5, align 4, !tbaa !10
  br label %8

8:                                                ; preds = %24, %2
  %9 = load i32, ptr %5, align 4, !tbaa !10
  %10 = icmp slt i32 %9, 4
  br i1 %10, label %11, label %27

11:                                               ; preds = %8
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %12, i32 0, i32 16
  %14 = load i32, ptr %5, align 4, !tbaa !10
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [4 x ptr], ptr %13, i64 0, i64 %15
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %17, ptr %6, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %23

19:                                               ; preds = %11
  %20 = load i8, ptr %4, align 1, !tbaa !9
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.JQUANT_TBL, ptr %21, i32 0, i32 1
  store i8 %20, ptr %22, align 2, !tbaa !12
  br label %23

23:                                               ; preds = %19, %11
  br label %24

24:                                               ; preds = %23
  %25 = load i32, ptr %5, align 4, !tbaa !10
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %5, align 4, !tbaa !10
  br label %8, !llvm.loop !14

27:                                               ; preds = %8
  store i32 0, ptr %5, align 4, !tbaa !10
  br label %28

28:                                               ; preds = %56, %27
  %29 = load i32, ptr %5, align 4, !tbaa !10
  %30 = icmp slt i32 %29, 4
  br i1 %30, label %31, label %59

31:                                               ; preds = %28
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %32, i32 0, i32 17
  %34 = load i32, ptr %5, align 4, !tbaa !10
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [4 x ptr], ptr %33, i64 0, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  store ptr %37, ptr %7, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %43

39:                                               ; preds = %31
  %40 = load i8, ptr %4, align 1, !tbaa !9
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.JHUFF_TBL, ptr %41, i32 0, i32 2
  store i8 %40, ptr %42, align 1, !tbaa !16
  br label %43

43:                                               ; preds = %39, %31
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %44, i32 0, i32 18
  %46 = load i32, ptr %5, align 4, !tbaa !10
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [4 x ptr], ptr %45, i64 0, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  store ptr %49, ptr %7, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %55

51:                                               ; preds = %43
  %52 = load i8, ptr %4, align 1, !tbaa !9
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.JHUFF_TBL, ptr %53, i32 0, i32 2
  store i8 %52, ptr %54, align 1, !tbaa !16
  br label %55

55:                                               ; preds = %51, %43
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %5, align 4, !tbaa !10
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %5, align 4, !tbaa !10
  br label %28, !llvm.loop !18

59:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !7, i64 128}
!13 = !{!"", !7, i64 0, !7, i64 128}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !7, i64 273}
!17 = !{!"", !7, i64 0, !7, i64 17, !7, i64 273}
!18 = distinct !{!18, !15}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @jpeg_suppress_tables(ptr nocapture noundef readonly %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 96
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not19 = icmp eq ptr %4, null
  br i1 %.not19, label %7, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %4, i64 128
  store i8 %1, ptr %6, align 2, !tbaa !9
  br label %7

7:                                                ; preds = %2, %5
  %8 = getelementptr inbounds i8, ptr %0, i64 104
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %.not19.1 = icmp eq ptr %9, null
  br i1 %.not19.1, label %12, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %9, i64 128
  store i8 %1, ptr %11, align 2, !tbaa !9
  br label %12

12:                                               ; preds = %10, %7
  %13 = getelementptr inbounds i8, ptr %0, i64 112
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %.not19.2 = icmp eq ptr %14, null
  br i1 %.not19.2, label %17, label %15

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %14, i64 128
  store i8 %1, ptr %16, align 2, !tbaa !9
  br label %17

17:                                               ; preds = %15, %12
  %18 = getelementptr inbounds i8, ptr %0, i64 120
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %.not19.3 = icmp eq ptr %19, null
  br i1 %.not19.3, label %.preheader, label %20

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %19, i64 128
  store i8 %1, ptr %21, align 2, !tbaa !9
  br label %.preheader

.preheader:                                       ; preds = %20, %17
  %22 = getelementptr inbounds i8, ptr %0, i64 128
  %23 = getelementptr inbounds i8, ptr %0, i64 160
  %24 = load ptr, ptr %22, align 8, !tbaa !5
  %.not = icmp eq ptr %24, null
  br i1 %.not, label %27, label %25

25:                                               ; preds = %.preheader
  %26 = getelementptr inbounds i8, ptr %24, i64 273
  store i8 %1, ptr %26, align 1, !tbaa !11
  br label %27

27:                                               ; preds = %25, %.preheader
  %28 = load ptr, ptr %23, align 8, !tbaa !5
  %.not18 = icmp eq ptr %28, null
  br i1 %.not18, label %31, label %29

29:                                               ; preds = %27
  %30 = getelementptr inbounds i8, ptr %28, i64 273
  store i8 %1, ptr %30, align 1, !tbaa !11
  br label %31

31:                                               ; preds = %27, %29
  %32 = getelementptr inbounds i8, ptr %0, i64 136
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %.not.1 = icmp eq ptr %33, null
  br i1 %.not.1, label %36, label %34

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %33, i64 273
  store i8 %1, ptr %35, align 1, !tbaa !11
  br label %36

36:                                               ; preds = %34, %31
  %37 = getelementptr inbounds i8, ptr %0, i64 168
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %.not18.1 = icmp eq ptr %38, null
  br i1 %.not18.1, label %41, label %39

39:                                               ; preds = %36
  %40 = getelementptr inbounds i8, ptr %38, i64 273
  store i8 %1, ptr %40, align 1, !tbaa !11
  br label %41

41:                                               ; preds = %39, %36
  %42 = getelementptr inbounds i8, ptr %0, i64 144
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %.not.2 = icmp eq ptr %43, null
  br i1 %.not.2, label %46, label %44

44:                                               ; preds = %41
  %45 = getelementptr inbounds i8, ptr %43, i64 273
  store i8 %1, ptr %45, align 1, !tbaa !11
  br label %46

46:                                               ; preds = %44, %41
  %47 = getelementptr inbounds i8, ptr %0, i64 176
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %.not18.2 = icmp eq ptr %48, null
  br i1 %.not18.2, label %51, label %49

49:                                               ; preds = %46
  %50 = getelementptr inbounds i8, ptr %48, i64 273
  store i8 %1, ptr %50, align 1, !tbaa !11
  br label %51

51:                                               ; preds = %49, %46
  %52 = getelementptr inbounds i8, ptr %0, i64 152
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %.not.3 = icmp eq ptr %53, null
  br i1 %.not.3, label %56, label %54

54:                                               ; preds = %51
  %55 = getelementptr inbounds i8, ptr %53, i64 273
  store i8 %1, ptr %55, align 1, !tbaa !11
  br label %56

56:                                               ; preds = %54, %51
  %57 = getelementptr inbounds i8, ptr %0, i64 184
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %.not18.3 = icmp eq ptr %58, null
  br i1 %.not18.3, label %61, label %59

59:                                               ; preds = %56
  %60 = getelementptr inbounds i8, ptr %58, i64 273
  store i8 %1, ptr %60, align 1, !tbaa !11
  br label %61

61:                                               ; preds = %59, %56
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) 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, !7, i64 128}
!10 = !{!"", !7, i64 0, !7, i64 128}
!11 = !{!12, !7, i64 273}
!12 = !{!"", !7, i64 0, !7, i64 17, !7, i64 273}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass