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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #0

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl7parsing3xml18XmlGetParserBufferERNS_6stream12MemoryStreamE(ptr noundef nonnull align 8 dereferenceable(48)) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl7parsing3xml12XmlLoadTableEv(ptr dead_on_unwind noalias writable sret(%"class.vl::Ptr.61") align 8 %0) #3 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.vl::stream::MemoryStream", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i1, align 1
  store ptr %0, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr %3) #5
  call void @_ZN2vl6stream12MemoryStreamC1El(ptr noundef nonnull align 8 dereferenceable(48) %3, i64 noundef 65536)
  invoke void @_ZN2vl7parsing3xml18XmlGetParserBufferERNS_6stream12MemoryStreamE(ptr noundef nonnull align 8 dereferenceable(48) %3)
          to label %7 unwind label %20

7:                                                ; preds = %1
  store i1 false, ptr %6, align 1
  %8 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 656) #6
          to label %9 unwind label %20

9:                                                ; preds = %7
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr i8, ptr %10, i64 -24
  %12 = load i64, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr %3, i64 %12
  invoke void @_ZN2vl7parsing7tabling12ParsingTableC1ERNS_6stream7IStreamE(ptr noundef nonnull align 8 dereferenceable(656) %8, ptr noundef nonnull align 8 dereferenceable(8) %13)
          to label %14 unwind label %24

14:                                               ; preds = %9
  invoke void @_ZN2vl3PtrINS_7parsing7tabling12ParsingTableEEC2EPS3_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %8)
          to label %15 unwind label %20

15:                                               ; preds = %14
  %16 = invoke noundef ptr @_ZNK2vl3PtrINS_7parsing7tabling12ParsingTableEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
          to label %17 unwind label %28

17:                                               ; preds = %15
  invoke void @_ZN2vl7parsing7tabling12ParsingTable10InitializeEv(ptr noundef nonnull align 8 dereferenceable(656) %16)
          to label %18 unwind label %28

18:                                               ; preds = %17
  store i1 true, ptr %6, align 1
  %19 = load i1, ptr %6, align 1
  br i1 %19, label %33, label %32

20:                                               ; preds = %14, %7, %1
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %4, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %5, align 4
  br label %34

24:                                               ; preds = %9
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %4, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %8, i64 noundef 656) #7
  br label %34

28:                                               ; preds = %17, %15
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %4, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %5, align 4
  call void @_ZN2vl3PtrINS_7parsing7tabling12ParsingTableEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #5
  br label %34

32:                                               ; preds = %18
  call void @_ZN2vl3PtrINS_7parsing7tabling12ParsingTableEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #5
  br label %33

33:                                               ; preds = %32, %18
  call void @_ZN2vl6stream12MemoryStreamD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr %3) #5
  ret void

34:                                               ; preds = %28, %24, %20
  call void @_ZN2vl6stream12MemoryStreamD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr %3) #5
  br label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr %4, align 8
  %37 = load i32, ptr %5, align 4
  %38 = insertvalue { ptr, i32 } poison, ptr %36, 0
  %39 = insertvalue { ptr, i32 } %38, i32 %37, 1
  resume { ptr, i32 } %39
}

declare void @_ZN2vl7parsing7tabling12ParsingTableC1ERNS_6stream7IStreamE(ptr, ptr)

attributes #0 = { nobuiltin 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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

%"class.vl::Ptr.61" = type { ptr, ptr, ptr, ptr }
%"class.vl::stream::MemoryStream" = type { %"class.vl::Object", i64, ptr, 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 }

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2vl3PtrINS_7parsing7tabling12ParsingTableEEptEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl7parsing7tabling12ParsingTable10InitializeEv(ptr noundef nonnull align 8 dereferenceable(656)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl7parsing3xml18XmlGetParserBufferERNS_6stream12MemoryStreamE(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl7parsing3xml12XmlLoadTableEv(ptr dead_on_unwind noalias writable sret(%"class.vl::Ptr.61") align 8 %0) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.vl::stream::MemoryStream", align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %2) #5
  call void @_ZN2vl6stream12MemoryStreamC1El(ptr noundef nonnull align 8 dereferenceable(48) %2, i64 noundef 65536)
  invoke void @_ZN2vl7parsing3xml18XmlGetParserBufferERNS_6stream12MemoryStreamE(ptr noundef nonnull align 8 dereferenceable(48) %2)
          to label %3 unwind label %13

3:                                                ; preds = %1
  %4 = invoke noalias noundef nonnull dereferenceable(656) ptr @_Znwm(i64 noundef 656) #6
          to label %5 unwind label %13

5:                                                ; preds = %3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr i8, ptr %6, i64 -24
  %8 = load i64, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr %2, i64 %8
  invoke void @_ZN2vl7parsing7tabling12ParsingTableC1ERNS_6stream7IStreamE(ptr noundef nonnull align 8 dereferenceable(656) %4, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %10 unwind label %15

10:                                               ; preds = %5
  invoke void @_ZN2vl3PtrINS_7parsing7tabling12ParsingTableEEC2EPS3_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull %4)
          to label %11 unwind label %13

11:                                               ; preds = %10
  %12 = call noundef ptr @_ZNK2vl3PtrINS_7parsing7tabling12ParsingTableEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  invoke void @_ZN2vl7parsing7tabling12ParsingTable10InitializeEv(ptr noundef nonnull align 8 dereferenceable(656) %12)
          to label %19 unwind label %17

13:                                               ; preds = %10, %3, %1
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %20

15:                                               ; preds = %5
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvm(ptr noundef nonnull %4, i64 noundef 656) #7
  br label %20

17:                                               ; preds = %11
  %18 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN2vl3PtrINS_7parsing7tabling12ParsingTableEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #5
  br label %20

19:                                               ; preds = %11
  call void @_ZN2vl6stream12MemoryStreamD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %2) #5
  ret void

20:                                               ; preds = %17, %15, %13
  %.pn = phi { ptr, i32 } [ %18, %17 ], [ %14, %13 ], [ %16, %15 ]
  call void @_ZN2vl6stream12MemoryStreamD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %2) #5
  resume { ptr, i32 } %.pn
}

declare void @_ZN2vl7parsing7tabling12ParsingTableC1ERNS_6stream7IStreamE(ptr, ptr) local_unnamed_addr

attributes #0 = { nobuiltin 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass