; LLVM IR from EyalAr/lwip :: src/lib/jpeg (jdmarker)

; 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, i32, i32, ptr, i32, i32, i32, i32, i32, i32, i32, double, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32, ptr, [4 x ptr], [4 x ptr], [4 x ptr], i32, ptr, i32, i32, i32, [16 x i8], [16 x i8], [16 x i8], i32, i32, i8, i8, i8, i16, i16, i32, i8, i32, i32, ptr, i32, i32, i32, i32, i32, ptr, i32, [4 x ptr], i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, ptr, 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, i32, i32, i32, i32 }

; 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 @jinit_marker_reader(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %5, i32 0, i32 1
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.jpeg_memory_mgr, ptr %7, i32 0, i32 0
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = call ptr %9(ptr noundef %10, i32 noundef 0, i64 noundef 264)
  store ptr %11, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.my_marker_reader, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %14, i32 0, i32 88
  store ptr %13, ptr %15, align 8, !tbaa !17
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.my_marker_reader, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.jpeg_marker_reader, ptr %17, i32 0, i32 0
  store ptr @reset_marker_reader, ptr %18, align 8, !tbaa !18
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.my_marker_reader, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.jpeg_marker_reader, ptr %20, i32 0, i32 1
  store ptr @read_markers, ptr %21, align 8, !tbaa !21
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.my_marker_reader, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.jpeg_marker_reader, ptr %23, i32 0, i32 2
  store ptr @read_restart_marker, ptr %24, align 8, !tbaa !22
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.my_marker_reader, ptr %25, i32 0, i32 1
  store ptr @skip_variable, ptr %26, align 8, !tbaa !23
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.my_marker_reader, ptr %27, i32 0, i32 3
  store i32 0, ptr %28, align 8, !tbaa !24
  store i32 0, ptr %4, align 4, !tbaa !25
  br label %29

29:                                               ; preds = %43, %1
  %30 = load i32, ptr %4, align 4, !tbaa !25
  %31 = icmp slt i32 %30, 16
  br i1 %31, label %32, label %46

32:                                               ; preds = %29
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.my_marker_reader, ptr %33, i32 0, i32 2
  %35 = load i32, ptr %4, align 4, !tbaa !25
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [16 x ptr], ptr %34, i64 0, i64 %36
  store ptr @skip_variable, ptr %37, align 8, !tbaa !5
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.my_marker_reader, ptr %38, i32 0, i32 4
  %40 = load i32, ptr %4, align 4, !tbaa !25
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [16 x i32], ptr %39, i64 0, i64 %41
  store i32 0, ptr %42, align 4, !tbaa !25
  br label %43

43:                                               ; preds = %32
  %44 = load i32, ptr %4, align 4, !tbaa !25
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %4, align 4, !tbaa !25
  br label %29, !llvm.loop !26

46:                                               ; preds = %29
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.my_marker_reader, ptr %47, i32 0, i32 2
  %49 = getelementptr inbounds [16 x ptr], ptr %48, i64 0, i64 0
  store ptr @get_interesting_appn, ptr %49, align 8, !tbaa !5
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.my_marker_reader, ptr %50, i32 0, i32 2
  %52 = getelementptr inbounds [16 x ptr], ptr %51, i64 0, i64 14
  store ptr @get_interesting_appn, ptr %52, align 8, !tbaa !5
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  call void @reset_marker_reader(ptr noundef %53)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @reset_marker_reader(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @read_markers(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @read_restart_marker(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @skip_variable(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @get_interesting_appn(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, !6, i64 8}
!10 = !{!"jpeg_decompress_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !12, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !11, i64 152, !11, i64 156, !6, i64 160, !11, i64 168, !11, i64 172, !11, i64 176, !11, i64 180, !11, i64 184, !6, i64 192, !7, i64 200, !7, i64 232, !7, i64 264, !11, i64 296, !6, i64 304, !11, i64 312, !11, i64 316, !11, i64 320, !7, i64 324, !7, i64 340, !7, i64 356, !11, i64 372, !11, i64 376, !7, i64 380, !7, i64 381, !7, i64 382, !13, i64 384, !13, i64 386, !11, i64 388, !7, i64 392, !11, i64 396, !11, i64 400, !6, i64 408, !11, i64 416, !11, i64 420, !11, i64 424, !11, i64 428, !11, i64 432, !6, i64 440, !11, i64 448, !7, i64 456, !11, i64 488, !11, i64 492, !11, i64 496, !7, i64 500, !11, i64 540, !11, i64 544, !11, i64 548, !11, i64 552, !11, i64 556, !6, i64 560, !11, i64 568, !11, i64 572, !6, i64 576, !6, i64 584, !6, i64 592, !6, i64 600, !6, i64 608, !6, i64 616, !6, i64 624, !6, i64 632, !6, i64 640, !6, i64 648, !6, i64 656}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"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, !16, i64 88, !16, i64 96}
!16 = !{!"long", !7, i64 0}
!17 = !{!10, !6, i64 616}
!18 = !{!19, !6, i64 0}
!19 = !{!"", !20, i64 0, !6, i64 40, !7, i64 48, !11, i64 176, !7, i64 180, !6, i64 248, !11, i64 256}
!20 = !{!"jpeg_marker_reader", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36}
!21 = !{!19, !6, i64 8}
!22 = !{!19, !6, i64 16}
!23 = !{!19, !6, i64 40}
!24 = !{!19, !11, i64 176}
!25 = !{!11, !11, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"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_marker_reader(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !13
  %5 = tail call ptr %4(ptr noundef %0, i32 noundef 0, i64 noundef 264) #1
  %6 = getelementptr inbounds i8, ptr %0, i64 616
  store ptr %5, ptr %6, align 8, !tbaa !16
  store ptr @reset_marker_reader, ptr %5, align 8, !tbaa !17
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr @read_markers, ptr %7, align 8, !tbaa !20
  %8 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr @read_restart_marker, ptr %8, align 8, !tbaa !21
  %9 = getelementptr inbounds i8, ptr %5, i64 40
  store ptr @skip_variable, ptr %9, align 8, !tbaa !22
  %10 = getelementptr inbounds i8, ptr %5, i64 176
  %11 = getelementptr inbounds i8, ptr %5, i64 48
  %12 = getelementptr inbounds i8, ptr %5, i64 56
  store ptr @skip_variable, ptr %12, align 8, !tbaa !23
  %13 = getelementptr inbounds i8, ptr %5, i64 64
  store ptr @skip_variable, ptr %13, align 8, !tbaa !23
  store <4 x i32> zeroinitializer, ptr %10, align 8, !tbaa !24
  %14 = getelementptr inbounds i8, ptr %5, i64 72
  store ptr @skip_variable, ptr %14, align 8, !tbaa !23
  %15 = getelementptr inbounds i8, ptr %5, i64 192
  %16 = getelementptr inbounds i8, ptr %5, i64 80
  store ptr @skip_variable, ptr %16, align 8, !tbaa !23
  %17 = getelementptr inbounds i8, ptr %5, i64 88
  store ptr @skip_variable, ptr %17, align 8, !tbaa !23
  %18 = getelementptr inbounds i8, ptr %5, i64 96
  store ptr @skip_variable, ptr %18, align 8, !tbaa !23
  store <4 x i32> zeroinitializer, ptr %15, align 4, !tbaa !24
  %19 = getelementptr inbounds i8, ptr %5, i64 104
  store ptr @skip_variable, ptr %19, align 8, !tbaa !23
  %20 = getelementptr inbounds i8, ptr %5, i64 208
  %21 = getelementptr inbounds i8, ptr %5, i64 112
  store ptr @skip_variable, ptr %21, align 8, !tbaa !23
  %22 = getelementptr inbounds i8, ptr %5, i64 120
  store ptr @skip_variable, ptr %22, align 8, !tbaa !23
  %23 = getelementptr inbounds i8, ptr %5, i64 128
  store ptr @skip_variable, ptr %23, align 8, !tbaa !23
  store <4 x i32> zeroinitializer, ptr %20, align 4, !tbaa !24
  %24 = getelementptr inbounds i8, ptr %5, i64 136
  store ptr @skip_variable, ptr %24, align 8, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %5, i64 224
  %26 = getelementptr inbounds i8, ptr %5, i64 144
  store ptr @skip_variable, ptr %26, align 8, !tbaa !23
  %27 = getelementptr inbounds i8, ptr %5, i64 152
  store ptr @skip_variable, ptr %27, align 8, !tbaa !23
  store <4 x i32> zeroinitializer, ptr %25, align 4, !tbaa !24
  %28 = getelementptr inbounds i8, ptr %5, i64 168
  store ptr @skip_variable, ptr %28, align 8, !tbaa !23
  %29 = getelementptr inbounds i8, ptr %5, i64 240
  store i32 0, ptr %29, align 4, !tbaa !24
  store ptr @get_interesting_appn, ptr %11, align 8, !tbaa !23
  %30 = getelementptr inbounds i8, ptr %5, i64 160
  store ptr @get_interesting_appn, ptr %30, align 8, !tbaa !23
  tail call void @reset_marker_reader(ptr noundef %0)
  ret void
}

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @get_interesting_appn(ptr 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_decompress_struct", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, 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, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152, !10, i64 156, !7, i64 160, !10, i64 168, !10, i64 172, !10, i64 176, !10, i64 180, !10, i64 184, !7, i64 192, !8, i64 200, !8, i64 232, !8, i64 264, !10, i64 296, !7, i64 304, !10, i64 312, !10, i64 316, !10, i64 320, !8, i64 324, !8, i64 340, !8, i64 356, !10, i64 372, !10, i64 376, !8, i64 380, !8, i64 381, !8, i64 382, !12, i64 384, !12, i64 386, !10, i64 388, !8, i64 392, !10, i64 396, !10, i64 400, !7, i64 408, !10, i64 416, !10, i64 420, !10, i64 424, !10, i64 428, !10, i64 432, !7, i64 440, !10, i64 448, !8, i64 456, !10, i64 488, !10, i64 492, !10, i64 496, !8, i64 500, !10, i64 540, !10, i64 544, !10, i64 548, !10, i64 552, !10, i64 556, !7, i64 560, !10, i64 568, !10, i64 572, !7, i64 576, !7, i64 584, !7, i64 592, !7, i64 600, !7, i64 608, !7, i64 616, !7, i64 624, !7, i64 632, !7, i64 640, !7, i64 648, !7, i64 656}
!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 616}
!17 = !{!18, !7, i64 0}
!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, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36}
!20 = !{!18, !7, i64 8}
!21 = !{!18, !7, i64 16}
!22 = !{!18, !7, i64 40}
!23 = !{!7, !7, i64 0}
!24 = !{!10, !10, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass