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

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

@_ZN2vl10reflection11description17globalTypeManagerE = external dso_local global ptr, align 8
@_ZN2vl10reflection11description28initializedGlobalTypeManagerE = external dso_local global i8, align 1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2vl10reflection11description20GetGlobalTypeManagerEv() #2 personality ptr @__gxx_personality_v0 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = load i8, ptr @_ZN2vl10reflection11description28initializedGlobalTypeManagerE, align 1, !tbaa !5, !range !9, !noundef !10
  %4 = trunc i8 %3 to i1
  br i1 %4, label %17, label %5

5:                                                ; preds = %0
  store i8 1, ptr @_ZN2vl10reflection11description28initializedGlobalTypeManagerE, align 1, !tbaa !5
  %6 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 192) #3
  invoke void @_ZN2vl10reflection11description11TypeManagerC1Ev(ptr noundef nonnull align 8 dereferenceable(185) %6)
          to label %7 unwind label %13

7:                                                ; preds = %5
  %8 = icmp eq ptr %6, null
  br i1 %8, label %11, label %9

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %6, i64 8
  br label %11

11:                                               ; preds = %9, %7
  %12 = phi ptr [ %10, %9 ], [ null, %7 ]
  store ptr %12, ptr @_ZN2vl10reflection11description17globalTypeManagerE, align 8, !tbaa !11
  br label %17

13:                                               ; preds = %5
  %14 = landingpad { ptr, i32 }
          cleanup
  %15 = extractvalue { ptr, i32 } %14, 0
  store ptr %15, ptr %1, align 8
  %16 = extractvalue { ptr, i32 } %14, 1
  store i32 %16, ptr %2, align 4
  call void @_ZdlPvm(ptr noundef %6, i64 noundef 192) #4
  br label %19

17:                                               ; preds = %11, %0
  %18 = load ptr, ptr @_ZN2vl10reflection11description17globalTypeManagerE, align 8, !tbaa !11
  ret ptr %18

19:                                               ; preds = %13
  %20 = load ptr, ptr %1, align 8
  %21 = load i32, ptr %2, align 4
  %22 = insertvalue { ptr, i32 } poison, ptr %20, 0
  %23 = insertvalue { ptr, i32 } %22, i32 %21, 1
  resume { ptr, i32 } %23
}

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

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 = { 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 = { builtin allocsize(0) }
attributes #4 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, 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"

@_ZN2vl10reflection11description17globalTypeManagerE = external dso_local local_unnamed_addr global ptr, align 8
@_ZN2vl10reflection11description28initializedGlobalTypeManagerE = external dso_local local_unnamed_addr global i8, align 1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2vl10reflection11description20GetGlobalTypeManagerEv() local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %1 = load i8, ptr @_ZN2vl10reflection11description28initializedGlobalTypeManagerE, align 1, !tbaa !5, !range !9, !noundef !10
  %2 = trunc nuw i8 %1 to i1
  br i1 %2, label %._crit_edge, label %3

._crit_edge:                                      ; preds = %0
  %.pre = load ptr, ptr @_ZN2vl10reflection11description17globalTypeManagerE, align 8, !tbaa !11
  br label %9

3:                                                ; preds = %0
  store i8 1, ptr @_ZN2vl10reflection11description28initializedGlobalTypeManagerE, align 1, !tbaa !5
  %4 = tail call noalias noundef nonnull dereferenceable(192) ptr @_Znwm(i64 noundef 192) #3
  invoke void @_ZN2vl10reflection11description11TypeManagerC1Ev(ptr noundef nonnull align 8 dereferenceable(185) %4)
          to label %5 unwind label %7

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %6, ptr @_ZN2vl10reflection11description17globalTypeManagerE, align 8, !tbaa !11
  br label %9

7:                                                ; preds = %3
  %8 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %4, i64 noundef 192) #4
  resume { ptr, i32 } %8

9:                                                ; preds = %._crit_edge, %5
  %10 = phi ptr [ %.pre, %._crit_edge ], [ %6, %5 ]
  ret ptr %10
}

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

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 = { 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 = { builtin allocsize(0) }
attributes #4 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass