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

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

%"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: mustprogress uwtable
define dso_local void @_ZN6charls18jpeg_stream_reader17frame_info_heightEjb(ptr noundef nonnull align 8 dereferenceable(192) %0, i32 noundef %1, i1 noundef zeroext %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %7 = zext i1 %2 to i8
  store i8 %7, ptr %6, align 1, !tbaa !11
  %8 = load ptr, ptr %4, align 8
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %15

11:                                               ; preds = %3
  %12 = load i8, ptr %6, align 1, !tbaa !11, !range !13, !noundef !14
  %13 = trunc i8 %12 to i1
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  br label %35

15:                                               ; preds = %11, %3
  %16 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 3
  %17 = getelementptr inbounds %struct.charls_frame_info, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !15
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %23, label %20

20:                                               ; preds = %15
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = icmp eq i32 %21, 0
  br label %23

23:                                               ; preds = %20, %15
  %24 = phi i1 [ true, %15 ], [ %22, %20 ]
  %25 = xor i1 %24, true
  %26 = xor i1 %25, true
  %27 = zext i1 %26 to i64
  %28 = call i64 @llvm.expect.i64(i64 %27, i64 0)
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %23
  call void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef 30) #3
  unreachable

31:                                               ; preds = %23
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = getelementptr inbounds %"class.charls::jpeg_stream_reader", ptr %8, i32 0, i32 3
  %34 = getelementptr inbounds %struct.charls_frame_info, ptr %33, i32 0, i32 1
  store i32 %32, ptr %34, align 4, !tbaa !15
  br label %35

35:                                               ; preds = %31, %14
  ret void
}

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 = { 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 = { 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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !10, i64 36}
!16 = !{!"_ZTSN6charls18jpeg_stream_readerE", !6, i64 0, !6, i64 8, !17, i64 16, !19, i64 32, !20, i64 48, !23, i64 64, !24, i64 88, !28, i64 112, !32, i64 136, !10, i64 140, !10, i64 144, !21, i64 148, !12, i64 152, !33, i64 156, !34, i64 160, !35, i64 176}
!17 = !{!"_ZTSN6charls4spanIKSt4byteEE", !6, i64 0, !18, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTS17charls_frame_info", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!20 = !{!"_ZTSN6charls17coding_parametersE", !10, i64 0, !10, i64 4, !21, i64 8, !22, i64 12}
!21 = !{!"_ZTSN6charls15interleave_modeE", !7, i64 0}
!22 = !{!"_ZTSN6charls20color_transformationE", !7, i64 0}
!23 = !{!"_ZTS27charls_jpegls_pc_parameters", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!24 = !{!"_ZTSSt6vectorIN6charls18jpeg_stream_reader14component_infoESaIS2_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIN6charls18jpeg_stream_reader14component_infoESaIS2_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader14component_infoESaIS2_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader14component_infoESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!"_ZTSSt6vectorIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE", !29, i64 0}
!29 = !{!"_ZTSSt12_Vector_baseIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE12_Vector_implE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIN6charls18jpeg_stream_reader19mapping_table_entryESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!32 = !{!"_ZTSN6charls18jpeg_stream_reader5stateE", !7, i64 0}
!33 = !{!"_ZTSN6charls22compressed_data_formatE", !7, i64 0}
!34 = !{!"_ZTSN6charls17callback_functionIPFiPKvmPvEEE", !6, i64 0, !6, i64 8}
!35 = !{!"_ZTSN6charls17callback_functionIPFiiPKvmPvEEE", !6, i64 0, !6, i64 8}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6charls18jpeg_stream_reader17frame_info_heightEjb(ptr nocapture noundef nonnull align 8 dereferenceable(192) %0, i32 noundef %1, i1 noundef zeroext %2) local_unnamed_addr #1 align 2 {
  %4 = icmp eq i32 %1, 0
  %.not = xor i1 %4, true
  %brmerge = or i1 %.not, %2
  br i1 %brmerge, label %5, label %12

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 36
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp ne i32 %7, 0
  %9 = or i1 %4, %8
  br i1 %9, label %10, label %11, !prof !31

10:                                               ; preds = %5
  tail call void @_ZN6charls4impl18throw_jpegls_errorENS_11jpegls_errcE(i32 noundef 30) #2
  unreachable

11:                                               ; preds = %5
  store i32 %1, ptr %6, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %3, %11
  ret void
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LowerExpectIntrinsicPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass