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

; 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.jpeg_memory_mgr = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64 }
%struct.my_main_controller = type { %struct.jpeg_c_main_controller, i32, i32, i8, i32, [10 x ptr] }
%struct.jpeg_c_main_controller = type { 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] }
%struct.jpeg_component_info = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, i32, i32, i32, i32, i32, i32, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @jinit_c_main_controller(ptr noundef %0, i8 noundef zeroext %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  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 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %9, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !10
  %12 = getelementptr inbounds %struct.jpeg_memory_mgr, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call ptr %13(ptr noundef %14, i32 noundef 1, i64 noundef 112)
  store ptr %15, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %17, i32 0, i32 55
  store ptr %16, ptr %18, align 8, !tbaa !18
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.my_main_controller, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.jpeg_c_main_controller, ptr %20, i32 0, i32 0
  store ptr @start_pass_main, ptr %21, align 8, !tbaa !19
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %22, i32 0, i32 24
  %24 = load i8, ptr %23, align 8, !tbaa !22
  %25 = icmp ne i8 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %2
  store i32 1, ptr %8, align 4
  br label %79

27:                                               ; preds = %2
  %28 = load i8, ptr %4, align 1, !tbaa !9
  %29 = icmp ne i8 %28, 0
  br i1 %29, label %30, label %41

30:                                               ; preds = %27
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !23
  %34 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %33, i32 0, i32 5
  store i32 4, ptr %34, align 8, !tbaa !24
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !23
  %38 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !26
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  call void %39(ptr noundef %40)
  br label %78

41:                                               ; preds = %27
  store i32 0, ptr %6, align 4, !tbaa !27
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %42, i32 0, i32 15
  %44 = load ptr, ptr %43, align 8, !tbaa !28
  store ptr %44, ptr %7, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %72, %41
  %46 = load i32, ptr %6, align 4, !tbaa !27
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %47, i32 0, i32 13
  %49 = load i32, ptr %48, align 4, !tbaa !29
  %50 = icmp slt i32 %46, %49
  br i1 %50, label %51, label %77

51:                                               ; preds = %45
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !10
  %55 = getelementptr inbounds %struct.jpeg_memory_mgr, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !30
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.jpeg_component_info, ptr %58, i32 0, i32 7
  %60 = load i32, ptr %59, align 4, !tbaa !31
  %61 = mul i32 %60, 8
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.jpeg_component_info, ptr %62, i32 0, i32 3
  %64 = load i32, ptr %63, align 4, !tbaa !33
  %65 = mul nsw i32 %64, 8
  %66 = call ptr %56(ptr noundef %57, i32 noundef 1, i32 noundef %61, i32 noundef %65)
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.my_main_controller, ptr %67, i32 0, i32 5
  %69 = load i32, ptr %6, align 4, !tbaa !27
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [10 x ptr], ptr %68, i64 0, i64 %70
  store ptr %66, ptr %71, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %51
  %73 = load i32, ptr %6, align 4, !tbaa !27
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %6, align 4, !tbaa !27
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.jpeg_component_info, ptr %75, i32 1
  store ptr %76, ptr %7, align 8, !tbaa !5
  br label %45, !llvm.loop !34

77:                                               ; preds = %45
  br label %78

78:                                               ; preds = %77, %30
  store i32 0, ptr %8, align 4
  br label %79

79:                                               ; preds = %78, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  %80 = load i32, ptr %8, align 4
  switch i32 %80, label %82 [
    i32 0, label %81
    i32 1, label %81
  ]

81:                                               ; preds = %79, %79
  ret void

82:                                               ; preds = %79
  unreachable
}

; 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_main(ptr noundef, i32 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 8}
!11 = !{!"jpeg_compress_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !12, i64 36, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !13, i64 64, !12, i64 72, !12, i64 76, !12, i64 80, !6, i64 88, !7, i64 96, !7, i64 128, !7, i64 160, !7, i64 192, !7, i64 208, !7, i64 224, !12, i64 240, !6, i64 248, !7, i64 256, !7, i64 257, !7, i64 258, !7, i64 259, !12, i64 260, !12, i64 264, !12, i64 268, !12, i64 272, !7, i64 276, !7, i64 277, !7, i64 278, !7, i64 279, !14, i64 280, !14, i64 282, !7, i64 284, !12, i64 288, !7, i64 292, !12, i64 296, !12, i64 300, !12, i64 304, !12, i64 308, !7, i64 312, !12, i64 344, !12, i64 348, !12, i64 352, !7, i64 356, !12, i64 396, !12, i64 400, !12, i64 404, !12, i64 408, !6, i64 416, !6, i64 424, !6, i64 432, !6, i64 440, !6, i64 448, !6, i64 456, !6, i64 464, !6, i64 472, !6, i64 480, !6, i64 488, !12, i64 496}
!12 = !{!"int", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"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, !17, i64 88, !17, i64 96}
!17 = !{!"long", !7, i64 0}
!18 = !{!11, !6, i64 424}
!19 = !{!20, !6, i64 0}
!20 = !{!"", !21, i64 0, !12, i64 16, !12, i64 20, !7, i64 24, !12, i64 28, !7, i64 32}
!21 = !{!"jpeg_c_main_controller", !6, i64 0, !6, i64 8}
!22 = !{!11, !7, i64 256}
!23 = !{!11, !6, i64 0}
!24 = !{!25, !12, i64 40}
!25 = !{!"jpeg_error_mgr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !7, i64 44, !12, i64 124, !17, i64 128, !6, i64 136, !12, i64 144, !6, i64 152, !12, i64 160, !12, i64 164}
!26 = !{!25, !6, i64 0}
!27 = !{!12, !12, i64 0}
!28 = !{!11, !6, i64 88}
!29 = !{!11, !12, i64 76}
!30 = !{!16, !6, i64 16}
!31 = !{!32, !12, i64 28}
!32 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !7, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !6, i64 80, !6, i64 88}
!33 = !{!32, !12, i64 12}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}


; 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_c_main_controller(ptr noundef %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !13
  %6 = tail call ptr %5(ptr noundef %0, i32 noundef 1, i64 noundef 112) #1
  %7 = getelementptr inbounds i8, ptr %0, i64 424
  store ptr %6, ptr %7, align 8, !tbaa !16
  store ptr @start_pass_main, ptr %6, align 8, !tbaa !17
  %8 = getelementptr inbounds i8, ptr %0, i64 256
  %9 = load i8, ptr %8, align 8, !tbaa !20
  %.not = icmp eq i8 %9, 0
  br i1 %.not, label %10, label %.loopexit

10:                                               ; preds = %2
  %.not21 = icmp eq i8 %1, 0
  br i1 %.not21, label %15, label %11

11:                                               ; preds = %10
  %12 = load ptr, ptr %0, align 8, !tbaa !21
  %13 = getelementptr inbounds i8, ptr %12, i64 40
  store i32 4, ptr %13, align 8, !tbaa !22
  %14 = load ptr, ptr %12, align 8, !tbaa !24
  tail call void %14(ptr noundef nonnull %0) #1
  br label %.loopexit

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %0, i64 76
  %17 = load i32, ptr %16, align 4, !tbaa !25
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %15
  %19 = getelementptr inbounds i8, ptr %0, i64 88
  %20 = load ptr, ptr %19, align 8, !tbaa !26
  %21 = getelementptr inbounds i8, ptr %6, i64 32
  br label %22

22:                                               ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %.023 = phi ptr [ %20, %.lr.ph ], [ %34, %22 ]
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  %25 = load ptr, ptr %24, align 8, !tbaa !27
  %26 = getelementptr inbounds i8, ptr %.023, i64 28
  %27 = load i32, ptr %26, align 4, !tbaa !28
  %28 = shl i32 %27, 3
  %29 = getelementptr inbounds i8, ptr %.023, i64 12
  %30 = load i32, ptr %29, align 4, !tbaa !30
  %31 = shl nsw i32 %30, 3
  %32 = tail call ptr %25(ptr noundef nonnull %0, i32 noundef 1, i32 noundef %28, i32 noundef %31) #1
  %33 = getelementptr inbounds [10 x ptr], ptr %21, i64 0, i64 %indvars.iv
  store ptr %32, ptr %33, align 8, !tbaa !31
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = getelementptr inbounds i8, ptr %.023, i64 96
  %35 = load i32, ptr %16, align 4, !tbaa !25
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %indvars.iv.next, %36
  br i1 %37, label %22, label %.loopexit, !llvm.loop !32

.loopexit:                                        ; preds = %22, %15, %11, %2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @start_pass_main(ptr noundef, i32 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" }
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_compress_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, !11, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 88, !8, i64 96, !8, i64 128, !8, i64 160, !8, i64 192, !8, i64 208, !8, i64 224, !10, i64 240, !7, i64 248, !8, i64 256, !8, i64 257, !8, i64 258, !8, i64 259, !10, i64 260, !10, i64 264, !10, i64 268, !10, i64 272, !8, i64 276, !8, i64 277, !8, i64 278, !8, i64 279, !12, i64 280, !12, i64 282, !8, i64 284, !10, i64 288, !8, i64 292, !10, i64 296, !10, i64 300, !10, i64 304, !10, i64 308, !8, i64 312, !10, i64 344, !10, i64 348, !10, i64 352, !8, i64 356, !10, i64 396, !10, i64 400, !10, i64 404, !10, i64 408, !7, i64 416, !7, i64 424, !7, i64 432, !7, i64 440, !7, i64 448, !7, i64 456, !7, i64 464, !7, i64 472, !7, i64 480, !7, i64 488, !10, i64 496}
!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 424}
!17 = !{!18, !7, i64 0}
!18 = !{!"", !19, i64 0, !10, i64 16, !10, i64 20, !8, i64 24, !10, i64 28, !8, i64 32}
!19 = !{!"jpeg_c_main_controller", !7, i64 0, !7, i64 8}
!20 = !{!6, !8, i64 256}
!21 = !{!6, !7, i64 0}
!22 = !{!23, !10, i64 40}
!23 = !{!"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}
!24 = !{!23, !7, i64 0}
!25 = !{!6, !10, i64 76}
!26 = !{!6, !7, i64 88}
!27 = !{!14, !7, i64 16}
!28 = !{!29, !10, i64 28}
!29 = !{!"", !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, !8, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !7, i64 80, !7, i64 88}
!30 = !{!29, !10, i64 12}
!31 = !{!7, !7, i64 0}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass