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

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

; 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 i32 @jpeg_read_scanlines(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %10, i32 0, i32 5
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = icmp ne i32 %12, 205
  br i1 %13, label %14, label %33

14:                                               ; preds = %3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %17, i32 0, i32 5
  store i32 20, ptr %18, align 8, !tbaa !16
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %19, i32 0, i32 5
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %24, i32 0, i32 6
  %26 = getelementptr inbounds [8 x i32], ptr %25, i64 0, i64 0
  store i32 %21, ptr %26, align 4, !tbaa !19
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !20
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  call void %31(ptr noundef %32)
  br label %33

33:                                               ; preds = %14, %3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %34, i32 0, i32 34
  %36 = load i32, ptr %35, align 8, !tbaa !21
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %37, i32 0, i32 28
  %39 = load i32, ptr %38, align 8, !tbaa !22
  %40 = icmp uge i32 %36, %39
  br i1 %40, label %41, label %52

41:                                               ; preds = %33
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !15
  %45 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %44, i32 0, i32 5
  store i32 123, ptr %45, align 8, !tbaa !16
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !23
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  call void %50(ptr noundef %51, i32 noundef -1)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %95

52:                                               ; preds = %33
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !24
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %80

57:                                               ; preds = %52
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %58, i32 0, i32 34
  %60 = load i32, ptr %59, align 8, !tbaa !21
  %61 = zext i32 %60 to i64
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !24
  %65 = getelementptr inbounds %struct.jpeg_progress_mgr, ptr %64, i32 0, i32 1
  store i64 %61, ptr %65, align 8, !tbaa !25
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %66, i32 0, i32 28
  %68 = load i32, ptr %67, align 8, !tbaa !22
  %69 = zext i32 %68 to i64
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !24
  %73 = getelementptr inbounds %struct.jpeg_progress_mgr, ptr %72, i32 0, i32 2
  store i64 %69, ptr %73, align 8, !tbaa !27
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !24
  %77 = getelementptr inbounds %struct.jpeg_progress_mgr, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !28
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  call void %78(ptr noundef %79)
  br label %80

80:                                               ; preds = %57, %52
  store i32 0, ptr %8, align 4, !tbaa !9
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %81, i32 0, i32 78
  %83 = load ptr, ptr %82, align 8, !tbaa !29
  %84 = getelementptr inbounds %struct.jpeg_d_main_controller, ptr %83, i32 0, i32 1
  %85 = load ptr, ptr %84, align 8, !tbaa !30
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = load i32, ptr %7, align 4, !tbaa !9
  call void %85(ptr noundef %86, ptr noundef %87, ptr noundef %8, i32 noundef %88)
  %89 = load i32, ptr %8, align 4, !tbaa !9
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %90, i32 0, i32 34
  %92 = load i32, ptr %91, align 8, !tbaa !21
  %93 = add i32 %92, %89
  store i32 %93, ptr %91, align 8, !tbaa !21
  %94 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %94, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %95

95:                                               ; preds = %80, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %96 = load i32, ptr %4, align 4
  ret i32 %96
}

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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 36}
!12 = !{!"jpeg_decompress_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !10, i64 36, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !13, i64 80, !7, i64 88, !7, i64 89, !10, i64 92, !7, i64 96, !7, i64 97, !7, i64 98, !10, i64 100, !7, i64 104, !10, i64 108, !7, i64 112, !7, i64 113, !7, i64 114, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !6, i64 144, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !10, i64 168, !6, i64 176, !7, i64 184, !7, i64 216, !7, i64 248, !10, i64 280, !6, i64 288, !7, i64 296, !7, i64 297, !7, i64 298, !7, i64 314, !7, i64 330, !10, 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, !10, i64 376, !10, i64 380, !10, i64 384, !10, i64 388, !6, i64 392, !10, i64 400, !7, i64 408, !10, i64 440, !10, i64 444, !10, i64 448, !7, i64 452, !10, i64 492, !10, i64 496, !10, i64 500, !10, i64 504, !10, 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}
!13 = !{!"double", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !10, i64 40}
!17 = !{!"jpeg_error_mgr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !7, i64 44, !10, i64 124, !18, i64 128, !6, i64 136, !10, i64 144, !6, i64 152, !10, i64 160, !10, i64 164}
!18 = !{!"long", !7, i64 0}
!19 = !{!7, !7, i64 0}
!20 = !{!17, !6, i64 0}
!21 = !{!12, !10, i64 152}
!22 = !{!12, !10, i64 120}
!23 = !{!17, !6, i64 8}
!24 = !{!12, !6, i64 16}
!25 = !{!26, !18, i64 8}
!26 = !{!"jpeg_progress_mgr", !6, i64 0, !18, i64 8, !18, i64 16, !10, i64 24, !10, i64 28}
!27 = !{!26, !18, i64 16}
!28 = !{!26, !6, i64 0}
!29 = !{!12, !6, i64 520}
!30 = !{!31, !6, i64 8}
!31 = !{!"jpeg_d_main_controller", !6, i64 0, !6, i64 8}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 i32 @jpeg_read_scanlines(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  %5 = getelementptr inbounds i8, ptr %0, i64 36
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 205
  br i1 %.not, label %13, label %7

7:                                                ; preds = %3
  %8 = load ptr, ptr %0, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %8, i64 40
  store i32 20, ptr %9, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %8, i64 44
  store i32 %6, ptr %10, align 4, !tbaa !17
  %11 = load ptr, ptr %0, align 8, !tbaa !13
  %12 = load ptr, ptr %11, align 8, !tbaa !18
  tail call void %12(ptr noundef nonnull %0) #2
  br label %13

13:                                               ; preds = %7, %3
  %14 = getelementptr inbounds i8, ptr %0, i64 152
  %15 = load i32, ptr %14, align 8, !tbaa !19
  %16 = getelementptr inbounds i8, ptr %0, i64 120
  %17 = load i32, ptr %16, align 8, !tbaa !20
  %.not25 = icmp ult i32 %15, %17
  br i1 %.not25, label %23, label %18

18:                                               ; preds = %13
  %19 = load ptr, ptr %0, align 8, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %19, i64 40
  store i32 123, ptr %20, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %19, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !21
  tail call void %22(ptr noundef nonnull %0, i32 noundef -1) #2
  br label %40

23:                                               ; preds = %13
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  %25 = load ptr, ptr %24, align 8, !tbaa !22
  %.not26 = icmp eq ptr %25, null
  br i1 %.not26, label %32, label %26

26:                                               ; preds = %23
  %27 = zext i32 %15 to i64
  %28 = getelementptr inbounds i8, ptr %25, i64 8
  store i64 %27, ptr %28, align 8, !tbaa !23
  %29 = zext i32 %17 to i64
  %30 = getelementptr inbounds i8, ptr %25, i64 16
  store i64 %29, ptr %30, align 8, !tbaa !25
  %31 = load ptr, ptr %25, align 8, !tbaa !26
  tail call void %31(ptr noundef nonnull %0) #2
  br label %32

32:                                               ; preds = %26, %23
  store i32 0, ptr %4, align 4, !tbaa !27
  %33 = getelementptr inbounds i8, ptr %0, i64 520
  %34 = load ptr, ptr %33, align 8, !tbaa !28
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !29
  call void %36(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %4, i32 noundef %2) #2
  %37 = load i32, ptr %4, align 4, !tbaa !27
  %38 = load i32, ptr %14, align 8, !tbaa !19
  %39 = add i32 %38, %37
  store i32 %39, ptr %14, align 8, !tbaa !19
  br label %40

40:                                               ; preds = %32, %18
  %.0 = phi i32 [ 0, %18 ], [ %37, %32 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  ret i32 %.0
}

attributes #0 = { mustprogress 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, !10, i64 36}
!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 = !{!6, !7, i64 0}
!14 = !{!15, !10, i64 40}
!15 = !{!"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, !16, i64 128, !7, i64 136, !10, i64 144, !7, i64 152, !10, i64 160, !10, i64 164}
!16 = !{!"long", !8, i64 0}
!17 = !{!8, !8, i64 0}
!18 = !{!15, !7, i64 0}
!19 = !{!6, !10, i64 152}
!20 = !{!6, !10, i64 120}
!21 = !{!15, !7, i64 8}
!22 = !{!6, !7, i64 16}
!23 = !{!24, !16, i64 8}
!24 = !{!"jpeg_progress_mgr", !7, i64 0, !16, i64 8, !16, i64 16, !10, i64 24, !10, i64 28}
!25 = !{!24, !16, i64 16}
!26 = !{!24, !7, i64 0}
!27 = !{!10, !10, i64 0}
!28 = !{!6, !7, i64 520}
!29 = !{!30, !7, i64 8}
!30 = !{!"jpeg_d_main_controller", !7, i64 0, !7, i64 8}


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