; LLVM IR from ASDAlexander77/TypeScriptCompiler :: tsc/tsc-new-parser/scanner.ll (ZN2ts7Scanner18reScanGreaterTokenEv)

; 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.ts::Scanner" = type { i32, i32, i8, i32, %"struct.ts::safe_string", i32, i32, i32, i32, i32, %"class.std::__cxx11::basic_string", i32, %"class.std::vector.41", i32, i32, %"class.std::function" }
%"struct.ts::safe_string" = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<wchar_t>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<wchar_t>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::vector.41" = type { %"struct.std::_Vector_base.42" }
%"struct.std::_Vector_base.42" = type { %"struct.std::_Vector_base<ptr<ts::data::CommentDirective>, std::allocator<ptr<ts::data::CommentDirective>>>::_Vector_impl" }
%"struct.std::_Vector_base<ptr<ts::data::CommentDirective>, std::allocator<ptr<ts::data::CommentDirective>>>::_Vector_impl" = type { %"struct.std::_Vector_base<ptr<ts::data::CommentDirective>, std::allocator<ptr<ts::data::CommentDirective>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ptr<ts::data::CommentDirective>, std::allocator<ptr<ts::data::CommentDirective>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2ts7Scanner18reScanGreaterTokenEv(ptr noundef nonnull align 8 dereferenceable(176) %0) #0 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  %5 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 9
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = icmp eq i32 %6, 32
  br i1 %7, label %8, label %67

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 4
  %10 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %11 = load i32, ptr %10, align 8, !tbaa !29
  %12 = call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %9, i32 noundef %11)
  %13 = icmp eq i32 %12, 62
  br i1 %13, label %14, label %55

14:                                               ; preds = %8
  %15 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 4
  %16 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %17 = load i32, ptr %16, align 8, !tbaa !29
  %18 = add nsw i32 %17, 1
  %19 = call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %15, i32 noundef %18)
  %20 = icmp eq i32 %19, 62
  br i1 %20, label %21, label %38

21:                                               ; preds = %14
  %22 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 4
  %23 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %24 = load i32, ptr %23, align 8, !tbaa !29
  %25 = add nsw i32 %24, 2
  %26 = call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %22, i32 noundef %25)
  %27 = icmp eq i32 %26, 61
  br i1 %27, label %28, label %33

28:                                               ; preds = %21
  %29 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %30 = load i32, ptr %29, align 8, !tbaa !29
  %31 = add nsw i32 %30, 3
  store i32 %31, ptr %29, align 8, !tbaa !29
  %32 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 9
  store i32 73, ptr %32, align 8, !tbaa !9
  store i32 73, ptr %2, align 4
  br label %70

33:                                               ; preds = %21
  %34 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %35 = load i32, ptr %34, align 8, !tbaa !29
  %36 = add nsw i32 %35, 2
  store i32 %36, ptr %34, align 8, !tbaa !29
  %37 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 9
  store i32 50, ptr %37, align 8, !tbaa !9
  store i32 50, ptr %2, align 4
  br label %70

38:                                               ; preds = %14
  %39 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 4
  %40 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %41 = load i32, ptr %40, align 8, !tbaa !29
  %42 = add nsw i32 %41, 1
  %43 = call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %39, i32 noundef %42)
  %44 = icmp eq i32 %43, 61
  br i1 %44, label %45, label %50

45:                                               ; preds = %38
  %46 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %47 = load i32, ptr %46, align 8, !tbaa !29
  %48 = add nsw i32 %47, 2
  store i32 %48, ptr %46, align 8, !tbaa !29
  %49 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 9
  store i32 72, ptr %49, align 8, !tbaa !9
  store i32 72, ptr %2, align 4
  br label %70

50:                                               ; preds = %38
  %51 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %52 = load i32, ptr %51, align 8, !tbaa !29
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %51, align 8, !tbaa !29
  %54 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 9
  store i32 49, ptr %54, align 8, !tbaa !9
  store i32 49, ptr %2, align 4
  br label %70

55:                                               ; preds = %8
  %56 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 4
  %57 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %58 = load i32, ptr %57, align 8, !tbaa !29
  %59 = call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %56, i32 noundef %58)
  %60 = icmp eq i32 %59, 61
  br i1 %60, label %61, label %66

61:                                               ; preds = %55
  %62 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 5
  %63 = load i32, ptr %62, align 8, !tbaa !29
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %62, align 8, !tbaa !29
  %65 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 9
  store i32 34, ptr %65, align 8, !tbaa !9
  store i32 34, ptr %2, align 4
  br label %70

66:                                               ; preds = %55
  br label %67

67:                                               ; preds = %66, %1
  %68 = getelementptr inbounds %"class.ts::Scanner", ptr %4, i32 0, i32 9
  %69 = load i32, ptr %68, align 8, !tbaa !9
  store i32 %69, ptr %2, align 4
  br label %70

70:                                               ; preds = %67, %61, %50, %45, %33, %28
  %71 = load i32, ptr %2, align 4
  ret i32 %71
}

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

!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, !20, i64 64}
!10 = !{!"_ZTSN2ts7ScannerE", !11, i64 0, !12, i64 4, !13, i64 8, !14, i64 12, !15, i64 16, !19, i64 48, !19, i64 52, !19, i64 56, !19, i64 60, !20, i64 64, !16, i64 72, !21, i64 104, !22, i64 112, !19, i64 136, !26, i64 140, !27, i64 144}
!11 = !{!"_ZTSN2ts10ScriptKindE", !7, i64 0}
!12 = !{!"_ZTSN2ts12ScriptTargetE", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN2ts15LanguageVariantE", !7, i64 0}
!15 = !{!"_ZTSN2ts11safe_stringE", !16, i64 0}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!"_ZTS10SyntaxKind", !7, i64 0}
!21 = !{!"_ZTSN2ts10TokenFlagsE", !7, i64 0}
!22 = !{!"_ZTSSt6vectorI3ptrIN2ts4data16CommentDirectiveEESaIS4_EE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseI3ptrIN2ts4data16CommentDirectiveEESaIS4_EE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseI3ptrIN2ts4data16CommentDirectiveEESaIS4_EE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseI3ptrIN2ts4data16CommentDirectiveEESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!26 = !{!"_ZTSN2ts16JSDocParsingModeE", !7, i64 0}
!27 = !{!"_ZTSSt8functionIFv3ptrIN2ts4data17DiagnosticMessageEEiNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEEE", !28, i64 0, !6, i64 24}
!28 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!29 = !{!10, !19, i64 48}


; 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
declare dso_local noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2ts7Scanner18reScanGreaterTokenEv(ptr noundef nonnull align 8 dereferenceable(176) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp eq i32 %3, 32
  br i1 %4, label %5, label %41

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load i32, ptr %7, align 8, !tbaa !28
  %9 = tail call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef %8)
  %10 = icmp eq i32 %9, 62
  %11 = load i32, ptr %7, align 8, !tbaa !28
  br i1 %10, label %12, label %35

12:                                               ; preds = %5
  %13 = add nsw i32 %11, 1
  %14 = tail call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef %13)
  %15 = icmp eq i32 %14, 62
  %16 = load i32, ptr %7, align 8, !tbaa !28
  br i1 %15, label %17, label %26

17:                                               ; preds = %12
  %18 = add nsw i32 %16, 2
  %19 = tail call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef %18)
  %20 = icmp eq i32 %19, 61
  %21 = load i32, ptr %7, align 8, !tbaa !28
  br i1 %20, label %22, label %24

22:                                               ; preds = %17
  %23 = add nsw i32 %21, 3
  store i32 %23, ptr %7, align 8, !tbaa !28
  store i32 73, ptr %2, align 8, !tbaa !5
  br label %41

24:                                               ; preds = %17
  %25 = add nsw i32 %21, 2
  store i32 %25, ptr %7, align 8, !tbaa !28
  store i32 50, ptr %2, align 8, !tbaa !5
  br label %41

26:                                               ; preds = %12
  %27 = add nsw i32 %16, 1
  %28 = tail call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef %27)
  %29 = icmp eq i32 %28, 61
  %30 = load i32, ptr %7, align 8, !tbaa !28
  br i1 %29, label %31, label %33

31:                                               ; preds = %26
  %32 = add nsw i32 %30, 2
  store i32 %32, ptr %7, align 8, !tbaa !28
  store i32 72, ptr %2, align 8, !tbaa !5
  br label %41

33:                                               ; preds = %26
  %34 = add nsw i32 %30, 1
  store i32 %34, ptr %7, align 8, !tbaa !28
  store i32 49, ptr %2, align 8, !tbaa !5
  br label %41

35:                                               ; preds = %5
  %36 = tail call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef %11)
  %37 = icmp eq i32 %36, 61
  br i1 %37, label %38, label %._crit_edge

._crit_edge:                                      ; preds = %35
  %.pre = load i32, ptr %2, align 8, !tbaa !5
  br label %41

38:                                               ; preds = %35
  %39 = load i32, ptr %7, align 8, !tbaa !28
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %7, align 8, !tbaa !28
  store i32 34, ptr %2, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %1, %._crit_edge, %38, %33, %31, %24, %22
  %.0 = phi i32 [ 73, %22 ], [ 50, %24 ], [ 72, %31 ], [ 49, %33 ], [ 34, %38 ], [ %.pre, %._crit_edge ], [ %3, %1 ]
  ret i32 %.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" }

!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, !19, i64 64}
!6 = !{!"_ZTSN2ts7ScannerE", !7, i64 0, !10, i64 4, !11, i64 8, !12, i64 12, !13, i64 16, !18, i64 48, !18, i64 52, !18, i64 56, !18, i64 60, !19, i64 64, !14, i64 72, !20, i64 104, !21, i64 112, !18, i64 136, !25, i64 140, !26, i64 144}
!7 = !{!"_ZTSN2ts10ScriptKindE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN2ts12ScriptTargetE", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTSN2ts15LanguageVariantE", !8, i64 0}
!13 = !{!"_ZTSN2ts11safe_stringE", !14, i64 0}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE", !15, i64 0, !17, i64 8, !8, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE12_Alloc_hiderE", !16, i64 0}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!"long", !8, i64 0}
!18 = !{!"int", !8, i64 0}
!19 = !{!"_ZTS10SyntaxKind", !8, i64 0}
!20 = !{!"_ZTSN2ts10TokenFlagsE", !8, i64 0}
!21 = !{!"_ZTSSt6vectorI3ptrIN2ts4data16CommentDirectiveEESaIS4_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseI3ptrIN2ts4data16CommentDirectiveEESaIS4_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseI3ptrIN2ts4data16CommentDirectiveEESaIS4_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseI3ptrIN2ts4data16CommentDirectiveEESaIS4_EE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!25 = !{!"_ZTSN2ts16JSDocParsingModeE", !8, i64 0}
!26 = !{!"_ZTSSt8functionIFv3ptrIN2ts4data17DiagnosticMessageEEiNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEEE", !27, i64 0, !16, i64 24}
!27 = !{!"_ZTSSt14_Function_base", !8, i64 0, !16, i64 16}
!28 = !{!6, !18, i64 48}


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