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

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

@_ZN2ts7Scanner25mergeConflictMarkerLengthE = external dso_local global i32, align 4

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN2tsL5debugEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2ts7Scanner22isConflictMarkerTriviaERNS_11safe_stringEi(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2) #2 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = icmp sge i32 %12, 0
  call void @_ZN2tsL5debugEb(i1 noundef zeroext %13)
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %22, label %16

16:                                               ; preds = %3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = sub nsw i32 %18, 1
  %20 = call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %17, i32 noundef %19)
  %21 = call noundef zeroext i1 @_ZN2ts7Scanner11isLineBreakE14CharacterCodes(ptr noundef nonnull align 8 dereferenceable(176) %11, i32 noundef %20)
  br i1 %21, label %22, label %69

22:                                               ; preds = %16, %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %23, i32 noundef %24)
  store i32 %25, ptr %8, align 4, !tbaa !11
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = load i32, ptr @_ZN2ts7Scanner25mergeConflictMarkerLengthE, align 4, !tbaa !9
  %28 = add nsw i32 %26, %27
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call noundef i32 @_ZN2ts11safe_string6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %29)
  %31 = icmp slt i32 %28, %30
  br i1 %31, label %32, label %65

32:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %48, %32
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = load i32, ptr @_ZN2ts7Scanner25mergeConflictMarkerLengthE, align 4, !tbaa !9
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  store i32 2, ptr %10, align 4
  br label %51

38:                                               ; preds = %33
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = add nsw i32 %40, %41
  %43 = call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %39, i32 noundef %42)
  %44 = load i32, ptr %8, align 4, !tbaa !11
  %45 = icmp ne i32 %43, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %38
  store i1 false, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %51

47:                                               ; preds = %38
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %9, align 4, !tbaa !9
  br label %33, !llvm.loop !13

51:                                               ; preds = %46, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %52 = load i32, ptr %10, align 4
  switch i32 %52, label %66 [
    i32 2, label %53
  ]

53:                                               ; preds = %51
  %54 = load i32, ptr %8, align 4, !tbaa !11
  %55 = icmp eq i32 %54, 61
  br i1 %55, label %63, label %56

56:                                               ; preds = %53
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = load i32, ptr @_ZN2ts7Scanner25mergeConflictMarkerLengthE, align 4, !tbaa !9
  %60 = add nsw i32 %58, %59
  %61 = call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %57, i32 noundef %60)
  %62 = icmp eq i32 %61, 32
  br label %63

63:                                               ; preds = %56, %53
  %64 = phi i1 [ true, %53 ], [ %62, %56 ]
  store i1 %64, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %66

65:                                               ; preds = %22
  store i32 0, ptr %10, align 4
  br label %66

66:                                               ; preds = %65, %63, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %67 = load i32, ptr %10, align 4
  switch i32 %67, label %72 [
    i32 0, label %68
    i32 1, label %70
  ]

68:                                               ; preds = %66
  br label %69

69:                                               ; preds = %68, %16
  store i1 false, ptr %4, align 1
  br label %70

70:                                               ; preds = %69, %66
  %71 = load i1, ptr %4, align 1
  ret i1 %71

72:                                               ; preds = %66
  unreachable
}

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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS14CharacterCodes", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@_ZN2ts7Scanner25mergeConflictMarkerLengthE = external dso_local local_unnamed_addr global i32, align 4

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN2tsL5debugEb(i1 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2ts7Scanner22isConflictMarkerTriviaERNS_11safe_stringEi(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = icmp sgt i32 %2, -1
  tail call void @_ZN2tsL5debugEb(i1 noundef zeroext %4)
  %5 = icmp eq i32 %2, 0
  br i1 %5, label %10, label %6

6:                                                ; preds = %3
  %7 = add nsw i32 %2, -1
  %8 = tail call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %7)
  %9 = tail call noundef zeroext i1 @_ZN2ts7Scanner11isLineBreakE14CharacterCodes(ptr noundef nonnull align 8 dereferenceable(176) %0, i32 noundef %8)
  br i1 %9, label %10, label %.loopexit

10:                                               ; preds = %6, %3
  %11 = tail call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2)
  %12 = load i32, ptr @_ZN2ts7Scanner25mergeConflictMarkerLengthE, align 4, !tbaa !5
  %13 = add nsw i32 %12, %2
  %14 = tail call noundef i32 @_ZN2ts11safe_string6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %.not27 = icmp slt i32 %13, %14
  br i1 %.not27, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %10
  %15 = load i32, ptr @_ZN2ts7Scanner25mergeConflictMarkerLengthE, align 4, !tbaa !5
  %.not2428 = icmp sgt i32 %15, 0
  br i1 %.not2428, label %.lr.ph, label %.critedge

16:                                               ; preds = %.lr.ph
  %17 = add nuw nsw i32 %.02029, 1
  %18 = load i32, ptr @_ZN2ts7Scanner25mergeConflictMarkerLengthE, align 4, !tbaa !5
  %.not24 = icmp slt i32 %17, %18
  br i1 %.not24, label %.lr.ph, label %.critedge, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader, %16
  %.02029 = phi i32 [ %17, %16 ], [ 0, %.preheader ]
  %19 = add nsw i32 %.02029, %2
  %20 = tail call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %19)
  %.not = icmp eq i32 %20, %11
  br i1 %.not, label %16, label %.loopexit

.critedge:                                        ; preds = %16, %.preheader
  %21 = phi i32 [ %15, %.preheader ], [ %18, %16 ]
  %22 = icmp eq i32 %11, 61
  br i1 %22, label %.loopexit, label %23

23:                                               ; preds = %.critedge
  %24 = add nsw i32 %21, %2
  %25 = tail call noundef i32 @_ZN2ts11safe_stringixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %24)
  %26 = icmp eq i32 %25, 32
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %6, %10, %23, %.critedge
  %.2 = phi i1 [ true, %.critedge ], [ %26, %23 ], [ false, %10 ], [ false, %6 ], [ false, %.lr.ph ]
  ret i1 %.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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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