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

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

; 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 i32 @_ZN2ts11safe_string6lengthEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2ts7Scanner17isIdentifierStartE14CharacterCodesNS_12ScriptTargetE(ptr noundef nonnull align 8 dereferenceable(176), i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2ts7Scanner16isIdentifierPartE14CharacterCodesNS_12ScriptTargetENS_15LanguageVariantE(ptr noundef nonnull align 8 dereferenceable(176), i32 noundef, i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2ts7Scanner16isIdentifierTextERNS_11safe_stringENS_12ScriptTargetENS_15LanguageVariantE(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2, i32 noundef %3) #2 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  %13 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = call noundef i32 @_ZN2ts7Scanner11codePointAtERNS_11safe_stringEi(ptr noundef nonnull align 8 dereferenceable(176) %13, ptr noundef nonnull align 8 dereferenceable(32) %14, i32 noundef 0)
  store i32 %15, ptr %10, align 4, !tbaa !13
  %16 = load i32, ptr %10, align 4, !tbaa !13
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = call noundef zeroext i1 @_ZN2ts7Scanner17isIdentifierStartE14CharacterCodesNS_12ScriptTargetE(ptr noundef nonnull align 8 dereferenceable(176) %13, i32 noundef %16, i32 noundef %17)
  br i1 %18, label %20, label %19

19:                                               ; preds = %4
  store i1 false, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %46

20:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %21 = load i32, ptr %10, align 4, !tbaa !13
  %22 = call noundef i32 @_ZN2ts7Scanner8charSizeE14CharacterCodes(ptr noundef nonnull align 8 dereferenceable(176) %13, i32 noundef %21)
  store i32 %22, ptr %12, align 4, !tbaa !15
  br label %23

23:                                               ; preds = %38, %20
  %24 = load i32, ptr %12, align 4, !tbaa !15
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call noundef i32 @_ZN2ts11safe_string6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %25)
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %23
  store i32 2, ptr %11, align 4
  br label %43

29:                                               ; preds = %23
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load i32, ptr %12, align 4, !tbaa !15
  %32 = call noundef i32 @_ZN2ts7Scanner11codePointAtERNS_11safe_stringEi(ptr noundef nonnull align 8 dereferenceable(176) %13, ptr noundef nonnull align 8 dereferenceable(32) %30, i32 noundef %31)
  store i32 %32, ptr %10, align 4, !tbaa !13
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !11
  %35 = call noundef zeroext i1 @_ZN2ts7Scanner16isIdentifierPartE14CharacterCodesNS_12ScriptTargetENS_15LanguageVariantE(ptr noundef nonnull align 8 dereferenceable(176) %13, i32 noundef %32, i32 noundef %33, i32 noundef %34)
  br i1 %35, label %37, label %36

36:                                               ; preds = %29
  store i1 false, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %43

37:                                               ; preds = %29
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %10, align 4, !tbaa !13
  %40 = call noundef i32 @_ZN2ts7Scanner8charSizeE14CharacterCodes(ptr noundef nonnull align 8 dereferenceable(176) %13, i32 noundef %39)
  %41 = load i32, ptr %12, align 4, !tbaa !15
  %42 = add nsw i32 %41, %40
  store i32 %42, ptr %12, align 4, !tbaa !15
  br label %23, !llvm.loop !17

43:                                               ; preds = %36, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %44 = load i32, ptr %11, align 4
  switch i32 %44, label %46 [
    i32 2, label %45
  ]

45:                                               ; preds = %43
  store i1 true, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %46

46:                                               ; preds = %45, %43, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %47 = load i1, ptr %5, align 1
  ret i1 %47
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2ts7Scanner8charSizeE14CharacterCodes(ptr noundef nonnull align 8 dereferenceable(176), i32 noundef) #1 align 2

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, !10, i64 0}
!10 = !{!"_ZTSN2ts12ScriptTargetE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN2ts15LanguageVariantE", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTS14CharacterCodes", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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 i32 @_ZN2ts11safe_string6lengthEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2ts7Scanner17isIdentifierStartE14CharacterCodesNS_12ScriptTargetE(ptr noundef nonnull align 8 dereferenceable(176), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2ts7Scanner16isIdentifierPartE14CharacterCodesNS_12ScriptTargetENS_15LanguageVariantE(ptr noundef nonnull align 8 dereferenceable(176), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2ts7Scanner16isIdentifierTextERNS_11safe_stringENS_12ScriptTargetENS_15LanguageVariantE(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = tail call noundef i32 @_ZN2ts7Scanner11codePointAtERNS_11safe_stringEi(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 0)
  %6 = tail call noundef zeroext i1 @_ZN2ts7Scanner17isIdentifierStartE14CharacterCodesNS_12ScriptTargetE(ptr noundef nonnull align 8 dereferenceable(176) %0, i32 noundef %5, i32 noundef %2)
  br i1 %6, label %7, label %.loopexit

7:                                                ; preds = %4
  %8 = tail call noundef i32 @_ZN2ts7Scanner8charSizeE14CharacterCodes(ptr noundef nonnull align 8 dereferenceable(176) %0, i32 noundef %5)
  %9 = tail call noundef i32 @_ZN2ts11safe_string6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %.not16.not = icmp slt i32 %8, %9
  br i1 %.not16.not, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %7, %12
  %.017 = phi i32 [ %14, %12 ], [ %8, %7 ]
  %10 = tail call noundef i32 @_ZN2ts7Scanner11codePointAtERNS_11safe_stringEi(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %.017)
  %11 = tail call noundef zeroext i1 @_ZN2ts7Scanner16isIdentifierPartE14CharacterCodesNS_12ScriptTargetENS_15LanguageVariantE(ptr noundef nonnull align 8 dereferenceable(176) %0, i32 noundef %10, i32 noundef %2, i32 noundef %3)
  br i1 %11, label %12, label %.loopexit

12:                                               ; preds = %.lr.ph
  %13 = tail call noundef i32 @_ZN2ts7Scanner8charSizeE14CharacterCodes(ptr noundef nonnull align 8 dereferenceable(176) %0, i32 noundef %10)
  %14 = add nsw i32 %13, %.017
  %15 = tail call noundef i32 @_ZN2ts11safe_string6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %.not.not = icmp slt i32 %14, %15
  br i1 %.not.not, label %.lr.ph, label %.loopexit, !llvm.loop !5

.loopexit:                                        ; preds = %.lr.ph, %12, %7, %4
  %.1 = phi i1 [ false, %4 ], [ true, %7 ], [ %11, %12 ], [ %11, %.lr.ph ]
  ret i1 %.1
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2ts7Scanner11codePointAtERNS_11safe_stringEi(ptr noundef nonnull align 8 dereferenceable(176), ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2ts7Scanner8charSizeE14CharacterCodes(ptr noundef nonnull align 8 dereferenceable(176), i32 noundef) local_unnamed_addr #0 align 2

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

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass