; 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_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_post_controller = type { %struct.jpeg_d_post_controller, ptr, ptr, i32, i32, i32 }
%struct.jpeg_d_post_controller = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @jinit_d_post_controller(ptr noundef %0, i8 noundef zeroext %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = 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 8, ptr %5) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %6, i32 0, i32 1
  %8 = load ptr, ptr %7, align 8, !tbaa !10
  %9 = getelementptr inbounds %struct.jpeg_memory_mgr, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call ptr %10(ptr noundef %11, i32 noundef 1, i64 noundef 48)
  store ptr %12, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %14, i32 0, i32 80
  store ptr %13, ptr %15, align 8, !tbaa !18
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.my_post_controller, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.jpeg_d_post_controller, ptr %17, i32 0, i32 0
  store ptr @start_pass_dpost, ptr %18, align 8, !tbaa !19
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.my_post_controller, ptr %19, i32 0, i32 1
  store ptr null, ptr %20, align 8, !tbaa !22
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.my_post_controller, ptr %21, i32 0, i32 2
  store ptr null, ptr %22, align 8, !tbaa !23
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %23, i32 0, i32 20
  %25 = load i8, ptr %24, align 2, !tbaa !24
  %26 = icmp ne i8 %25, 0
  br i1 %26, label %27, label %86

27:                                               ; preds = %2
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %28, i32 0, i32 62
  %30 = load i32, ptr %29, align 4, !tbaa !25
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.my_post_controller, ptr %31, i32 0, i32 3
  store i32 %30, ptr %32, align 8, !tbaa !26
  %33 = load i8, ptr %4, align 1, !tbaa !9
  %34 = icmp ne i8 %33, 0
  br i1 %34, label %35, label %65

35:                                               ; preds = %27
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !10
  %39 = getelementptr inbounds %struct.jpeg_memory_mgr, ptr %38, i32 0, i32 4
  %40 = load ptr, ptr %39, align 8, !tbaa !27
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %42, i32 0, i32 27
  %44 = load i32, ptr %43, align 4, !tbaa !28
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %45, i32 0, i32 29
  %47 = load i32, ptr %46, align 4, !tbaa !29
  %48 = mul i32 %44, %47
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %49, i32 0, i32 28
  %51 = load i32, ptr %50, align 8, !tbaa !30
  %52 = zext i32 %51 to i64
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.my_post_controller, ptr %53, i32 0, i32 3
  %55 = load i32, ptr %54, align 8, !tbaa !26
  %56 = zext i32 %55 to i64
  %57 = call i64 @jround_up(i64 noundef %52, i64 noundef %56)
  %58 = trunc i64 %57 to i32
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.my_post_controller, ptr %59, i32 0, i32 3
  %61 = load i32, ptr %60, align 8, !tbaa !26
  %62 = call ptr %40(ptr noundef %41, i32 noundef 1, i8 noundef zeroext 0, i32 noundef %48, i32 noundef %58, i32 noundef %61)
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.my_post_controller, ptr %63, i32 0, i32 1
  store ptr %62, ptr %64, align 8, !tbaa !22
  br label %85

65:                                               ; preds = %27
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %66, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !10
  %69 = getelementptr inbounds %struct.jpeg_memory_mgr, ptr %68, i32 0, i32 2
  %70 = load ptr, ptr %69, align 8, !tbaa !31
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %72, i32 0, i32 27
  %74 = load i32, ptr %73, align 4, !tbaa !28
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %75, i32 0, i32 29
  %77 = load i32, ptr %76, align 4, !tbaa !29
  %78 = mul i32 %74, %77
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.my_post_controller, ptr %79, i32 0, i32 3
  %81 = load i32, ptr %80, align 8, !tbaa !26
  %82 = call ptr %70(ptr noundef %71, i32 noundef 1, i32 noundef %78, i32 noundef %81)
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.my_post_controller, ptr %83, i32 0, i32 2
  store ptr %82, ptr %84, align 8, !tbaa !23
  br label %85

85:                                               ; preds = %65, %35
  br label %86

86:                                               ; preds = %85, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  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_dpost(ptr noundef, i32 noundef) #0

declare i64 @jround_up(i64 noundef, i64 noundef) #2

; 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 = { "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 #3 = { 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_decompress_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, !12, i64 64, !12, i64 68, !12, i64 72, !13, i64 80, !7, i64 88, !7, i64 89, !12, i64 92, !7, i64 96, !7, i64 97, !7, i64 98, !12, i64 100, !7, i64 104, !12, i64 108, !7, i64 112, !7, i64 113, !7, i64 114, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132, !12, i64 136, !6, i64 144, !12, i64 152, !12, i64 156, !12, i64 160, !12, i64 164, !12, i64 168, !6, i64 176, !7, i64 184, !7, i64 216, !7, i64 248, !12, i64 280, !6, i64 288, !7, i64 296, !7, i64 297, !7, i64 298, !7, i64 314, !7, i64 330, !12, i64 348, !7, i64 352, !7, i64 353, !7, i64 354, !7, i64 355, !14, i64 356, !14, i64 358, !7, i64 360, !7, i64 361, !7, i64 362, !6, i64 368, !12, i64 376, !12, i64 380, !12, i64 384, !12, i64 388, !6, i64 392, !12, i64 400, !7, i64 408, !12, i64 440, !12, i64 444, !12, i64 448, !7, i64 452, !12, i64 492, !12, i64 496, !12, i64 500, !12, i64 504, !12, 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}
!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 536}
!19 = !{!20, !6, i64 0}
!20 = !{!"", !21, i64 0, !6, i64 16, !6, i64 24, !12, i64 32, !12, i64 36, !12, i64 40}
!21 = !{!"jpeg_d_post_controller", !6, i64 0, !6, i64 8}
!22 = !{!20, !6, i64 16}
!23 = !{!20, !6, i64 24}
!24 = !{!11, !7, i64 98}
!25 = !{!11, !12, i64 380}
!26 = !{!20, !12, i64 32}
!27 = !{!16, !6, i64 32}
!28 = !{!11, !12, i64 116}
!29 = !{!11, !12, i64 124}
!30 = !{!11, !12, i64 120}
!31 = !{!16, !6, i64 16}


; 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_d_post_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 48) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 536
  store ptr %6, ptr %7, align 8, !tbaa !16
  store ptr @start_pass_dpost, ptr %6, align 8, !tbaa !17
  %8 = getelementptr inbounds i8, ptr %6, i64 16
  %9 = getelementptr inbounds i8, ptr %6, i64 24
  %10 = getelementptr inbounds i8, ptr %0, i64 98
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %8, i8 0, i64 16, i1 false)
  %11 = load i8, ptr %10, align 2, !tbaa !20
  %.not = icmp eq i8 %11, 0
  br i1 %.not, label %37, label %12

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 380
  %14 = load i32, ptr %13, align 4, !tbaa !21
  %15 = getelementptr inbounds i8, ptr %6, i64 32
  store i32 %14, ptr %15, align 8, !tbaa !22
  %.not24 = icmp eq i8 %1, 0
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 116
  %18 = load i32, ptr %17, align 4, !tbaa !23
  %19 = getelementptr inbounds i8, ptr %0, i64 124
  %20 = load i32, ptr %19, align 4, !tbaa !24
  %21 = mul i32 %20, %18
  br i1 %.not24, label %33, label %22

22:                                               ; preds = %12
  %23 = getelementptr inbounds i8, ptr %16, i64 32
  %24 = load ptr, ptr %23, align 8, !tbaa !25
  %25 = getelementptr inbounds i8, ptr %0, i64 120
  %26 = load i32, ptr %25, align 8, !tbaa !26
  %27 = zext i32 %26 to i64
  %28 = zext i32 %14 to i64
  %29 = tail call i64 @jround_up(i64 noundef %27, i64 noundef %28) #3
  %30 = trunc i64 %29 to i32
  %31 = load i32, ptr %15, align 8, !tbaa !22
  %32 = tail call ptr %24(ptr noundef nonnull %0, i32 noundef 1, i8 noundef zeroext 0, i32 noundef %21, i32 noundef %30, i32 noundef %31) #3
  store ptr %32, ptr %8, align 8, !tbaa !27
  br label %37

33:                                               ; preds = %12
  %34 = getelementptr inbounds i8, ptr %16, i64 16
  %35 = load ptr, ptr %34, align 8, !tbaa !28
  %36 = tail call ptr %35(ptr noundef nonnull %0, i32 noundef 1, i32 noundef %21, i32 noundef %14) #3
  store ptr %36, ptr %9, align 8, !tbaa !29
  br label %37

37:                                               ; preds = %22, %33, %2
  ret void
}

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

declare i64 @jround_up(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 536}
!17 = !{!18, !7, i64 0}
!18 = !{!"", !19, i64 0, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40}
!19 = !{!"jpeg_d_post_controller", !7, i64 0, !7, i64 8}
!20 = !{!6, !8, i64 98}
!21 = !{!6, !10, i64 380}
!22 = !{!18, !10, i64 32}
!23 = !{!6, !10, i64 116}
!24 = !{!6, !10, i64 124}
!25 = !{!14, !7, i64 32}
!26 = !{!6, !10, i64 120}
!27 = !{!18, !7, i64 16}
!28 = !{!14, !7, i64 16}
!29 = !{!18, !7, i64 24}


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