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

; 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::CacheStream" = type { %"class.vl::Object", ptr, i64, i64, i64, ptr, i64, i64, i64, i64, %"class.vl::stream::IStream" }
%"class.vl::Object" = type { ptr }
%"class.vl::stream::IStream" = type { %"class.vl::Interface" }
%"class.vl::Interface" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN2vl6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl6stream11CacheStreamC2ERNS0_7IStreamEl(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2, i64 noundef %3) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  %12 = load ptr, ptr %6, align 8
  call void @_ZN2vl6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  %13 = load ptr, ptr %12, align 8
  store ptr %13, ptr %11, align 8, !tbaa !11
  %14 = getelementptr inbounds ptr, ptr %12, i64 1
  %15 = load ptr, ptr %14, align 8
  %16 = load ptr, ptr %11, align 8, !tbaa !11
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr %11, i64 %18
  store ptr %15, ptr %19, align 8, !tbaa !11
  %20 = getelementptr inbounds ptr, ptr %12, i64 2
  %21 = load ptr, ptr %20, align 8
  %22 = load ptr, ptr %11, align 8, !tbaa !11
  %23 = getelementptr i8, ptr %22, i64 -32
  %24 = load i64, ptr %23, align 8
  %25 = getelementptr inbounds i8, ptr %11, i64 %24
  store ptr %21, ptr %25, align 8, !tbaa !11
  %26 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 1
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %27, ptr %26, align 8, !tbaa !13
  %28 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 2
  %29 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %29, ptr %28, align 8, !tbaa !16
  %30 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 3
  store i64 0, ptr %30, align 8, !tbaa !17
  %31 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 4
  store i64 0, ptr %31, align 8, !tbaa !18
  %32 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 6
  store i64 0, ptr %32, align 8, !tbaa !19
  %33 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 7
  store i64 0, ptr %33, align 8, !tbaa !20
  %34 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 8
  store i64 0, ptr %34, align 8, !tbaa !21
  %35 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 9
  store i64 0, ptr %35, align 8, !tbaa !22
  %36 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 2
  %37 = load i64, ptr %36, align 8, !tbaa !16
  %38 = icmp sle i64 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %4
  %40 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 2
  store i64 65536, ptr %40, align 8, !tbaa !16
  br label %41

41:                                               ; preds = %39, %4
  %42 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 2
  %43 = load i64, ptr %42, align 8, !tbaa !16
  %44 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %43) #5
          to label %45 unwind label %47

45:                                               ; preds = %41
  %46 = getelementptr inbounds %"class.vl::stream::CacheStream", ptr %11, i32 0, i32 5
  store ptr %44, ptr %46, align 8, !tbaa !23
  ret void

47:                                               ; preds = %41
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %9, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %10, align 4
  call void @_ZN2vl6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  br label %51

51:                                               ; preds = %47
  %52 = load ptr, ptr %9, align 8
  %53 = load i32, ptr %10, align 4
  %54 = insertvalue { ptr, i32 } poison, ptr %52, 0
  %55 = insertvalue { ptr, i32 } %54, i32 %53, 1
  resume { ptr, i32 } %55
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

attributes #0 = { inlinehint 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 #1 = { nobuiltin allocsize(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 = { 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 = { nounwind }
attributes #5 = { builtin allocsize(0) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTSN2vl6stream11CacheStreamE", !15, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!15 = !{!"_ZTSN2vl6ObjectE"}
!16 = !{!14, !10, i64 16}
!17 = !{!14, !10, i64 24}
!18 = !{!14, !10, i64 32}
!19 = !{!14, !10, i64 48}
!20 = !{!14, !10, i64 56}
!21 = !{!14, !10, i64 64}
!22 = !{!14, !10, i64 72}
!23 = !{!14, !6, i64 40}


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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN2vl6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl6stream11CacheStreamC2ERNS0_7IStreamEl(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr nocapture noundef readonly %1, ptr noundef nonnull align 8 dereferenceable(8) %2, i64 noundef %3) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN2vl6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  %5 = load ptr, ptr %1, align 8
  store ptr %5, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load ptr, ptr %6, align 8
  %8 = getelementptr i8, ptr %5, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr %0, i64 %9
  store ptr %7, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  %12 = load ptr, ptr %11, align 8
  %13 = load ptr, ptr %0, align 8, !tbaa !5
  %14 = getelementptr i8, ptr %13, i64 -32
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr %0, i64 %15
  store ptr %12, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %2, ptr %17, align 8, !tbaa !8
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %3, ptr %18, align 8, !tbaa !14
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  %21 = icmp slt i64 %3, 1
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %19, i8 0, i64 16, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %20, i8 0, i64 32, i1 false)
  br i1 %21, label %22, label %23

22:                                               ; preds = %4
  store i64 65536, ptr %18, align 8, !tbaa !14
  br label %23

23:                                               ; preds = %22, %4
  %24 = phi i64 [ 65536, %22 ], [ %3, %4 ]
  %25 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %24) #6
          to label %26 unwind label %28

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %25, ptr %27, align 8, !tbaa !15
  ret void

28:                                               ; preds = %23
  %29 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN2vl6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  resume { ptr, i32 } %29
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 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

attributes #0 = { inlinehint 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 #1 = { nobuiltin allocsize(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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"_ZTSN2vl6stream11CacheStreamE", !10, i64 0, !11, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !11, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72}
!10 = !{!"_ZTSN2vl6ObjectE"}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"long", !12, i64 0}
!14 = !{!9, !13, i64 16}
!15 = !{!9, !11, i64 40}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass