; LLVM IR from team-charls/charls :: src/jpeg_stream_reader.ll (ZN6charls18jpeg_stream_reader26read_start_of_scan_segmentEv)

; 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.std::array" = type { [4 x i8] }
%"class.charls::jpeg_stream_reader" = type { ptr, ptr, %"class.charls::span", %struct.charls_frame_info, %"struct.charls::coding_parameters", %struct.charls_jpegls_pc_parameters, %"class.std::vector", %"class.std::vector.0", i32, i32, i32, i32, i8, i32, %"struct.charls::callback_function", %"struct.charls::callback_function.5" }
%"class.charls::span" = type { ptr, i64 }
%struct.charls_frame_info = type { i32, i32, i32, i32 }
%"struct.charls::coding_parameters" = type { i32, i32, i32, i32 }
%struct.charls_jpegls_pc_parameters = type { i32, i32, i32, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<charls::jpeg_stream_reader::component_info, std::allocator<charls::jpeg_stream_reader::component_info>>::_Vector_impl" }
%"struct.std::_Vector_base<charls::jpeg_stream_reader::component_info, std::allocator<charls::jpeg_stream_reader::component_info>>::_Vector_impl" = type { %"struct.std::_Vector_base<charls::jpeg_stream_reader::component_info, std::allocator<charls::jpeg_stream_reader::component_info>>::_Vector_impl_data" }
%"struct.std::_Vector_base<charls::jpeg_stream_reader::component_info, std::allocator<charls::jpeg_stream_reader::component_info>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<charls::jpeg_stream_reader::mapping_table_entry, std::allocator<charls::jpeg_stream_reader::mapping_table_entry>>::_Vector_impl" }
%"struct.std::_Vector_base<charls::jpeg_stream_reader::mapping_table_entry, std::allocator<charls::jpeg_stream_reader::mapping_table_entry>>::_Vector_impl" = type { %"struct.std::_Vector_base<charls::jpeg_stream_reader::mapping_table_entry, std::allocator<charls::jpeg_stream_reader::mapping_table_entry>>::_Vector_impl_data" }
%"struct.std::_Vector_base<charls::jpeg_stream_reader::mapping_table_entry, std::allocator<charls::jpeg_stream_reader::mapping_table_entry>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.charls::callback_function" = type { ptr, ptr }
%"struct.charls::callback_function.5" = type { ptr, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #0

; Function Attrs: mustprogress noinline noreturn uwtable
declare dso_local void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6charls18jpeg_stream_reader26read_start_of_scan_segmentEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::array", align 1
  %5 = alloca %"struct.std::array", align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @_ZNK6charls18jpeg_stream_reader26check_minimal_segment_sizeEm(ptr noundef nonnull align 8 dereferenceable(192) %8, i64 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %9 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %8) #7
  %10 = zext i8 %9 to i32
  store i32 %10, ptr %3, align 4, !tbaa !9
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 1
  br i1 %12, label %25, label %13

13:                                               ; preds = %1
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = icmp sgt i32 %14, 4
  br i1 %15, label %25, label %16

16:                                               ; preds = %13
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 3
  %19 = getelementptr inbounds %struct.charls_frame_info, ptr %18, i32 0, i32 3
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 9
  %22 = load i32, ptr %21, align 4, !tbaa !33
  %23 = sub nsw i32 %20, %22
  %24 = icmp sgt i32 %17, %23
  br label %25

25:                                               ; preds = %16, %13, %1
  %26 = phi i1 [ true, %13 ], [ true, %1 ], [ %24, %16 ]
  %27 = xor i1 %26, true
  %28 = xor i1 %27, true
  %29 = zext i1 %28 to i64
  %30 = call i64 @llvm.expect.i64(i64 %29, i64 0)
  %31 = icmp ne i64 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %25
  call void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef 32) #8
  unreachable

33:                                               ; preds = %25
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 10
  store i32 %34, ptr %35, align 8, !tbaa !34
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 9
  %38 = load i32, ptr %37, align 4, !tbaa !33
  %39 = add nsw i32 %38, %36
  store i32 %39, ptr %37, align 4, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.memset.p0.i64(ptr align 1 %4, i8 0, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  call void @llvm.memset.p0.i64(ptr align 1 %5, i8 0, i64 4, i1 false)
  %40 = load i32, ptr %3, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = mul i64 %41, 2
  %43 = add i64 %42, 4
  call void @_ZNK6charls18jpeg_stream_reader18check_segment_sizeEm(ptr noundef nonnull align 8 dereferenceable(192) %8, i64 noundef %43)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %58, %33
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = load i32, ptr %3, align 4, !tbaa !9
  %47 = icmp ne i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %61

49:                                               ; preds = %44
  %50 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %8) #7
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %4, i64 noundef %52) #7
  store i8 %50, ptr %53, align 1, !tbaa !35
  %54 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %8) #7
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %5, i64 noundef %56) #7
  store i8 %54, ptr %57, align 1, !tbaa !35
  br label %58

58:                                               ; preds = %49
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %6, align 4, !tbaa !9
  br label %44, !llvm.loop !36

61:                                               ; preds = %48
  %62 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %8) #7
  %63 = zext i8 %62 to i32
  %64 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 4
  %65 = getelementptr inbounds %"struct.charls::coding_parameters", ptr %64, i32 0, i32 0
  store i32 %63, ptr %65, align 8, !tbaa !38
  %66 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 4
  %67 = getelementptr inbounds %"struct.charls::coding_parameters", ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !38
  %69 = call noundef i32 @_ZNK6charls18jpeg_stream_reader20maximum_sample_valueEv(ptr noundef nonnull align 8 dereferenceable(192) %8) #7
  %70 = call noundef i32 @_ZN6charls29compute_maximum_near_losslessEi(i32 noundef %69) #7
  %71 = icmp sgt i32 %68, %70
  %72 = xor i1 %71, true
  %73 = xor i1 %72, true
  %74 = zext i1 %73 to i64
  %75 = call i64 @llvm.expect.i64(i64 %74, i64 0)
  %76 = icmp ne i64 %75, 0
  br i1 %76, label %77, label %78

77:                                               ; preds = %61
  call void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef 34) #8
  unreachable

78:                                               ; preds = %61
  %79 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %8) #7
  %80 = zext i8 %79 to i32
  %81 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 11
  store i32 %80, ptr %81, align 4, !tbaa !39
  %82 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 11
  %83 = load i32, ptr %82, align 4, !tbaa !39
  %84 = load i32, ptr %3, align 4, !tbaa !9
  call void @_ZN6charls18jpeg_stream_reader21check_interleave_modeENS_15interleave_modeEi(i32 noundef %83, i32 noundef %84)
  %85 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 11
  %86 = load i32, ptr %85, align 4, !tbaa !39
  %87 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 4
  %88 = getelementptr inbounds %"struct.charls::coding_parameters", ptr %87, i32 0, i32 2
  store i32 %86, ptr %88, align 8, !tbaa !40
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %109, %78
  %90 = load i32, ptr %7, align 4, !tbaa !9
  %91 = load i32, ptr %3, align 4, !tbaa !9
  %92 = icmp ne i32 %90, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %112

94:                                               ; preds = %89
  %95 = load i32, ptr %7, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %4, i64 noundef %96) #7
  %98 = load i8, ptr %97, align 1, !tbaa !35
  %99 = load i32, ptr %7, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %5, i64 noundef %100) #7
  %102 = load i8, ptr %101, align 1, !tbaa !35
  %103 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 4
  %104 = getelementptr inbounds %"struct.charls::coding_parameters", ptr %103, i32 0, i32 0
  %105 = load i32, ptr %104, align 8, !tbaa !38
  %106 = trunc i32 %105 to i8
  %107 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 11
  %108 = load i32, ptr %107, align 4, !tbaa !39
  call void @_ZN6charls18jpeg_stream_reader20store_component_infoEhhhNS_15interleave_modeE(ptr noundef nonnull align 8 dereferenceable(192) %8, i8 noundef zeroext %98, i8 noundef zeroext %102, i8 noundef zeroext %106, i32 noundef %108)
  br label %109

109:                                              ; preds = %94
  %110 = load i32, ptr %7, align 4, !tbaa !9
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %7, align 4, !tbaa !9
  br label %89, !llvm.loop !41

112:                                              ; preds = %93
  %113 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %8) #7
  %114 = call noundef zeroext i8 @_ZStanSt4byteS_(i8 noundef zeroext %113, i8 noundef zeroext 15) #7
  %115 = icmp ne i8 %114, 0
  %116 = xor i1 %115, true
  %117 = xor i1 %116, true
  %118 = zext i1 %117 to i64
  %119 = call i64 @llvm.expect.i64(i64 %118, i64 0)
  %120 = icmp ne i64 %119, 0
  br i1 %120, label %121, label %122

121:                                              ; preds = %112
  call void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef 7) #8
  unreachable

122:                                              ; preds = %112
  %123 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 8
  store i32 5, ptr %123, align 8, !tbaa !42
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6charls18jpeg_stream_reader26check_minimal_segment_sizeEm(ptr noundef nonnull align 8 dereferenceable(192), i64 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6charls18jpeg_stream_reader18check_segment_sizeEm(ptr noundef nonnull align 8 dereferenceable(192), i64 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192)) #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4), i64 noundef) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN6charls29compute_maximum_near_losslessEi(i32 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6charls18jpeg_stream_reader20maximum_sample_valueEv(ptr noundef nonnull align 8 dereferenceable(192)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6charls18jpeg_stream_reader21check_interleave_modeENS_15interleave_modeEi(i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6charls18jpeg_stream_reader20store_component_infoEhhhNS_15interleave_modeE(ptr noundef nonnull align 8 dereferenceable(192), i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i32 noundef) #3 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZStanSt4byteS_(i8 noundef zeroext, i8 noundef zeroext) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #1 = { mustprogress noinline noreturn 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress 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 #4 = { mustprogress 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { alwaysinline mustprogress 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 #7 = { nounwind }
attributes #8 = { noreturn }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 44}
!12 = !{!"_ZTSN6charls18jpeg_stream_readerE", !6, i64 0, !6, i64 8, !13, i64 16, !15, i64 32, !16, i64 48, !19, i64 64, !20, i64 88, !24, i64 112, !28, i64 136, !10, i64 140, !10, i64 144, !17, i64 148, !29, i64 152, !30, i64 156, !31, i64 160, !32, i64 176}
!13 = !{!"_ZTSN6charls4spanIKSt4byteEE", !6, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTS17charls_frame_info", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!16 = !{!"_ZTSN6charls17coding_parametersE", !10, i64 0, !10, i64 4, !17, i64 8, !18, i64 12}
!17 = !{!"_ZTSN6charls15interleave_modeE", !7, i64 0}
!18 = !{!"_ZTSN6charls20color_transformationE", !7, i64 0}
!19 = !{!"_ZTS27charls_jpegls_pc_parameters", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!20 = !{!"_ZTSSt6vectorIN6charls18jpeg_stream_reader14component_infoESaIS2_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIN6charls18jpeg_stream_reader14component_infoESaIS2_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader14component_infoESaIS2_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader14component_infoESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!"_ZTSSt6vectorIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!"_ZTSN6charls18jpeg_stream_reader5stateE", !7, i64 0}
!29 = !{!"bool", !7, i64 0}
!30 = !{!"_ZTSN6charls22compressed_data_formatE", !7, i64 0}
!31 = !{!"_ZTSN6charls17callback_functionIPFiPKvmPvEEE", !6, i64 0, !6, i64 8}
!32 = !{!"_ZTSN6charls17callback_functionIPFiiPKvmPvEEE", !6, i64 0, !6, i64 8}
!33 = !{!12, !10, i64 140}
!34 = !{!12, !10, i64 144}
!35 = !{!7, !7, i64 0}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!12, !10, i64 48}
!39 = !{!12, !17, i64 148}
!40 = !{!12, !17, i64 56}
!41 = distinct !{!41, !37}
!42 = !{!12, !28, i64 136}


; 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"

%"struct.std::array" = type { [4 x i8] }

; Function Attrs: mustprogress noinline noreturn uwtable
declare dso_local void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6charls18jpeg_stream_reader26read_start_of_scan_segmentEv(ptr noundef nonnull align 8 dereferenceable(192) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca %"struct.std::array", align 4
  %3 = alloca %"struct.std::array", align 4
  tail call void @_ZNK6charls18jpeg_stream_reader26check_minimal_segment_sizeEm(ptr noundef nonnull align 8 dereferenceable(192) %0, i64 noundef 1)
  %4 = tail call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #5
  %5 = zext i8 %4 to i32
  %6 = add i8 %4, -5
  %or.cond = icmp ult i8 %6, -4
  %7 = getelementptr inbounds i8, ptr %0, i64 44
  %8 = load i32, ptr %7, align 4
  %9 = getelementptr inbounds i8, ptr %0, i64 140
  %10 = load i32, ptr %9, align 4
  %11 = sub nsw i32 %8, %10
  %12 = icmp slt i32 %11, %5
  %13 = select i1 %or.cond, i1 true, i1 %12, !prof !5
  br i1 %13, label %14, label %.lr.ph.preheader, !prof !6

14:                                               ; preds = %1
  tail call void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef 32) #6
  unreachable

.lr.ph.preheader:                                 ; preds = %1
  %15 = getelementptr inbounds i8, ptr %0, i64 144
  store i32 %5, ptr %15, align 8, !tbaa !7
  %16 = add nsw i32 %10, %5
  store i32 %16, ptr %9, align 4, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 0, ptr %2, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  store i32 0, ptr %3, align 4
  %17 = shl nuw nsw i8 %4, 1
  %narrow = add nuw nsw i8 %17, 4
  %18 = zext nneg i8 %narrow to i64
  tail call void @_ZNK6charls18jpeg_stream_reader18check_segment_sizeEm(ptr noundef nonnull align 8 dereferenceable(192) %0, i64 noundef %18)
  %19 = zext nneg i8 %4 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %20 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #5
  %21 = zext i8 %20 to i32
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %21, ptr %22, align 8, !tbaa !34
  %23 = call noundef i32 @_ZNK6charls18jpeg_stream_reader20maximum_sample_valueEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #5
  %24 = call noundef i32 @_ZN6charls29compute_maximum_near_losslessEi(i32 noundef %23) #5
  %25 = icmp slt i32 %24, %21
  br i1 %25, label %30, label %.lr.ph27.preheader, !prof !6

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %26 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #5
  %27 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %2, i64 noundef %indvars.iv) #5
  store i8 %26, ptr %27, align 1, !tbaa !35
  %28 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #5
  %29 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %3, i64 noundef %indvars.iv) #5
  store i8 %28, ptr %29, align 1, !tbaa !35
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not = icmp eq i64 %indvars.iv.next, %19
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !36

30:                                               ; preds = %._crit_edge
  call void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef 34) #6
  unreachable

.lr.ph27.preheader:                               ; preds = %._crit_edge
  %31 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #5
  %32 = zext i8 %31 to i32
  %33 = getelementptr inbounds i8, ptr %0, i64 148
  store i32 %32, ptr %33, align 4, !tbaa !38
  call void @_ZN6charls18jpeg_stream_reader21check_interleave_modeENS_15interleave_modeEi(i32 noundef %32, i32 noundef %5)
  %34 = load i32, ptr %33, align 4, !tbaa !38
  %35 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 %34, ptr %35, align 8, !tbaa !39
  %36 = zext nneg i8 %4 to i64
  br label %.lr.ph27

._crit_edge28:                                    ; preds = %.lr.ph27
  %37 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #5
  %38 = call noundef zeroext i8 @_ZStanSt4byteS_(i8 noundef zeroext %37, i8 noundef zeroext 15) #5
  %.not21 = icmp eq i8 %38, 0
  br i1 %.not21, label %47, label %46, !prof !40

.lr.ph27:                                         ; preds = %.lr.ph27.preheader, %.lr.ph27
  %indvars.iv30 = phi i64 [ 0, %.lr.ph27.preheader ], [ %indvars.iv.next31, %.lr.ph27 ]
  %39 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %2, i64 noundef %indvars.iv30) #5
  %40 = load i8, ptr %39, align 1, !tbaa !35
  %41 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %3, i64 noundef %indvars.iv30) #5
  %42 = load i8, ptr %41, align 1, !tbaa !35
  %43 = load i32, ptr %22, align 8, !tbaa !34
  %44 = trunc i32 %43 to i8
  %45 = load i32, ptr %33, align 4, !tbaa !38
  call void @_ZN6charls18jpeg_stream_reader20store_component_infoEhhhNS_15interleave_modeE(ptr noundef nonnull align 8 dereferenceable(192) %0, i8 noundef zeroext %40, i8 noundef zeroext %42, i8 noundef zeroext %44, i32 noundef %45)
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %.not20 = icmp eq i64 %indvars.iv.next31, %36
  br i1 %.not20, label %._crit_edge28, label %.lr.ph27, !llvm.loop !41

46:                                               ; preds = %._crit_edge28
  call void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef 7) #6
  unreachable

47:                                               ; preds = %._crit_edge28
  %48 = getelementptr inbounds i8, ptr %0, i64 136
  store i32 5, ptr %48, align 8, !tbaa !42
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6charls18jpeg_stream_reader26check_minimal_segment_sizeEm(ptr noundef nonnull align 8 dereferenceable(192), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6charls18jpeg_stream_reader18check_segment_sizeEm(ptr noundef nonnull align 8 dereferenceable(192), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN6charls29compute_maximum_near_losslessEi(i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6charls18jpeg_stream_reader20maximum_sample_valueEv(ptr noundef nonnull align 8 dereferenceable(192)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6charls18jpeg_stream_reader21check_interleave_modeENS_15interleave_modeEi(i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6charls18jpeg_stream_reader20store_component_infoEhhhNS_15interleave_modeE(ptr noundef nonnull align 8 dereferenceable(192), i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZStanSt4byteS_(i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #4

attributes #0 = { mustprogress noinline noreturn 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #3 = { mustprogress 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 #4 = { alwaysinline mustprogress 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 #5 = { nounwind }
attributes #6 = { noreturn }

!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 = !{!"branch_weights", i32 4001, i32 4000000}
!6 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!7 = !{!8, !15, i64 144}
!8 = !{!"_ZTSN6charls18jpeg_stream_readerE", !9, i64 0, !9, i64 8, !12, i64 16, !14, i64 32, !16, i64 48, !19, i64 64, !20, i64 88, !24, i64 112, !28, i64 136, !15, i64 140, !15, i64 144, !17, i64 148, !29, i64 152, !30, i64 156, !31, i64 160, !32, i64 176}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN6charls4spanIKSt4byteEE", !9, i64 0, !13, i64 8}
!13 = !{!"long", !10, i64 0}
!14 = !{!"_ZTS17charls_frame_info", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!15 = !{!"int", !10, i64 0}
!16 = !{!"_ZTSN6charls17coding_parametersE", !15, i64 0, !15, i64 4, !17, i64 8, !18, i64 12}
!17 = !{!"_ZTSN6charls15interleave_modeE", !10, i64 0}
!18 = !{!"_ZTSN6charls20color_transformationE", !10, i64 0}
!19 = !{!"_ZTS27charls_jpegls_pc_parameters", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16}
!20 = !{!"_ZTSSt6vectorIN6charls18jpeg_stream_reader14component_infoESaIS2_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIN6charls18jpeg_stream_reader14component_infoESaIS2_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader14component_infoESaIS2_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader14component_infoESaIS2_EE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!24 = !{!"_ZTSSt6vectorIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!28 = !{!"_ZTSN6charls18jpeg_stream_reader5stateE", !10, i64 0}
!29 = !{!"bool", !10, i64 0}
!30 = !{!"_ZTSN6charls22compressed_data_formatE", !10, i64 0}
!31 = !{!"_ZTSN6charls17callback_functionIPFiPKvmPvEEE", !9, i64 0, !9, i64 8}
!32 = !{!"_ZTSN6charls17callback_functionIPFiiPKvmPvEEE", !9, i64 0, !9, i64 8}
!33 = !{!8, !15, i64 140}
!34 = !{!8, !15, i64 48}
!35 = !{!10, !10, i64 0}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!8, !17, i64 148}
!39 = !{!8, !17, i64 56}
!40 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!41 = distinct !{!41, !37}
!42 = !{!8, !28, i64 136}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LowerExpectIntrinsicPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass