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

; 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.13" = type { [6 x i8] }
%"class.charls::span" = type { ptr, i64 }
%struct.charls_spiff_header = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%"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" }
%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 }

@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb = external hidden unnamed_addr constant [87 x i8], align 1
@__const._ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb.spiff_tag = external hidden unnamed_addr constant %"struct.std::array.13", align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6charls4spanIKSt4byteE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6charls18jpeg_stream_reader9skip_byteEv(ptr noundef nonnull align 8 dereferenceable(192)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK6charls4spanIKSt4byteE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { ptr, i64 } @_ZN6charls18jpeg_stream_reader10read_bytesEm(ptr noundef nonnull align 8 dereferenceable(192), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb(ptr noundef nonnull align 8 dereferenceable(192) %0, ptr noundef nonnull align 4 dereferenceable(40) %1, ptr noundef nonnull align 1 dereferenceable(1) %2) #5 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.std::array.13", align 1
  %8 = alloca %"class.charls::span", align 8
  %9 = alloca %struct.charls_spiff_header, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca %struct.charls_spiff_header, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  %14 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %13, i32 0, i32 2
  %15 = call noundef i64 @_ZNK6charls4spanIKSt4byteE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %14) #8
  %16 = icmp uge i64 %15, 30
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  br label %20

18:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.1, i32 noundef 787, ptr noundef @__PRETTY_FUNCTION__._ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb) #9
  unreachable

19:                                               ; No predecessors!
  br label %20

20:                                               ; preds = %19, %17
  call void @llvm.lifetime.start.p0(i64 6, ptr %7) #8
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %7, ptr align 1 @__const._ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb.spiff_tag, i64 6, i1 false)
  %21 = call noundef ptr @_ZNKSt5arrayISt4byteLm6EE6cbeginEv(ptr noundef nonnull align 1 dereferenceable(6) %7) #8
  %22 = call noundef ptr @_ZNKSt5arrayISt4byteLm6EE4cendEv(ptr noundef nonnull align 1 dereferenceable(6) %7) #8
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #8
  %23 = call noundef i64 @_ZNKSt5arrayISt4byteLm6EE4sizeEv(ptr noundef nonnull align 1 dereferenceable(6) %7) #10
  %24 = call { ptr, i64 } @_ZN6charls18jpeg_stream_reader10read_bytesEm(ptr noundef nonnull align 8 dereferenceable(192) %13, i64 noundef %23) #8
  %25 = getelementptr inbounds { ptr, i64 }, ptr %8, i32 0, i32 0
  %26 = extractvalue { ptr, i64 } %24, 0
  store ptr %26, ptr %25, align 8
  %27 = getelementptr inbounds { ptr, i64 }, ptr %8, i32 0, i32 1
  %28 = extractvalue { ptr, i64 } %24, 1
  store i64 %28, ptr %27, align 8
  %29 = call noundef ptr @_ZNK6charls4spanIKSt4byteE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %8) #8
  %30 = call noundef zeroext i1 @_ZSt5equalIPKSt4byteS2_EbT_S3_T0_(ptr noundef %21, ptr noundef %22, ptr noundef %29)
  %31 = xor i1 %30, true
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #8
  br i1 %31, label %32, label %45

32:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #8
  call void @llvm.memset.p0.i64(ptr align 4 %9, i8 0, i64 40, i1 false)
  %33 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 0
  %34 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 1
  %35 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 2
  %36 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 3
  %37 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 4
  %38 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 5
  %39 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 6
  %40 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 7
  %41 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 8
  %42 = getelementptr inbounds %struct.charls_spiff_header, ptr %9, i32 0, i32 9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %43, ptr align 4 %9, i64 40, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #8
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 0, ptr %44, align 1, !tbaa !20
  store i32 1, ptr %10, align 4
  br label %46

45:                                               ; preds = %20
  store i32 0, ptr %10, align 4
  br label %46

46:                                               ; preds = %45, %32
  call void @llvm.lifetime.end.p0(i64 6, ptr %7) #8
  %47 = load i32, ptr %10, align 4
  switch i32 %47, label %108 [
    i32 0, label %48
    i32 1, label %107
  ]

48:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #8
  %49 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  store i8 %49, ptr %11, align 1, !tbaa !22
  %50 = load i8, ptr %11, align 1, !tbaa !22
  %51 = zext i8 %50 to i32
  %52 = icmp sgt i32 %51, 2
  br i1 %52, label %53, label %66

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 40, ptr %12) #8
  call void @llvm.memset.p0.i64(ptr align 4 %12, i8 0, i64 40, i1 false)
  %54 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 0
  %55 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 1
  %56 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 2
  %57 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 3
  %58 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 4
  %59 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 5
  %60 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 6
  %61 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 7
  %62 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 8
  %63 = getelementptr inbounds %struct.charls_spiff_header, ptr %12, i32 0, i32 9
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %64, ptr align 4 %12, i64 40, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 40, ptr %12) #8
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 0, ptr %65, align 1, !tbaa !20
  store i32 1, ptr %10, align 4
  br label %67

66:                                               ; preds = %48
  store i32 0, ptr %10, align 4
  br label %67

67:                                               ; preds = %66, %53
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #8
  %68 = load i32, ptr %10, align 4
  switch i32 %68, label %108 [
    i32 0, label %69
    i32 1, label %107
  ]

69:                                               ; preds = %67
  call void @_ZN6charls18jpeg_stream_reader9skip_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %70 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %71 = zext i8 %70 to i32
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.charls_spiff_header, ptr %72, i32 0, i32 0
  store i32 %71, ptr %73, align 4, !tbaa !23
  %74 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %75 = zext i8 %74 to i32
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.charls_spiff_header, ptr %76, i32 0, i32 1
  store i32 %75, ptr %77, align 4, !tbaa !25
  %78 = call noundef i32 @_ZN6charls18jpeg_stream_reader11read_uint32Ev(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.charls_spiff_header, ptr %79, i32 0, i32 2
  store i32 %78, ptr %80, align 4, !tbaa !26
  %81 = call noundef i32 @_ZN6charls18jpeg_stream_reader11read_uint32Ev(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.charls_spiff_header, ptr %82, i32 0, i32 3
  store i32 %81, ptr %83, align 4, !tbaa !27
  %84 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %85 = zext i8 %84 to i32
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.charls_spiff_header, ptr %86, i32 0, i32 4
  store i32 %85, ptr %87, align 4, !tbaa !28
  %88 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %89 = zext i8 %88 to i32
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.charls_spiff_header, ptr %90, i32 0, i32 5
  store i32 %89, ptr %91, align 4, !tbaa !29
  %92 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %93 = zext i8 %92 to i32
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.charls_spiff_header, ptr %94, i32 0, i32 6
  store i32 %93, ptr %95, align 4, !tbaa !30
  %96 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %97 = zext i8 %96 to i32
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.charls_spiff_header, ptr %98, i32 0, i32 7
  store i32 %97, ptr %99, align 4, !tbaa !31
  %100 = call noundef i32 @_ZN6charls18jpeg_stream_reader11read_uint32Ev(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.charls_spiff_header, ptr %101, i32 0, i32 8
  store i32 %100, ptr %102, align 4, !tbaa !32
  %103 = call noundef i32 @_ZN6charls18jpeg_stream_reader11read_uint32Ev(ptr noundef nonnull align 8 dereferenceable(192) %13) #8
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.charls_spiff_header, ptr %104, i32 0, i32 9
  store i32 %103, ptr %105, align 4, !tbaa !33
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 1, ptr %106, align 1, !tbaa !20
  br label %107

107:                                              ; preds = %69, %67, %46
  ret void

108:                                              ; preds = %67, %46
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZSt5equalIPKSt4byteS2_EbT_S3_T0_(ptr noundef, ptr noundef, ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt5arrayISt4byteLm6EE6cbeginEv(ptr noundef nonnull align 1 dereferenceable(6)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt5arrayISt4byteLm6EE4cendEv(ptr noundef nonnull align 1 dereferenceable(6)) #1 align 2

; Function Attrs: mustprogress nounwind willreturn memory(none) uwtable
declare dso_local noundef i64 @_ZNKSt5arrayISt4byteLm6EE4sizeEv(ptr noundef nonnull align 1 dereferenceable(6)) #7 align 2

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

!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 = !{i64 0, i64 4, !10, i64 4, i64 4, !12, i64 8, i64 4, !12, i64 12, i64 4, !12, i64 16, i64 4, !14, i64 20, i64 4, !12, i64 24, i64 4, !16, i64 28, i64 4, !18, i64 32, i64 4, !12, i64 36, i64 4, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"_ZTSN6charls16spiff_profile_idE", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"_ZTSN6charls17spiff_color_spaceE", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"_ZTSN6charls22spiff_compression_typeE", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"_ZTSN6charls22spiff_resolution_unitsE", !7, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{!7, !7, i64 0}
!23 = !{!24, !11, i64 0}
!24 = !{!"_ZTS19charls_spiff_header", !11, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !15, i64 16, !13, i64 20, !17, i64 24, !19, i64 28, !13, i64 32, !13, i64 36}
!25 = !{!24, !13, i64 4}
!26 = !{!24, !13, i64 8}
!27 = !{!24, !13, i64 12}
!28 = !{!24, !15, i64 16}
!29 = !{!24, !13, i64 20}
!30 = !{!24, !17, i64 24}
!31 = !{!24, !19, i64 28}
!32 = !{!24, !13, i64 32}
!33 = !{!24, !13, i64 36}


; 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.13" = type { [6 x i8] }
%"class.charls::span" = type { ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb = external hidden unnamed_addr constant [87 x i8], align 1
@__const._ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb.spiff_tag = external hidden unnamed_addr constant %"struct.std::array.13", align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6charls4spanIKSt4byteE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN6charls18jpeg_stream_reader11read_uint32Ev(ptr noundef nonnull align 8 dereferenceable(192)) local_unnamed_addr #1 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 #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6charls18jpeg_stream_reader9skip_byteEv(ptr noundef nonnull align 8 dereferenceable(192)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK6charls4spanIKSt4byteE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 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 #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { ptr, i64 } @_ZN6charls18jpeg_stream_reader10read_bytesEm(ptr noundef nonnull align 8 dereferenceable(192), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb(ptr noundef nonnull align 8 dereferenceable(192) %0, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(40) %1, ptr nocapture noundef nonnull writeonly align 1 dereferenceable(1) %2) local_unnamed_addr #5 align 2 {
  %4 = alloca %"struct.std::array.13", align 1
  %5 = alloca %"class.charls::span", align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = tail call noundef i64 @_ZNK6charls4spanIKSt4byteE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %6) #8
  %8 = icmp ugt i64 %7, 29
  br i1 %8, label %10, label %9

9:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i32 noundef 787, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb) #9
  unreachable

10:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 6, ptr nonnull %4) #8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(6) %4, ptr noundef nonnull align 1 dereferenceable(6) @__const._ZN6charls18jpeg_stream_reader29try_read_spiff_header_segmentER19charls_spiff_headerRb.spiff_tag, i64 6, i1 false)
  %11 = call noundef ptr @_ZNKSt5arrayISt4byteLm6EE6cbeginEv(ptr noundef nonnull align 1 dereferenceable(6) %4) #8
  %12 = call noundef ptr @_ZNKSt5arrayISt4byteLm6EE4cendEv(ptr noundef nonnull align 1 dereferenceable(6) %4) #8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #8
  %13 = call noundef i64 @_ZNKSt5arrayISt4byteLm6EE4sizeEv(ptr noundef nonnull align 1 dereferenceable(6) %4) #10
  %14 = call { ptr, i64 } @_ZN6charls18jpeg_stream_reader10read_bytesEm(ptr noundef nonnull align 8 dereferenceable(192) %0, i64 noundef %13) #8
  %15 = extractvalue { ptr, i64 } %14, 0
  store ptr %15, ptr %5, align 8
  %16 = getelementptr inbounds i8, ptr %5, i64 8
  %17 = extractvalue { ptr, i64 } %14, 1
  store i64 %17, ptr %16, align 8
  %18 = call noundef ptr @_ZNK6charls4spanIKSt4byteE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #8
  %19 = call noundef zeroext i1 @_ZSt5equalIPKSt4byteS2_EbT_S3_T0_(ptr noundef %11, ptr noundef %12, ptr noundef %18)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #8
  br i1 %19, label %21, label %20

20:                                               ; preds = %10
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(40) %1, i8 0, i64 40, i1 false)
  store i8 0, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 6, ptr nonnull %4) #8
  br label %51

21:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 6, ptr nonnull %4) #8
  %22 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %23 = icmp ugt i8 %22, 2
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(40) %1, i8 0, i64 40, i1 false)
  store i8 0, ptr %2, align 1, !tbaa !5
  br label %51

25:                                               ; preds = %21
  call void @_ZN6charls18jpeg_stream_reader9skip_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %26 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %27 = zext i8 %26 to i32
  store i32 %27, ptr %1, align 4, !tbaa !9
  %28 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %29 = zext i8 %28 to i32
  %30 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %29, ptr %30, align 4, !tbaa !16
  %31 = call noundef i32 @_ZN6charls18jpeg_stream_reader11read_uint32Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %32 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %31, ptr %32, align 4, !tbaa !17
  %33 = call noundef i32 @_ZN6charls18jpeg_stream_reader11read_uint32Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %34 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 %33, ptr %34, align 4, !tbaa !18
  %35 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %36 = zext i8 %35 to i32
  %37 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 %36, ptr %37, align 4, !tbaa !19
  %38 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader10read_uint8Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %39 = zext i8 %38 to i32
  %40 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 %39, ptr %40, align 4, !tbaa !20
  %41 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %42 = zext i8 %41 to i32
  %43 = getelementptr inbounds i8, ptr %1, i64 24
  store i32 %42, ptr %43, align 4, !tbaa !21
  %44 = call noundef zeroext i8 @_ZN6charls18jpeg_stream_reader9read_byteEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %45 = zext i8 %44 to i32
  %46 = getelementptr inbounds i8, ptr %1, i64 28
  store i32 %45, ptr %46, align 4, !tbaa !22
  %47 = call noundef i32 @_ZN6charls18jpeg_stream_reader11read_uint32Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %48 = getelementptr inbounds i8, ptr %1, i64 32
  store i32 %47, ptr %48, align 4, !tbaa !23
  %49 = call noundef i32 @_ZN6charls18jpeg_stream_reader11read_uint32Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) #8
  %50 = getelementptr inbounds i8, ptr %1, i64 36
  store i32 %49, ptr %50, align 4, !tbaa !24
  store i8 1, ptr %2, align 1, !tbaa !5
  br label %51

51:                                               ; preds = %24, %20, %25
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZSt5equalIPKSt4byteS2_EbT_S3_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt5arrayISt4byteLm6EE6cbeginEv(ptr noundef nonnull align 1 dereferenceable(6)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt5arrayISt4byteLm6EE4cendEv(ptr noundef nonnull align 1 dereferenceable(6)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
declare dso_local noundef i64 @_ZNKSt5arrayISt4byteLm6EE4sizeEv(ptr noundef nonnull align 1 dereferenceable(6)) local_unnamed_addr #7 align 2

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

!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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS19charls_spiff_header", !11, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !13, i64 16, !12, i64 20, !14, i64 24, !15, i64 28, !12, i64 32, !12, i64 36}
!11 = !{!"_ZTSN6charls16spiff_profile_idE", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN6charls17spiff_color_spaceE", !7, i64 0}
!14 = !{!"_ZTSN6charls22spiff_compression_typeE", !7, i64 0}
!15 = !{!"_ZTSN6charls22spiff_resolution_unitsE", !7, i64 0}
!16 = !{!10, !12, i64 4}
!17 = !{!10, !12, i64 8}
!18 = !{!10, !12, i64 12}
!19 = !{!10, !13, i64 16}
!20 = !{!10, !12, i64 20}
!21 = !{!10, !14, i64 24}
!22 = !{!10, !15, i64 28}
!23 = !{!10, !12, i64 32}
!24 = !{!10, !12, i64 36}


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