; 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::StdQualifiedName" = type { %"class.llvh::itanium_demangle::Node.base", ptr }
%"struct.llvh::itanium_demangle::NestedName" = type { %"class.llvh::itanium_demangle::Node.base", 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 }

; 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
define dso_local noundef ptr @_ZNK4llvh23ItaniumPartialDemangler19getFunctionBaseNameEPcPm(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1, ptr noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  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
  %9 = load ptr, ptr %5, align 8
  %10 = call noundef zeroext i1 @_ZNK4llvh23ItaniumPartialDemangler10isFunctionEv(ptr noundef nonnull align 8 dereferenceable(16) %9)
  br i1 %10, label %12, label %11

11:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  br label %46

12:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %13 = getelementptr inbounds %"struct.llvh::ItaniumPartialDemangler", ptr %9, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = call noundef ptr @_ZNK4llvh16itanium_demangle16FunctionEncoding7getNameEv(ptr noundef nonnull align 8 dereferenceable(64) %14)
  store ptr %15, ptr %8, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %37, %33, %29, %25, %21, %12
  br label %17

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

21:                                               ; preds = %17
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.llvh::itanium_demangle::AbiTagAttr", ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  store ptr %24, ptr %8, align 8, !tbaa !5
  br label %16, !llvm.loop !17

25:                                               ; preds = %17
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.llvh::itanium_demangle::StdQualifiedName", ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !19
  store ptr %28, ptr %8, align 8, !tbaa !5
  br label %16, !llvm.loop !17

29:                                               ; preds = %17
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.llvh::itanium_demangle::NestedName", ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !21
  store ptr %32, ptr %8, align 8, !tbaa !5
  br label %16, !llvm.loop !17

33:                                               ; preds = %17
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.llvh::itanium_demangle::LocalName", ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !23
  store ptr %36, ptr %8, align 8, !tbaa !5
  br label %16, !llvm.loop !17

37:                                               ; preds = %17
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.llvh::itanium_demangle::NameWithTemplateArgs", ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !25
  store ptr %40, ptr %8, align 8, !tbaa !5
  br label %16, !llvm.loop !17

41:                                               ; preds = %17
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = call noundef ptr @_ZL9printNodePKN4llvh16itanium_demangle4NodeEPcPm(ptr noundef %42, ptr noundef %43, ptr noundef %44)
  store ptr %45, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %46

46:                                               ; preds = %41, %11
  %47 = load ptr, ptr %4, align 8
  ret ptr %47
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4llvh23ItaniumPartialDemangler10isFunctionEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL9printNodePKN4llvh16itanium_demangle4NodeEPcPm(ptr noundef, ptr noundef, ptr noundef) #1

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 = { 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 #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 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !6, i64 16}
!20 = !{!"_ZTSN4llvh16itanium_demangle16StdQualifiedNameE", !13, i64 0, !6, i64 16}
!21 = !{!22, !6, i64 24}
!22 = !{!"_ZTSN4llvh16itanium_demangle10NestedNameE", !13, i64 0, !6, i64 16, !6, i64 24}
!23 = !{!24, !6, i64 24}
!24 = !{!"_ZTSN4llvh16itanium_demangle9LocalNameE", !13, i64 0, !6, i64 16, !6, i64 24}
!25 = !{!26, !6, i64 16}
!26 = !{!"_ZTSN4llvh16itanium_demangle20NameWithTemplateArgsE", !13, i64 0, !6, i64 16, !6, i64 24}


; 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
define dso_local noundef ptr @_ZNK4llvh23ItaniumPartialDemangler19getFunctionBaseNameEPcPm(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 align 2 {
  %4 = tail call noundef zeroext i1 @_ZNK4llvh23ItaniumPartialDemangler10isFunctionEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  br i1 %4, label %5, label %15

5:                                                ; preds = %3
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = tail call noundef ptr @_ZNK4llvh16itanium_demangle16FunctionEncoding7getNameEv(ptr noundef nonnull align 8 dereferenceable(64) %6)
  br label %8

8:                                                ; preds = %.backedge, %5
  %.0 = phi ptr [ %7, %5 ], [ %.0.be, %.backedge ]
  %9 = tail call noundef zeroext i8 @_ZNK4llvh16itanium_demangle4Node7getKindEv(ptr noundef nonnull align 8 dereferenceable(12) %.0)
  switch i8 %9, label %13 [
    i8 8, label %.backedge
    i8 34, label %.backedge
    i8 23, label %11
    i8 24, label %12
    i8 32, label %.backedge
  ]

.backedge:                                        ; preds = %8, %8, %8, %11, %12
  %.sink = phi i64 [ 24, %11 ], [ 24, %12 ], [ 16, %8 ], [ 16, %8 ], [ 16, %8 ]
  %10 = getelementptr inbounds i8, ptr %.0, i64 %.sink
  %.0.be = load ptr, ptr %10, align 8, !tbaa !10
  br label %8, !llvm.loop !11

11:                                               ; preds = %8
  br label %.backedge

12:                                               ; preds = %8
  br label %.backedge

13:                                               ; preds = %8
  %14 = tail call noundef ptr @_ZL9printNodePKN4llvh16itanium_demangle4NodeEPcPm(ptr noundef nonnull %.0, ptr noundef %1, ptr noundef %2)
  br label %15

15:                                               ; preds = %3, %13
  %.011 = phi ptr [ %14, %13 ], [ null, %3 ]
  ret ptr %.011
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4llvh23ItaniumPartialDemangler10isFunctionEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL9printNodePKN4llvh16itanium_demangle4NodeEPcPm(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

!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 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass