; LLVM IR from vczh/herodb :: Kernel/Source/Vlpp.ll (ZN2vl6stream10LzwDecoder24ExpandCodeToOutputBufferEPNS0_3lzw4CodeE)

; 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.vl::stream::LzwDecoder" = type { %"class.vl::stream::LzwBase", %"class.vl::stream::IDecoder", ptr, %"class.vl::collections::List.22", ptr, [1024 x i8], i64, i64, %"class.vl::collections::Array.39", i64, i64 }
%"class.vl::stream::LzwBase" = type { %"class.vl::Object", %"class.vl::collections::PushOnlyAllocator", %"class.vl::collections::PushOnlyAllocator.30", ptr, i64, i64, i64 }
%"class.vl::Object" = type { ptr }
%"class.vl::collections::PushOnlyAllocator" = type { %"class.vl::Object", i64, i64, %"class.vl::collections::List.22" }
%"class.vl::collections::PushOnlyAllocator.30" = type { %"class.vl::Object", i64, i64, %"class.vl::collections::List.31" }
%"class.vl::collections::List.31" = type { %"class.vl::collections::ListBase.base.37", %"class.vl::collections::IEnumerable.35" }
%"class.vl::collections::ListBase.base.37" = type <{ %"class.vl::collections::ArrayBase.base.36", i64, i8 }>
%"class.vl::collections::ArrayBase.base.36" = type { %"class.vl::collections::ListStore.34", ptr, i64 }
%"class.vl::collections::ListStore.34" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.35" = type { %"class.vl::Interface" }
%"class.vl::Interface" = type { ptr }
%"class.vl::stream::IDecoder" = type { %"class.vl::Interface" }
%"class.vl::collections::List.22" = type { %"class.vl::collections::ListBase.base.28", %"class.vl::collections::IEnumerable.26" }
%"class.vl::collections::ListBase.base.28" = type <{ %"class.vl::collections::ArrayBase.base.27", i64, i8 }>
%"class.vl::collections::ArrayBase.base.27" = type { %"class.vl::collections::ListStore.25", ptr, i64 }
%"class.vl::collections::ListStore.25" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.26" = type { %"class.vl::Interface" }
%"class.vl::collections::Array.39" = type { %"class.vl::collections::ArrayBase.base.43", %"class.vl::collections::IEnumerable.42" }
%"class.vl::collections::ArrayBase.base.43" = type { %"class.vl::collections::ListStore.41", ptr, i64 }
%"class.vl::collections::ListStore.41" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.42" = type { %"class.vl::Interface" }
%"struct.vl::stream::lzw::Code" = type { i8, i64, ptr, i64, %"class.vl::collections::ByteObjectMap" }
%"class.vl::collections::ByteObjectMap" = type { %"class.vl::Object", ptr }

; 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: mustprogress uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN2vl11collections5ArrayIhhEixEl(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl6stream10LzwDecoder24ExpandCodeToOutputBufferEPNS0_3lzw4CodeE(ptr noundef nonnull align 8 dereferenceable(1344) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %8 = getelementptr inbounds %"class.vl::stream::LzwDecoder", ptr %7, i32 0, i32 8
  %9 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN2vl11collections5ArrayIhhEixEl(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef 0)
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.vl::stream::lzw::Code", ptr %10, i32 0, i32 3
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %9, i64 %12
  store ptr %13, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %14, ptr %6, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %20, %2
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.vl::stream::LzwBase", ptr %7, i32 0, i32 3
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = icmp ne ptr %16, %18
  br i1 %19, label %20, label %29

20:                                               ; preds = %15
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.vl::stream::lzw::Code", ptr %21, i32 0, i32 0
  %23 = load i8, ptr %22, align 8, !tbaa !27
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i32 -1
  store ptr %25, ptr %5, align 8, !tbaa !5
  store i8 %23, ptr %25, align 1, !tbaa !28
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.vl::stream::lzw::Code", ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !29
  store ptr %28, ptr %6, align 8, !tbaa !5
  br label %15, !llvm.loop !30

29:                                               ; preds = %15
  %30 = getelementptr inbounds %"class.vl::stream::LzwDecoder", ptr %7, i32 0, i32 10
  store i64 0, ptr %30, align 8, !tbaa !32
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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++ TBAA"}
!9 = !{!10, !11, i64 24}
!10 = !{!"_ZTSN2vl6stream3lzw4CodeE", !7, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !12, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTSN2vl11collections13ByteObjectMapINS_6stream3lzw4CodeEEE", !13, i64 0, !6, i64 8}
!13 = !{!"_ZTSN2vl6ObjectE"}
!14 = !{!15, !6, i64 152}
!15 = !{!"_ZTSN2vl6stream7LzwBaseE", !13, i64 0, !16, i64 8, !22, i64 80, !6, i64 152, !11, i64 160, !11, i64 168, !11, i64 176}
!16 = !{!"_ZTSN2vl11collections17PushOnlyAllocatorINS_6stream3lzw4CodeEEE", !13, i64 0, !11, i64 8, !11, i64 16, !17, i64 24}
!17 = !{!"_ZTSN2vl11collections4ListIPNS_6stream3lzw4CodeES5_EE", !18, i64 0}
!18 = !{!"_ZTSN2vl11collections8ListBaseIPNS_6stream3lzw4CodeES5_EE", !19, i64 0, !11, i64 24, !21, i64 32}
!19 = !{!"_ZTSN2vl11collections9ArrayBaseIPNS_6stream3lzw4CodeEEE", !20, i64 0, !6, i64 8, !11, i64 16}
!20 = !{!"_ZTSN2vl11collections9ListStoreIPNS_6stream3lzw4CodeELb1EEE", !13, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{!"_ZTSN2vl11collections17PushOnlyAllocatorINS0_10bom_helper8TreeNodeEEE", !13, i64 0, !11, i64 8, !11, i64 16, !23, i64 24}
!23 = !{!"_ZTSN2vl11collections4ListIPNS0_10bom_helper8TreeNodeES4_EE", !24, i64 0}
!24 = !{!"_ZTSN2vl11collections8ListBaseIPNS0_10bom_helper8TreeNodeES4_EE", !25, i64 0, !11, i64 24, !21, i64 32}
!25 = !{!"_ZTSN2vl11collections9ArrayBaseIPNS0_10bom_helper8TreeNodeEEE", !26, i64 0, !6, i64 8, !11, i64 16}
!26 = !{!"_ZTSN2vl11collections9ListStoreIPNS0_10bom_helper8TreeNodeELb1EEE", !13, i64 0}
!27 = !{!10, !7, i64 0}
!28 = !{!7, !7, i64 0}
!29 = !{!10, !6, i64 16}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = !{!33, !11, i64 1336}
!33 = !{!"_ZTSN2vl6stream10LzwDecoderE", !15, i64 0, !34, i64 184, !6, i64 192, !17, i64 200, !6, i64 248, !7, i64 256, !11, i64 1280, !11, i64 1288, !36, i64 1296, !11, i64 1328, !11, i64 1336}
!34 = !{!"_ZTSN2vl6stream8IDecoderE", !35, i64 0}
!35 = !{!"_ZTSN2vl9InterfaceE"}
!36 = !{!"_ZTSN2vl11collections5ArrayIhhEE", !37, i64 0}
!37 = !{!"_ZTSN2vl11collections9ArrayBaseIhEE", !38, i64 0, !6, i64 8, !11, i64 16}
!38 = !{!"_ZTSN2vl11collections9ListStoreIhLb1EEE", !13, i64 0}


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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN2vl11collections5ArrayIhhEixEl(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl6stream10LzwDecoder24ExpandCodeToOutputBufferEPNS0_3lzw4CodeE(ptr noundef nonnull align 8 dereferenceable(1344) %0, ptr noundef readonly %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 1296
  %4 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZN2vl11collections5ArrayIhhEixEl(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef 0)
  %5 = getelementptr inbounds i8, ptr %0, i64 152
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not8 = icmp eq ptr %6, %1
  br i1 %.not8, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load i64, ptr %7, align 8, !tbaa !23
  %9 = getelementptr inbounds i8, ptr %4, i64 %8
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.010 = phi ptr [ %13, %.lr.ph ], [ %1, %.lr.ph.preheader ]
  %.079 = phi ptr [ %11, %.lr.ph ], [ %9, %.lr.ph.preheader ]
  %10 = load i8, ptr %.010, align 8, !tbaa !26
  %11 = getelementptr inbounds i8, ptr %.079, i64 -1
  store i8 %10, ptr %11, align 1, !tbaa !27
  %12 = getelementptr inbounds i8, ptr %.010, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !28
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %13, %14
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !29

._crit_edge:                                      ; preds = %.lr.ph, %2
  %15 = getelementptr inbounds i8, ptr %0, i64 1336
  store i64 0, ptr %15, align 8, !tbaa !31
  ret void
}

attributes #0 = { 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" }

!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, !16, i64 152}
!6 = !{!"_ZTSN2vl6stream7LzwBaseE", !7, i64 0, !8, i64 8, !18, i64 80, !16, i64 152, !9, i64 160, !9, i64 168, !9, i64 176}
!7 = !{!"_ZTSN2vl6ObjectE"}
!8 = !{!"_ZTSN2vl11collections17PushOnlyAllocatorINS_6stream3lzw4CodeEEE", !7, i64 0, !9, i64 8, !9, i64 16, !12, i64 24}
!9 = !{!"long", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN2vl11collections4ListIPNS_6stream3lzw4CodeES5_EE", !13, i64 0}
!13 = !{!"_ZTSN2vl11collections8ListBaseIPNS_6stream3lzw4CodeES5_EE", !14, i64 0, !9, i64 24, !17, i64 32}
!14 = !{!"_ZTSN2vl11collections9ArrayBaseIPNS_6stream3lzw4CodeEEE", !15, i64 0, !16, i64 8, !9, i64 16}
!15 = !{!"_ZTSN2vl11collections9ListStoreIPNS_6stream3lzw4CodeELb1EEE", !7, i64 0}
!16 = !{!"any pointer", !10, i64 0}
!17 = !{!"bool", !10, i64 0}
!18 = !{!"_ZTSN2vl11collections17PushOnlyAllocatorINS0_10bom_helper8TreeNodeEEE", !7, i64 0, !9, i64 8, !9, i64 16, !19, i64 24}
!19 = !{!"_ZTSN2vl11collections4ListIPNS0_10bom_helper8TreeNodeES4_EE", !20, i64 0}
!20 = !{!"_ZTSN2vl11collections8ListBaseIPNS0_10bom_helper8TreeNodeES4_EE", !21, i64 0, !9, i64 24, !17, i64 32}
!21 = !{!"_ZTSN2vl11collections9ArrayBaseIPNS0_10bom_helper8TreeNodeEEE", !22, i64 0, !16, i64 8, !9, i64 16}
!22 = !{!"_ZTSN2vl11collections9ListStoreIPNS0_10bom_helper8TreeNodeELb1EEE", !7, i64 0}
!23 = !{!24, !9, i64 24}
!24 = !{!"_ZTSN2vl6stream3lzw4CodeE", !10, i64 0, !9, i64 8, !16, i64 16, !9, i64 24, !25, i64 32}
!25 = !{!"_ZTSN2vl11collections13ByteObjectMapINS_6stream3lzw4CodeEEE", !7, i64 0, !16, i64 8}
!26 = !{!24, !10, i64 0}
!27 = !{!10, !10, i64 0}
!28 = !{!24, !16, i64 16}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!32, !9, i64 1336}
!32 = !{!"_ZTSN2vl6stream10LzwDecoderE", !6, i64 0, !33, i64 184, !16, i64 192, !12, i64 200, !16, i64 248, !10, i64 256, !9, i64 1280, !9, i64 1288, !35, i64 1296, !9, i64 1328, !9, i64 1336}
!33 = !{!"_ZTSN2vl6stream8IDecoderE", !34, i64 0}
!34 = !{!"_ZTSN2vl9InterfaceE"}
!35 = !{!"_ZTSN2vl11collections5ArrayIhhEE", !36, i64 0}
!36 = !{!"_ZTSN2vl11collections9ArrayBaseIhEE", !37, i64 0, !16, i64 8, !9, i64 16}
!37 = !{!"_ZTSN2vl11collections9ListStoreIhLb1EEE", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass