; LLVM IR from AlgoGenesis/C :: Searching Algorithms/Ukkonen's Algorithm (Program)

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

@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
@text = external dso_local global [1000 x i8], align 16

; Function Attrs: nounwind uwtable
declare dso_local ptr @newNode(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: nounwind uwtable
define dso_local void @extendSuffixTree(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  %7 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %7, ptr @leafEnd, align 4, !tbaa !5
  %8 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr @remainingSuffixCount, align 4, !tbaa !5
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %192, %164, %1
  %11 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %13, label %193

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

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

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

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

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

46:                                               ; preds = %42, %29
  br label %167

47:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %48 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.SuffixTreeNode, ptr %48, i32 0, i32 0
  %50 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = sext i8 %53 to i64
  %55 = getelementptr inbounds [256 x ptr], ptr %49, i64 0, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  store ptr %56, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %57 = load ptr, ptr %3, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.SuffixTreeNode, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !14
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %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 !15
  %64 = sub nsw i32 %60, %63
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %4, align 4, !tbaa !5
  %66 = load i32, ptr @activeLength, align 4, !tbaa !5
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = icmp sge i32 %66, %67
  br i1 %68, label %69, label %77

69:                                               ; preds = %47
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %72 = add nsw i32 %71, %70
  store i32 %72, ptr @activeEdge, align 4, !tbaa !5
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = load i32, ptr @activeLength, align 4, !tbaa !5
  %75 = sub nsw i32 %74, %73
  store i32 %75, ptr @activeLength, align 4, !tbaa !5
  %76 = load ptr, ptr %3, align 8, !tbaa !9
  store ptr %76, ptr @activeNode, align 8, !tbaa !9
  store i32 2, ptr %5, align 4
  br label %164, !llvm.loop !16

77:                                               ; preds = %47
  %78 = load ptr, ptr %3, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.SuffixTreeNode, ptr %78, i32 0, i32 2
  %80 = load i32, ptr %79, align 8, !tbaa !15
  %81 = load i32, ptr @activeLength, align 4, !tbaa !5
  %82 = add nsw i32 %80, %81
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %83
  %85 = load i8, ptr %84, align 1, !tbaa !11
  %86 = sext i8 %85 to i32
  %87 = load i32, ptr %2, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !11
  %91 = sext i8 %90 to i32
  %92 = icmp eq i32 %86, %91
  br i1 %92, label %93, label %107

93:                                               ; preds = %77
  %94 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %95 = icmp ne ptr %94, null
  br i1 %95, label %96, label %104

96:                                               ; preds = %93
  %97 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %98 = load ptr, ptr @root, align 8, !tbaa !9
  %99 = icmp ne ptr %97, %98
  br i1 %99, label %100, label %104

100:                                              ; preds = %96
  %101 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %102 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %103 = getelementptr inbounds %struct.SuffixTreeNode, ptr %102, i32 0, i32 1
  store ptr %101, ptr %103, align 8, !tbaa !12
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  br label %104

104:                                              ; preds = %100, %96, %93
  %105 = load i32, ptr @activeLength, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr @activeLength, align 4, !tbaa !5
  store i32 3, ptr %5, align 4
  br label %164

107:                                              ; preds = %77
  %108 = call noalias ptr @malloc(i64 noundef 4) #4
  store ptr %108, ptr @splitEnd, align 8, !tbaa !9
  %109 = load ptr, ptr %3, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct.SuffixTreeNode, ptr %109, i32 0, i32 2
  %111 = load i32, ptr %110, align 8, !tbaa !15
  %112 = load i32, ptr @activeLength, align 4, !tbaa !5
  %113 = add nsw i32 %111, %112
  %114 = sub nsw i32 %113, 1
  %115 = load ptr, ptr @splitEnd, align 8, !tbaa !9
  store i32 %114, ptr %115, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %116 = load ptr, ptr %3, align 8, !tbaa !9
  %117 = getelementptr inbounds %struct.SuffixTreeNode, ptr %116, i32 0, i32 2
  %118 = load i32, ptr %117, align 8, !tbaa !15
  %119 = load ptr, ptr @splitEnd, align 8, !tbaa !9
  %120 = call ptr @newNode(i32 noundef %118, ptr noundef %119)
  store ptr %120, ptr %6, align 8, !tbaa !9
  %121 = load ptr, ptr %6, align 8, !tbaa !9
  %122 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %123 = getelementptr inbounds %struct.SuffixTreeNode, ptr %122, i32 0, i32 0
  %124 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %125
  %127 = load i8, ptr %126, align 1, !tbaa !11
  %128 = sext i8 %127 to i64
  %129 = getelementptr inbounds [256 x ptr], ptr %123, i64 0, i64 %128
  store ptr %121, ptr %129, align 8, !tbaa !9
  %130 = load i32, ptr %2, align 4, !tbaa !5
  %131 = call ptr @newNode(i32 noundef %130, ptr noundef @leafEnd)
  %132 = load ptr, ptr %6, align 8, !tbaa !9
  %133 = getelementptr inbounds %struct.SuffixTreeNode, ptr %132, i32 0, i32 0
  %134 = load i32, ptr %2, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %135
  %137 = load i8, ptr %136, align 1, !tbaa !11
  %138 = sext i8 %137 to i64
  %139 = getelementptr inbounds [256 x ptr], ptr %133, i64 0, i64 %138
  store ptr %131, ptr %139, align 8, !tbaa !9
  %140 = load i32, ptr @activeLength, align 4, !tbaa !5
  %141 = load ptr, ptr %3, align 8, !tbaa !9
  %142 = getelementptr inbounds %struct.SuffixTreeNode, ptr %141, i32 0, i32 2
  %143 = load i32, ptr %142, align 8, !tbaa !15
  %144 = add nsw i32 %143, %140
  store i32 %144, ptr %142, align 8, !tbaa !15
  %145 = load ptr, ptr %3, align 8, !tbaa !9
  %146 = load ptr, ptr %6, align 8, !tbaa !9
  %147 = getelementptr inbounds %struct.SuffixTreeNode, ptr %146, i32 0, i32 0
  %148 = load ptr, ptr %3, align 8, !tbaa !9
  %149 = getelementptr inbounds %struct.SuffixTreeNode, ptr %148, i32 0, i32 2
  %150 = load i32, ptr %149, align 8, !tbaa !15
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %151
  %153 = load i8, ptr %152, align 1, !tbaa !11
  %154 = sext i8 %153 to i64
  %155 = getelementptr inbounds [256 x ptr], ptr %147, i64 0, i64 %154
  store ptr %145, ptr %155, align 8, !tbaa !9
  %156 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %157 = icmp ne ptr %156, null
  br i1 %157, label %158, label %162

158:                                              ; preds = %107
  %159 = load ptr, ptr %6, align 8, !tbaa !9
  %160 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %161 = getelementptr inbounds %struct.SuffixTreeNode, ptr %160, i32 0, i32 1
  store ptr %159, ptr %161, align 8, !tbaa !12
  br label %162

162:                                              ; preds = %158, %107
  %163 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %163, ptr @lastNewNode, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  store i32 0, ptr %5, align 4
  br label %164

164:                                              ; preds = %162, %104, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %165 = load i32, ptr %5, align 4
  switch i32 %165, label %194 [
    i32 0, label %166
    i32 2, label %10
    i32 3, label %193
  ]

166:                                              ; preds = %164
  br label %167

167:                                              ; preds = %166, %46
  %168 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %169 = add nsw i32 %168, -1
  store i32 %169, ptr @remainingSuffixCount, align 4, !tbaa !5
  %170 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %171 = load ptr, ptr @root, align 8, !tbaa !9
  %172 = icmp eq ptr %170, %171
  br i1 %172, label %173, label %183

173:                                              ; preds = %167
  %174 = load i32, ptr @activeLength, align 4, !tbaa !5
  %175 = icmp sgt i32 %174, 0
  br i1 %175, label %176, label %183

176:                                              ; preds = %173
  %177 = load i32, ptr @activeLength, align 4, !tbaa !5
  %178 = add nsw i32 %177, -1
  store i32 %178, ptr @activeLength, align 4, !tbaa !5
  %179 = load i32, ptr %2, align 4, !tbaa !5
  %180 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %181 = sub nsw i32 %179, %180
  %182 = add nsw i32 %181, 1
  store i32 %182, ptr @activeEdge, align 4, !tbaa !5
  br label %192

183:                                              ; preds = %173, %167
  %184 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %185 = load ptr, ptr @root, align 8, !tbaa !9
  %186 = icmp ne ptr %184, %185
  br i1 %186, label %187, label %191

187:                                              ; preds = %183
  %188 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %189 = getelementptr inbounds %struct.SuffixTreeNode, ptr %188, i32 0, i32 1
  %190 = load ptr, ptr %189, align 8, !tbaa !12
  store ptr %190, ptr @activeNode, align 8, !tbaa !9
  br label %191

191:                                              ; preds = %187, %183
  br label %192

192:                                              ; preds = %191, %176
  br label %10, !llvm.loop !16

193:                                              ; preds = %164, %10
  ret void

194:                                              ; preds = %164
  unreachable
}

attributes #0 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 2048}
!13 = !{!"SuffixTreeNode", !7, i64 0, !10, i64 2048, !6, i64 2056, !10, i64 2064, !6, i64 2072}
!14 = !{!13, !10, i64 2064}
!15 = !{!13, !6, i64 2056}
!16 = distinct !{!16, !17}
!17 = !{!"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"

@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
@text = external dso_local local_unnamed_addr global [1000 x i8], align 16

; Function Attrs: nounwind uwtable
declare dso_local ptr @newNode(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: nounwind uwtable
define dso_local void @extendSuffixTree(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 [1000 x i8], ptr @text, i64 0, i64 %5
  %.pre = load i32, ptr @activeLength, align 4, !tbaa !5
  br label %10

thread-pre-split:                                 ; preds = %95, %100, %99, %.thread40
  %.pr = phi i32 [ %90, %95 ], [ %90, %100 ], [ %90, %99 ], [ %.pr50, %.thread40 ]
  %7 = phi ptr [ %88, %95 ], [ %88, %100 ], [ %88, %99 ], [ %11, %.thread40 ]
  %8 = phi i32 [ %96, %95 ], [ %93, %100 ], [ %93, %99 ], [ %45, %.thread40 ]
  %9 = icmp sgt i32 %.pr, 0
  br i1 %9, label %10, label %.loopexit

10:                                               ; preds = %.lr.ph, %thread-pre-split
  %.pr50 = phi i32 [ %3, %.lr.ph ], [ %.pr, %thread-pre-split ]
  %11 = phi ptr [ null, %.lr.ph ], [ %7, %thread-pre-split ]
  %12 = phi i32 [ %.pre, %.lr.ph ], [ %8, %thread-pre-split ]
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %._crit_edge

._crit_edge:                                      ; preds = %10
  %.pre46 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %.pre51 = sext i32 %.pre46 to i64
  br label %15

14:                                               ; preds = %10
  store i32 %0, ptr @activeEdge, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %._crit_edge, %14
  %.pre-phi = phi i64 [ %.pre51, %._crit_edge ], [ %5, %14 ]
  %16 = phi i32 [ %.pre46, %._crit_edge ], [ %0, %14 ]
  %17 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %18 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %.pre-phi
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = sext i8 %19 to i64
  %21 = getelementptr inbounds [256 x ptr], ptr %17, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %36

24:                                               ; preds = %15
  %25 = tail call ptr @newNode(i32 noundef %0, ptr noundef nonnull @leafEnd)
  %26 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %27 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !11
  %31 = sext i8 %30 to i64
  %32 = getelementptr inbounds [256 x ptr], ptr %26, i64 0, i64 %31
  store ptr %25, ptr %32, align 8, !tbaa !9
  %33 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %.not36 = icmp eq ptr %33, null
  %.pre48 = load ptr, ptr @activeNode, align 8, !tbaa !9
  br i1 %.not36, label %86, label %34

34:                                               ; preds = %24
  %35 = getelementptr inbounds i8, ptr %33, i64 2048
  store ptr %.pre48, ptr %35, align 8, !tbaa !12
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  br label %86

36:                                               ; preds = %15
  %37 = getelementptr inbounds i8, ptr %22, i64 2064
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %22, i64 2056
  %41 = load i32, ptr %40, align 8, !tbaa !15
  %42 = sub nsw i32 %39, %41
  %.not.not = icmp sgt i32 %12, %42
  br i1 %.not.not, label %.thread40, label %46

.thread40:                                        ; preds = %36
  %43 = add nsw i32 %42, 1
  %44 = add nsw i32 %43, %16
  store i32 %44, ptr @activeEdge, align 4, !tbaa !5
  %45 = sub nsw i32 %12, %43
  store i32 %45, ptr @activeLength, align 4, !tbaa !5
  store ptr %22, ptr @activeNode, align 8, !tbaa !9
  br label %thread-pre-split

46:                                               ; preds = %36
  %47 = add nsw i32 %41, %12
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = load i8, ptr %6, align 1, !tbaa !11
  %52 = icmp eq i8 %50, %51
  br i1 %52, label %53, label %57

53:                                               ; preds = %46
  %.not34 = icmp eq ptr %11, null
  %54 = load ptr, ptr @root, align 8
  %.not35 = icmp eq ptr %17, %54
  %or.cond38 = select i1 %.not34, i1 true, i1 %.not35
  br i1 %or.cond38, label %84, label %55

55:                                               ; preds = %53
  %56 = getelementptr inbounds i8, ptr %11, i64 2048
  store ptr %17, ptr %56, align 8, !tbaa !12
  store ptr null, ptr @lastNewNode, align 8, !tbaa !9
  br label %84

57:                                               ; preds = %46
  %58 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #2
  store ptr %58, ptr @splitEnd, align 8, !tbaa !9
  %59 = add nsw i32 %47, -1
  store i32 %59, ptr %58, align 4, !tbaa !5
  %60 = load i32, ptr %40, align 8, !tbaa !15
  %61 = tail call ptr @newNode(i32 noundef %60, ptr noundef nonnull %58)
  %62 = load ptr, ptr @activeNode, align 8, !tbaa !9
  %63 = load i32, ptr @activeEdge, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !11
  %67 = sext i8 %66 to i64
  %68 = getelementptr inbounds [256 x ptr], ptr %62, i64 0, i64 %67
  store ptr %61, ptr %68, align 8, !tbaa !9
  %69 = tail call ptr @newNode(i32 noundef %0, ptr noundef nonnull @leafEnd)
  %70 = load i8, ptr %6, align 1, !tbaa !11
  %71 = sext i8 %70 to i64
  %72 = getelementptr inbounds [256 x ptr], ptr %61, i64 0, i64 %71
  store ptr %69, ptr %72, align 8, !tbaa !9
  %73 = load i32, ptr @activeLength, align 4, !tbaa !5
  %74 = load i32, ptr %40, align 8, !tbaa !15
  %75 = add nsw i32 %74, %73
  store i32 %75, ptr %40, align 8, !tbaa !15
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1000 x i8], ptr @text, i64 0, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !11
  %79 = sext i8 %78 to i64
  %80 = getelementptr inbounds [256 x ptr], ptr %61, i64 0, i64 %79
  store ptr %22, ptr %80, align 8, !tbaa !9
  %81 = load ptr, ptr @lastNewNode, align 8, !tbaa !9
  %.not = icmp eq ptr %81, null
  br i1 %.not, label %.thread, label %82

82:                                               ; preds = %57
  %83 = getelementptr inbounds i8, ptr %81, i64 2048
  store ptr %61, ptr %83, align 8, !tbaa !12
  br label %.thread

.thread:                                          ; preds = %57, %82
  store ptr %61, ptr @lastNewNode, align 8, !tbaa !9
  %.pre47 = load ptr, ptr @activeNode, align 8, !tbaa !9
  br label %86

84:                                               ; preds = %53, %55
  %85 = add nsw i32 %12, 1
  store i32 %85, ptr @activeLength, align 4, !tbaa !5
  br label %.loopexit

86:                                               ; preds = %.thread, %24, %34
  %87 = phi ptr [ %.pre47, %.thread ], [ %.pre48, %24 ], [ %.pre48, %34 ]
  %88 = phi ptr [ %61, %.thread ], [ null, %24 ], [ null, %34 ]
  %89 = load i32, ptr @remainingSuffixCount, align 4, !tbaa !5
  %90 = add nsw i32 %89, -1
  store i32 %90, ptr @remainingSuffixCount, align 4, !tbaa !5
  %91 = load ptr, ptr @root, align 8, !tbaa !9
  %92 = icmp eq ptr %87, %91
  %93 = load i32, ptr @activeLength, align 4
  %94 = icmp sgt i32 %93, 0
  %or.cond = select i1 %92, i1 %94, i1 false
  br i1 %or.cond, label %95, label %99

95:                                               ; preds = %86
  %96 = add nsw i32 %93, -1
  store i32 %96, ptr @activeLength, align 4, !tbaa !5
  %97 = sub i32 %0, %89
  %98 = add i32 %97, 2
  store i32 %98, ptr @activeEdge, align 4, !tbaa !5
  br label %thread-pre-split, !llvm.loop !16

99:                                               ; preds = %86
  br i1 %92, label %thread-pre-split, label %100, !llvm.loop !16

100:                                              ; preds = %99
  %101 = getelementptr inbounds i8, ptr %87, i64 2048
  %102 = load ptr, ptr %101, align 8, !tbaa !12
  store ptr %102, ptr @activeNode, align 8, !tbaa !9
  br label %thread-pre-split, !llvm.loop !16

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

attributes #0 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 2048}
!13 = !{!"SuffixTreeNode", !7, i64 0, !10, i64 2048, !6, i64 2056, !10, i64 2064, !6, i64 2072}
!14 = !{!13, !10, i64 2064}
!15 = !{!13, !6, i64 2056}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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