; LLVM IR from facebook/hermes :: external/llvh/lib/Demangle (ItaniumDemangle)

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

%"struct.llvh::ItaniumPartialDemangler" = type { ptr, ptr }
%"struct.llvh::itanium_demangle::AbiTagAttr" = type { %"class.llvh::itanium_demangle::Node.base", ptr, %class.StringView }
%"class.llvh::itanium_demangle::Node.base" = type <{ ptr, i8, i8, i8, i8 }>
%class.StringView = type { ptr, ptr }
%"struct.llvh::itanium_demangle::LocalName" = type { %"class.llvh::itanium_demangle::Node.base", ptr, ptr }
%"struct.llvh::itanium_demangle::NameWithTemplateArgs" = type { %"class.llvh::itanium_demangle::Node.base", ptr, ptr }
%"struct.llvh::itanium_demangle::NestedName" = type { %"class.llvh::itanium_demangle::Node.base", ptr, ptr }
%"struct.llvh::itanium_demangle::StdQualifiedName" = type { %"class.llvh::itanium_demangle::Node.base", 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 nounwind uwtable
declare dso_local noundef ptr @_ZNK4llvh16itanium_demangle16FunctionEncoding7getNameEv(ptr noundef nonnull align 8 dereferenceable(64)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK4llvh16itanium_demangle4Node7getKindEv(ptr noundef nonnull align 8 dereferenceable(12)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK4llvh23ItaniumPartialDemangler12isCtorOrDtorEv(ptr noundef nonnull align 8 dereferenceable(16) %0) #2 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %7 = getelementptr inbounds %"struct.llvh::ItaniumPartialDemangler", ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %8, ptr %4, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %41, %1
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %42

12:                                               ; preds = %9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call noundef zeroext i8 @_ZNK4llvh16itanium_demangle4Node7getKindEv(ptr noundef nonnull align 8 dereferenceable(12) %13)
  %15 = zext i8 %14 to i32
  switch i32 %15, label %16 [
    i32 37, label %17
    i32 8, label %18
    i32 18, label %22
    i32 24, label %25
    i32 32, label %29
    i32 23, label %33
    i32 34, label %37
  ]

16:                                               ; preds = %12
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %43

17:                                               ; preds = %12
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %43

18:                                               ; preds = %12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.llvh::itanium_demangle::AbiTagAttr", ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  store ptr %21, ptr %4, align 8, !tbaa !5
  br label %41

22:                                               ; preds = %12
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call noundef ptr @_ZNK4llvh16itanium_demangle16FunctionEncoding7getNameEv(ptr noundef nonnull align 8 dereferenceable(64) %23)
  store ptr %24, ptr %4, align 8, !tbaa !5
  br label %41

25:                                               ; preds = %12
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.llvh::itanium_demangle::LocalName", ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  store ptr %28, ptr %4, align 8, !tbaa !5
  br label %41

29:                                               ; preds = %12
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.llvh::itanium_demangle::NameWithTemplateArgs", ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  store ptr %32, ptr %4, align 8, !tbaa !5
  br label %41

33:                                               ; preds = %12
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.llvh::itanium_demangle::NestedName", ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !21
  store ptr %36, ptr %4, align 8, !tbaa !5
  br label %41

37:                                               ; preds = %12
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.llvh::itanium_demangle::StdQualifiedName", ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !23
  store ptr %40, ptr %4, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %37, %33, %29, %25, %22, %18
  br label %9, !llvm.loop !25

42:                                               ; preds = %9
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %43

43:                                               ; preds = %42, %17, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %44 = load i1, ptr %2, align 1
  ret i1 %44
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !6, i64 0}
!10 = !{!"_ZTSN4llvh23ItaniumPartialDemanglerE", !6, i64 0, !6, i64 8}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTSN4llvh16itanium_demangle10AbiTagAttrE", !13, i64 0, !6, i64 16, !16, i64 24}
!13 = !{!"_ZTSN4llvh16itanium_demangle4NodeE", !14, i64 8, !15, i64 9, !15, i64 10, !15, i64 11}
!14 = !{!"_ZTSN4llvh16itanium_demangle4Node4KindE", !7, i64 0}
!15 = !{!"_ZTSN4llvh16itanium_demangle4Node5CacheE", !7, i64 0}
!16 = !{!"_ZTS10StringView", !6, i64 0, !6, i64 8}
!17 = !{!18, !6, i64 24}
!18 = !{!"_ZTSN4llvh16itanium_demangle9LocalNameE", !13, i64 0, !6, i64 16, !6, i64 24}
!19 = !{!20, !6, i64 16}
!20 = !{!"_ZTSN4llvh16itanium_demangle20NameWithTemplateArgsE", !13, i64 0, !6, i64 16, !6, i64 24}
!21 = !{!22, !6, i64 24}
!22 = !{!"_ZTSN4llvh16itanium_demangle10NestedNameE", !13, i64 0, !6, i64 16, !6, i64 24}
!23 = !{!24, !6, i64 16}
!24 = !{!"_ZTSN4llvh16itanium_demangle16StdQualifiedNameE", !13, i64 0, !6, i64 16}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; 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 nounwind uwtable
declare dso_local noundef ptr @_ZNK4llvh16itanium_demangle16FunctionEncoding7getNameEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK4llvh16itanium_demangle4Node7getKindEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK4llvh23ItaniumPartialDemangler12isCtorOrDtorEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0) local_unnamed_addr #0 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not11 = icmp eq ptr %2, null
  br i1 %.not11, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %1, %21
  %.012 = phi ptr [ %.1, %21 ], [ %2, %1 ]
  %3 = tail call noundef zeroext i8 @_ZNK4llvh16itanium_demangle4Node7getKindEv(ptr noundef nonnull align 8 dereferenceable(12) %.012)
  switch i8 %3, label %.loopexit.loopexit [
    i8 37, label %.loopexit
    i8 8, label %4
    i8 18, label %7
    i8 24, label %9
    i8 32, label %12
    i8 23, label %15
    i8 34, label %18
  ]

4:                                                ; preds = %.lr.ph
  %5 = getelementptr inbounds i8, ptr %.012, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !10
  br label %21

7:                                                ; preds = %.lr.ph
  %8 = tail call noundef ptr @_ZNK4llvh16itanium_demangle16FunctionEncoding7getNameEv(ptr noundef nonnull align 8 dereferenceable(64) %.012)
  br label %21

9:                                                ; preds = %.lr.ph
  %10 = getelementptr inbounds i8, ptr %.012, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  br label %21

12:                                               ; preds = %.lr.ph
  %13 = getelementptr inbounds i8, ptr %.012, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !18
  br label %21

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds i8, ptr %.012, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !20
  br label %21

18:                                               ; preds = %.lr.ph
  %19 = getelementptr inbounds i8, ptr %.012, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !22
  br label %21

21:                                               ; preds = %18, %15, %12, %9, %7, %4
  %.1 = phi ptr [ %20, %18 ], [ %17, %15 ], [ %14, %12 ], [ %11, %9 ], [ %8, %7 ], [ %6, %4 ]
  %.not = icmp eq ptr %.1, null
  br i1 %.not, label %.loopexit.loopexit, label %.lr.ph, !llvm.loop !24

.loopexit.loopexit:                               ; preds = %21, %.lr.ph
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.loopexit.loopexit, %1
  %.010 = phi i1 [ false, %1 ], [ false, %.loopexit.loopexit ], [ true, %.lr.ph ]
  ret i1 %.010
}

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

!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, !7, i64 0}
!6 = !{!"_ZTSN4llvh23ItaniumPartialDemanglerE", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 16}
!11 = !{!"_ZTSN4llvh16itanium_demangle10AbiTagAttrE", !12, i64 0, !7, i64 16, !15, i64 24}
!12 = !{!"_ZTSN4llvh16itanium_demangle4NodeE", !13, i64 8, !14, i64 9, !14, i64 10, !14, i64 11}
!13 = !{!"_ZTSN4llvh16itanium_demangle4Node4KindE", !8, i64 0}
!14 = !{!"_ZTSN4llvh16itanium_demangle4Node5CacheE", !8, i64 0}
!15 = !{!"_ZTS10StringView", !7, i64 0, !7, i64 8}
!16 = !{!17, !7, i64 24}
!17 = !{!"_ZTSN4llvh16itanium_demangle9LocalNameE", !12, i64 0, !7, i64 16, !7, i64 24}
!18 = !{!19, !7, i64 16}
!19 = !{!"_ZTSN4llvh16itanium_demangle20NameWithTemplateArgsE", !12, i64 0, !7, i64 16, !7, i64 24}
!20 = !{!21, !7, i64 24}
!21 = !{!"_ZTSN4llvh16itanium_demangle10NestedNameE", !12, i64 0, !7, i64 16, !7, i64 24}
!22 = !{!23, !7, i64 16}
!23 = !{!"_ZTSN4llvh16itanium_demangle16StdQualifiedNameE", !12, i64 0, !7, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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