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

; 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_marker_reader = type { %struct.jpeg_marker_reader, ptr, [16 x ptr], i32, [16 x i32], ptr, i32 }
%struct.jpeg_marker_reader = type { ptr, ptr, ptr, i8, i8, i32, i32 }
%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: 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
declare hidden zeroext i8 @skip_variable(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @get_interesting_appn(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @jpeg_save_markers(ptr noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %10, i32 0, i32 82
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  store ptr %12, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = getelementptr inbounds %struct.jpeg_memory_mgr, ptr %15, i32 0, i32 12
  %17 = load i64, ptr %16, align 8, !tbaa !16
  %18 = sub i64 %17, 32
  store i64 %18, ptr %8, align 8, !tbaa !19
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = load i64, ptr %8, align 8, !tbaa !19
  %22 = icmp sgt i64 %20, %21
  br i1 %22, label %23, label %26

23:                                               ; preds = %3
  %24 = load i64, ptr %8, align 8, !tbaa !19
  %25 = trunc i64 %24 to i32
  store i32 %25, ptr %6, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %23, %3
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %45

29:                                               ; preds = %26
  store ptr @save_marker, ptr %9, align 8, !tbaa !5
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = icmp eq i32 %30, 224
  br i1 %31, label %32, label %36

32:                                               ; preds = %29
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = icmp ult i32 %33, 14
  br i1 %34, label %35, label %36

35:                                               ; preds = %32
  store i32 14, ptr %6, align 4, !tbaa !9
  br label %44

36:                                               ; preds = %32, %29
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 238
  br i1 %38, label %39, label %43

39:                                               ; preds = %36
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = icmp ult i32 %40, 12
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  store i32 12, ptr %6, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %42, %39, %36
  br label %44

44:                                               ; preds = %43, %35
  br label %53

45:                                               ; preds = %26
  store ptr @skip_variable, ptr %9, align 8, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 224
  br i1 %47, label %51, label %48

48:                                               ; preds = %45
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = icmp eq i32 %49, 238
  br i1 %50, label %51, label %52

51:                                               ; preds = %48, %45
  store ptr @get_interesting_appn, ptr %9, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %51, %48
  br label %53

53:                                               ; preds = %52, %44
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = icmp eq i32 %54, 254
  br i1 %55, label %56, label %63

56:                                               ; preds = %53
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.my_marker_reader, ptr %58, i32 0, i32 1
  store ptr %57, ptr %59, align 8, !tbaa !20
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.my_marker_reader, ptr %61, i32 0, i32 3
  store i32 %60, ptr %62, align 8, !tbaa !23
  br label %102

63:                                               ; preds = %53
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = icmp sge i32 %64, 224
  br i1 %65, label %66, label %84

66:                                               ; preds = %63
  %67 = load i32, ptr %5, align 4, !tbaa !9
  %68 = icmp sle i32 %67, 239
  br i1 %68, label %69, label %84

69:                                               ; preds = %66
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.my_marker_reader, ptr %71, i32 0, i32 2
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = sub nsw i32 %73, 224
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [16 x ptr], ptr %72, i64 0, i64 %75
  store ptr %70, ptr %76, align 8, !tbaa !5
  %77 = load i32, ptr %6, align 4, !tbaa !9
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.my_marker_reader, ptr %78, i32 0, i32 4
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = sub nsw i32 %80, 224
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [16 x i32], ptr %79, i64 0, i64 %82
  store i32 %77, ptr %83, align 4, !tbaa !9
  br label %101

84:                                               ; preds = %66, %63
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !24
  %88 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %87, i32 0, i32 5
  store i32 68, ptr %88, align 8, !tbaa !25
  %89 = load i32, ptr %5, align 4, !tbaa !9
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !24
  %93 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %92, i32 0, i32 6
  %94 = getelementptr inbounds [8 x i32], ptr %93, i64 0, i64 0
  store i32 %89, ptr %94, align 4, !tbaa !27
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !24
  %98 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !28
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  call void %99(ptr noundef %100)
  br label %101

101:                                              ; preds = %84, %69
  br label %102

102:                                              ; preds = %101, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @save_marker(ptr noundef) #1

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, !6, i64 552}
!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 8}
!16 = !{!17, !18, i64 96}
!17 = !{!"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, !18, i64 88, !18, i64 96}
!18 = !{!"long", !7, i64 0}
!19 = !{!18, !18, i64 0}
!20 = !{!21, !6, i64 40}
!21 = !{!"", !22, i64 0, !6, i64 40, !7, i64 48, !10, i64 176, !7, i64 180, !6, i64 248, !10, i64 256}
!22 = !{!"jpeg_marker_reader", !6, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !7, i64 25, !10, i64 28, !10, i64 32}
!23 = !{!21, !10, i64 176}
!24 = !{!12, !6, i64 0}
!25 = !{!26, !10, i64 40}
!26 = !{!"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}
!27 = !{!7, !7, i64 0}
!28 = !{!26, !6, i64 0}


; 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
declare hidden zeroext i8 @skip_variable(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @jpeg_save_markers(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 552
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %7, i64 96
  %9 = load i64, ptr %8, align 8, !tbaa !14
  %10 = add i64 %9, -32
  %11 = zext i32 %2 to i64
  %12 = icmp slt i64 %10, %11
  %13 = trunc i64 %10 to i32
  %spec.select = select i1 %12, i32 %13, i32 %2
  %.not = icmp eq i32 %spec.select, 0
  %14 = icmp eq i32 %1, 224
  br i1 %.not, label %20, label %15

15:                                               ; preds = %3
  %16 = icmp ult i32 %spec.select, 14
  %or.cond = and i1 %14, %16
  br i1 %or.cond, label %.thread44, label %17

17:                                               ; preds = %15
  %18 = icmp eq i32 %1, 238
  %19 = tail call i32 @llvm.umax.i32(i32 %spec.select, i32 12)
  %spec.store.select = select i1 %18, i32 %19, i32 %spec.select
  br label %22

20:                                               ; preds = %3
  %21 = icmp eq i32 %1, 238
  %or.cond5 = or i1 %14, %21
  %spec.store.select8 = select i1 %or.cond5, ptr @get_interesting_appn, ptr @skip_variable
  br label %22

22:                                               ; preds = %20, %17
  %.1 = phi i32 [ %spec.store.select, %17 ], [ 0, %20 ]
  %.0 = phi ptr [ @save_marker, %17 ], [ %spec.store.select8, %20 ]
  %23 = icmp eq i32 %1, 254
  br i1 %23, label %24, label %27

24:                                               ; preds = %22
  %25 = getelementptr inbounds i8, ptr %5, i64 40
  store ptr %.0, ptr %25, align 8, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %5, i64 176
  store i32 %.1, ptr %26, align 8, !tbaa !20
  br label %41

27:                                               ; preds = %22
  %28 = and i32 %1, -16
  %or.cond7 = icmp eq i32 %28, 224
  br i1 %or.cond7, label %.thread44, label %35

.thread44:                                        ; preds = %15, %27
  %.14249 = phi i32 [ %.1, %27 ], [ 14, %15 ]
  %.04348 = phi ptr [ %.0, %27 ], [ @save_marker, %15 ]
  %29 = getelementptr inbounds i8, ptr %5, i64 48
  %30 = add nsw i32 %1, -224
  %31 = zext nneg i32 %30 to i64
  %32 = getelementptr inbounds [16 x ptr], ptr %29, i64 0, i64 %31
  store ptr %.04348, ptr %32, align 8, !tbaa !21
  %33 = getelementptr inbounds i8, ptr %5, i64 180
  %34 = getelementptr inbounds [16 x i32], ptr %33, i64 0, i64 %31
  store i32 %.14249, ptr %34, align 4, !tbaa !22
  br label %41

35:                                               ; preds = %27
  %36 = load ptr, ptr %0, align 8, !tbaa !23
  %37 = getelementptr inbounds i8, ptr %36, i64 40
  store i32 68, ptr %37, align 8, !tbaa !24
  %38 = getelementptr inbounds i8, ptr %36, i64 44
  store i32 %1, ptr %38, align 4, !tbaa !26
  %39 = load ptr, ptr %0, align 8, !tbaa !23
  %40 = load ptr, ptr %39, align 8, !tbaa !27
  tail call void %40(ptr noundef nonnull %0) #2
  br label %41

41:                                               ; preds = %.thread44, %35, %24
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #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 speculatable willreturn memory(none) }
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, !7, i64 552}
!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 8}
!14 = !{!15, !16, i64 96}
!15 = !{!"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, !16, i64 88, !16, i64 96}
!16 = !{!"long", !8, i64 0}
!17 = !{!18, !7, i64 40}
!18 = !{!"", !19, i64 0, !7, i64 40, !8, i64 48, !10, i64 176, !8, i64 180, !7, i64 248, !10, i64 256}
!19 = !{!"jpeg_marker_reader", !7, i64 0, !7, i64 8, !7, i64 16, !8, i64 24, !8, i64 25, !10, i64 28, !10, i64 32}
!20 = !{!18, !10, i64 176}
!21 = !{!7, !7, i64 0}
!22 = !{!10, !10, i64 0}
!23 = !{!6, !7, i64 0}
!24 = !{!25, !10, i64 40}
!25 = !{!"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}
!26 = !{!8, !8, i64 0}
!27 = !{!25, !7, i64 0}


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