; LLVM IR from ayush-tulsyan/ACM-ICPC-Handbook :: code/SuffixTree.ll (Z16extendSuffixTreei)

; 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.SuffixTreeNode = type { [256 x ptr], ptr, i32, ptr, i32 }

@text = external dso_local global [100 x i8], align 16
@root = external dso_local global ptr, align 8
@lastNewNode = external dso_local global ptr, align 8
@activeNode = external dso_local global ptr, align 8
@activeEdge = external dso_local global i32, align 4
@activeLength = external dso_local global i32, align 4
@remainingSuffixCount = external dso_local global i32, align 4
@leafEnd = external dso_local global i32, align 4
@splitEnd = external dso_local global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z7newNodeiPi(i32 noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z8walkDownP14SuffixTreeNode(ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z16extendSuffixTreei(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  %6 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %6, ptr @leafEnd, align 4, !tbaa !5
  %7 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %8 = add nsw i32 %7, 1
  store i32 %8, ptr @remainingSuffixCount, align 4, !tbaa !5
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %175, %147, %1
  %10 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %12, label %176

12:                                               ; preds = %9
  %13 = load i32, ptr @activeLength, align 4, !tbaa !5
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %12
  %16 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %16, ptr @activeEdge, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %15, %12
  %18 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.SuffixTreeNode, ptr %18, i32 0, i32 0
  %20 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = sext i8 %23 to i64
  %25 = getelementptr inbounds [256 x ptr], ptr %19, i64 0, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %46

28:                                               ; preds = %17
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = call noundef ptr @_Z7newNodeiPi(i32 noundef %29, ptr noundef @leafEnd)
  %31 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.SuffixTreeNode, ptr %31, i32 0, i32 0
  %33 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %37 = sext i8 %36 to i64
  %38 = getelementptr inbounds [256 x ptr], ptr %32, i64 0, i64 %37
  store ptr %30, ptr %38, align 8, !tbaa !9
  %39 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %45

41:                                               ; preds = %28
  %42 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %43 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.SuffixTreeNode, ptr %43, i32 0, i32 1
  store ptr %42, ptr %44, align 8, !tbaa !12
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %41, %28
  br label %150

46:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %47 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.SuffixTreeNode, ptr %47, i32 0, i32 0
  %49 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !11
  %53 = sext i8 %52 to i64
  %54 = getelementptr inbounds [256 x ptr], ptr %48, i64 0, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  store ptr %55, ptr %3, align 8, !tbaa !9
  %56 = load ptr, ptr %3, align 8, !tbaa !9
  %57 = call noundef i32 @_Z8walkDownP14SuffixTreeNode(ptr noundef %56)
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %46
  store i32 2, ptr %4, align 4
  br label %147, !llvm.loop !14

60:                                               ; preds = %46
  %61 = load ptr, ptr %3, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.SuffixTreeNode, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 8, !tbaa !16
  %64 = load i32, ptr @activeLength, align 4, !tbaa !5
  %65 = add nsw i32 %63, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !11
  %69 = sext i8 %68 to i32
  %70 = load i32, ptr %2, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %71
  %73 = load i8, ptr %72, align 1, !tbaa !11
  %74 = sext i8 %73 to i32
  %75 = icmp eq i32 %69, %74
  br i1 %75, label %76, label %90

76:                                               ; preds = %60
  %77 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %87

79:                                               ; preds = %76
  %80 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %81 = load ptr, ptr @root, align 8, !tbaa !9
  %82 = icmp ne ptr %80, %81
  br i1 %82, label %83, label %87

83:                                               ; preds = %79
  %84 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %85 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.SuffixTreeNode, ptr %85, i32 0, i32 1
  store ptr %84, ptr %86, align 8, !tbaa !12
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  br label %87

87:                                               ; preds = %83, %79, %76
  %88 = load i32, ptr @activeLength, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr @activeLength, align 4, !tbaa !5
  store i32 3, ptr %4, align 4
  br label %147

90:                                               ; preds = %60
  %91 = call noalias ptr @malloc(i64 noundef 4) #4
  store ptr %91, ptr @splitEnd, align 8, !tbaa !9
  %92 = load ptr, ptr %3, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct.SuffixTreeNode, ptr %92, i32 0, i32 2
  %94 = load i32, ptr %93, align 8, !tbaa !16
  %95 = load i32, ptr @activeLength, align 4, !tbaa !5
  %96 = add nsw i32 %94, %95
  %97 = sub nsw i32 %96, 1
  %98 = load ptr, ptr @splitEnd, align 8, !tbaa !9
  store i32 %97, ptr %98, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %99 = load ptr, ptr %3, align 8, !tbaa !9
  %100 = getelementptr inbounds %struct.SuffixTreeNode, ptr %99, i32 0, i32 2
  %101 = load i32, ptr %100, align 8, !tbaa !16
  %102 = load ptr, ptr @splitEnd, align 8, !tbaa !9
  %103 = call noundef ptr @_Z7newNodeiPi(i32 noundef %101, ptr noundef %102)
  store ptr %103, ptr %5, align 8, !tbaa !9
  %104 = load ptr, ptr %5, align 8, !tbaa !9
  %105 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %106 = getelementptr inbounds %struct.SuffixTreeNode, ptr %105, i32 0, i32 0
  %107 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %108
  %110 = load i8, ptr %109, align 1, !tbaa !11
  %111 = sext i8 %110 to i64
  %112 = getelementptr inbounds [256 x ptr], ptr %106, i64 0, i64 %111
  store ptr %104, ptr %112, align 8, !tbaa !9
  %113 = load i32, ptr %2, align 4, !tbaa !5
  %114 = call noundef ptr @_Z7newNodeiPi(i32 noundef %113, ptr noundef @leafEnd)
  %115 = load ptr, ptr %5, align 8, !tbaa !9
  %116 = getelementptr inbounds %struct.SuffixTreeNode, ptr %115, i32 0, i32 0
  %117 = load i32, ptr %2, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %118
  %120 = load i8, ptr %119, align 1, !tbaa !11
  %121 = sext i8 %120 to i64
  %122 = getelementptr inbounds [256 x ptr], ptr %116, i64 0, i64 %121
  store ptr %114, ptr %122, align 8, !tbaa !9
  %123 = load i32, ptr @activeLength, align 4, !tbaa !5
  %124 = load ptr, ptr %3, align 8, !tbaa !9
  %125 = getelementptr inbounds %struct.SuffixTreeNode, ptr %124, i32 0, i32 2
  %126 = load i32, ptr %125, align 8, !tbaa !16
  %127 = add nsw i32 %126, %123
  store i32 %127, ptr %125, align 8, !tbaa !16
  %128 = load ptr, ptr %3, align 8, !tbaa !9
  %129 = load ptr, ptr %5, align 8, !tbaa !9
  %130 = getelementptr inbounds %struct.SuffixTreeNode, ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %3, align 8, !tbaa !9
  %132 = getelementptr inbounds %struct.SuffixTreeNode, ptr %131, i32 0, i32 2
  %133 = load i32, ptr %132, align 8, !tbaa !16
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %134
  %136 = load i8, ptr %135, align 1, !tbaa !11
  %137 = sext i8 %136 to i64
  %138 = getelementptr inbounds [256 x ptr], ptr %130, i64 0, i64 %137
  store ptr %128, ptr %138, align 8, !tbaa !9
  %139 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %140 = icmp ne ptr %139, null
  br i1 %140, label %141, label %145

141:                                              ; preds = %90
  %142 = load ptr, ptr %5, align 8, !tbaa !9
  %143 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %144 = getelementptr inbounds %struct.SuffixTreeNode, ptr %143, i32 0, i32 1
  store ptr %142, ptr %144, align 8, !tbaa !12
  br label %145

145:                                              ; preds = %141, %90
  %146 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %146, ptr @lastNewNode, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  store i32 0, ptr %4, align 4
  br label %147

147:                                              ; preds = %145, %87, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %148 = load i32, ptr %4, align 4
  switch i32 %148, label %177 [
    i32 0, label %149
    i32 2, label %9
    i32 3, label %176
  ]

149:                                              ; preds = %147
  br label %150

150:                                              ; preds = %149, %45
  %151 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %152 = add nsw i32 %151, -1
  store i32 %152, ptr @remainingSuffixCount, align 4, !tbaa !5
  %153 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %154 = load ptr, ptr @root, align 8, !tbaa !9
  %155 = icmp eq ptr %153, %154
  br i1 %155, label %156, label %166

156:                                              ; preds = %150
  %157 = load i32, ptr @activeLength, align 4, !tbaa !5
  %158 = icmp sgt i32 %157, 0
  br i1 %158, label %159, label %166

159:                                              ; preds = %156
  %160 = load i32, ptr @activeLength, align 4, !tbaa !5
  %161 = add nsw i32 %160, -1
  store i32 %161, ptr @activeLength, align 4, !tbaa !5
  %162 = load i32, ptr %2, align 4, !tbaa !5
  %163 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %164 = sub nsw i32 %162, %163
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr @activeEdge, align 4, !tbaa !5
  br label %175

166:                                              ; preds = %156, %150
  %167 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %168 = load ptr, ptr @root, align 8, !tbaa !9
  %169 = icmp ne ptr %167, %168
  br i1 %169, label %170, label %174

170:                                              ; preds = %166
  %171 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %172 = getelementptr inbounds %struct.SuffixTreeNode, ptr %171, i32 0, i32 1
  %173 = load ptr, ptr %172, align 8, !tbaa !12
  store ptr %173, ptr @activeNode, align 8, !tbaa !9
  br label %174

174:                                              ; preds = %170, %166
  br label %175

175:                                              ; preds = %174, %159
  br label %9, !llvm.loop !14

176:                                              ; preds = %147, %9
  ret void

177:                                              ; preds = %147
  unreachable
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(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 }
attributes #4 = { nounwind allocsize(0) }

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 2048}
!13 = !{!"_ZTS14SuffixTreeNode", !7, i64 0, !10, i64 2048, !6, i64 2056, !10, i64 2064, !6, i64 2072}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !6, i64 2056}


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

@text = external dso_local local_unnamed_addr global [100 x i8], align 16
@root = external dso_local local_unnamed_addr global ptr, align 8
@lastNewNode = external dso_local local_unnamed_addr global ptr, align 8
@activeNode = external dso_local local_unnamed_addr global ptr, align 8
@activeEdge = external dso_local local_unnamed_addr global i32, align 4
@activeLength = external dso_local local_unnamed_addr global i32, align 4
@remainingSuffixCount = external dso_local local_unnamed_addr global i32, align 4
@leafEnd = external dso_local global i32, align 4
@splitEnd = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z7newNodeiPi(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z8walkDownP14SuffixTreeNode(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z16extendSuffixTreei(i32 noundef %0) local_unnamed_addr #0 {
  store i32 %0, ptr @leafEnd, align 4, !tbaa !5
  %2 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %3 = add nsw i32 %2, 1
  store i32 %3, ptr @remainingSuffixCount, align 4, !tbaa !5
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  %4 = icmp sgt i32 %2, -1
  br i1 %4, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %1
  %5 = sext i32 %0 to i64
  %6 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %5
  %.pre35 = load i32, ptr @activeLength, align 4, !tbaa !5
  br label %9

thread-pre-split:                                 ; preds = %.thread-pre-split_crit_edge, %88, %93, %92
  %.pr = phi i32 [ %.pr.pre, %.thread-pre-split_crit_edge ], [ %83, %88 ], [ %83, %93 ], [ %83, %92 ]
  %7 = phi i32 [ %.pre, %.thread-pre-split_crit_edge ], [ %89, %88 ], [ %86, %93 ], [ %86, %92 ]
  %8 = icmp sgt i32 %.pr, 0
  br i1 %8, label %9, label %.loopexit

9:                                                ; preds = %.lr.ph, %thread-pre-split
  %10 = phi i32 [ %.pre35, %.lr.ph ], [ %7, %thread-pre-split ]
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %._crit_edge

._crit_edge:                                      ; preds = %9
  %.pre36 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %.pre40 = sext i32 %.pre36 to i64
  br label %13

12:                                               ; preds = %9
  store i32 %0, ptr @activeEdge, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %._crit_edge, %12
  %.pre-phi = phi i64 [ %.pre40, %._crit_edge ], [ %5, %12 ]
  %14 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %15 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %.pre-phi
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = sext i8 %16 to i64
  %18 = getelementptr inbounds [256 x ptr], ptr %14, i64 0, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %33

21:                                               ; preds = %13
  %22 = tail call noundef ptr @_Z7newNodeiPi(i32 noundef %0, ptr noundef nonnull @leafEnd)
  %23 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %24 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !11
  %28 = sext i8 %27 to i64
  %29 = getelementptr inbounds [256 x ptr], ptr %23, i64 0, i64 %28
  store ptr %22, ptr %29, align 8, !tbaa !9
  %30 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %.not30 = icmp eq ptr %30, null
  %.pre38 = load ptr, ptr @activeNode, align 8, !tbaa !9
  br i1 %.not30, label %80, label %31

31:                                               ; preds = %21
  %32 = getelementptr inbounds i8, ptr %30, i64 2048
  store ptr %.pre38, ptr %32, align 8, !tbaa !12
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  br label %80

33:                                               ; preds = %13
  %34 = tail call noundef i32 @_Z8walkDownP14SuffixTreeNode(ptr noundef nonnull %19)
  %.not = icmp eq i32 %34, 0
  %.pre = load i32, ptr @activeLength, align 4, !tbaa !5
  br i1 %.not, label %35, label %.thread-pre-split_crit_edge, !llvm.loop !14

.thread-pre-split_crit_edge:                      ; preds = %33
  %.pr.pre = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  br label %thread-pre-split

35:                                               ; preds = %33
  %36 = getelementptr inbounds i8, ptr %19, i64 2056
  %37 = load i32, ptr %36, align 8, !tbaa !16
  %38 = add nsw i32 %.pre, %37
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = load i8, ptr %6, align 1, !tbaa !11
  %43 = icmp eq i8 %41, %42
  br i1 %43, label %44, label %51

44:                                               ; preds = %35
  %45 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %.not28 = icmp eq ptr %45, null
  br i1 %.not28, label %78, label %46

46:                                               ; preds = %44
  %47 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %48 = load ptr, ptr @root, align 8, !tbaa !9
  %.not29 = icmp eq ptr %47, %48
  br i1 %.not29, label %78, label %49

49:                                               ; preds = %46
  %50 = getelementptr inbounds i8, ptr %45, i64 2048
  store ptr %47, ptr %50, align 8, !tbaa !12
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  br label %78

51:                                               ; preds = %35
  %52 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #2
  store ptr %52, ptr @splitEnd, align 8, !tbaa !9
  %53 = add nsw i32 %38, -1
  store i32 %53, ptr %52, align 4, !tbaa !5
  %54 = load i32, ptr %36, align 8, !tbaa !16
  %55 = tail call noundef ptr @_Z7newNodeiPi(i32 noundef %54, ptr noundef nonnull %52)
  %56 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %57 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !11
  %61 = sext i8 %60 to i64
  %62 = getelementptr inbounds [256 x ptr], ptr %56, i64 0, i64 %61
  store ptr %55, ptr %62, align 8, !tbaa !9
  %63 = tail call noundef ptr @_Z7newNodeiPi(i32 noundef %0, ptr noundef nonnull @leafEnd)
  %64 = load i8, ptr %6, align 1, !tbaa !11
  %65 = sext i8 %64 to i64
  %66 = getelementptr inbounds [256 x ptr], ptr %55, i64 0, i64 %65
  store ptr %63, ptr %66, align 8, !tbaa !9
  %67 = load i32, ptr @activeLength, align 4, !tbaa !5
  %68 = load i32, ptr %36, align 8, !tbaa !16
  %69 = add nsw i32 %68, %67
  store i32 %69, ptr %36, align 8, !tbaa !16
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [100 x i8], ptr @text, i64 0, i64 %70
  %72 = load i8, ptr %71, align 1, !tbaa !11
  %73 = sext i8 %72 to i64
  %74 = getelementptr inbounds [256 x ptr], ptr %55, i64 0, i64 %73
  store ptr %19, ptr %74, align 8, !tbaa !9
  %75 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %.not27 = icmp eq ptr %75, null
  br i1 %.not27, label %.thread, label %76

76:                                               ; preds = %51
  %77 = getelementptr inbounds i8, ptr %75, i64 2048
  store ptr %55, ptr %77, align 8, !tbaa !12
  br label %.thread

.thread:                                          ; preds = %51, %76
  store ptr %55, ptr @lastNewNode, align 8, !tbaa !9
  %.pre37 = load ptr, ptr @activeNode, align 8, !tbaa !9
  br label %80

78:                                               ; preds = %44, %46, %49
  %79 = add nsw i32 %.pre, 1
  store i32 %79, ptr @activeLength, align 4, !tbaa !5
  br label %.loopexit

80:                                               ; preds = %.thread, %21, %31
  %81 = phi ptr [ %.pre37, %.thread ], [ %.pre38, %21 ], [ %.pre38, %31 ]
  %82 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %83 = add nsw i32 %82, -1
  store i32 %83, ptr @remainingSuffixCount, align 4, !tbaa !5
  %84 = load ptr, ptr @root, align 8, !tbaa !9
  %85 = icmp eq ptr %81, %84
  %86 = load i32, ptr @activeLength, align 4
  %87 = icmp sgt i32 %86, 0
  %or.cond = select i1 %85, i1 %87, i1 false
  br i1 %or.cond, label %88, label %92

88:                                               ; preds = %80
  %89 = add nsw i32 %86, -1
  store i32 %89, ptr @activeLength, align 4, !tbaa !5
  %90 = sub i32 %0, %82
  %91 = add i32 %90, 2
  store i32 %91, ptr @activeEdge, align 4, !tbaa !5
  br label %thread-pre-split, !llvm.loop !14

92:                                               ; preds = %80
  br i1 %85, label %thread-pre-split, label %93, !llvm.loop !14

93:                                               ; preds = %92
  %94 = getelementptr inbounds i8, ptr %81, i64 2048
  %95 = load ptr, ptr %94, align 8, !tbaa !12
  store ptr %95, ptr @activeNode, align 8, !tbaa !9
  br label %thread-pre-split, !llvm.loop !14

.loopexit:                                        ; preds = %thread-pre-split, %1, %78
  ret void
}

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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nounwind allocsize(0) }

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 2048}
!13 = !{!"_ZTS14SuffixTreeNode", !7, i64 0, !10, i64 2048, !6, i64 2056, !10, i64 2064, !6, i64 2072}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !6, i64 2056}


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