; LLVM IR from Dev-XYS/Algorithms :: Suffix-Automaton.ll (Z6extendi)

; 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.node = type <{ [26 x ptr], ptr, i32, [4 x i8] }>

@root = external dso_local global ptr, align 8
@last = external dso_local global ptr, align 8

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(220), i32 noundef) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6extendi(i32 noundef %0) #3 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %9 = load ptr, ptr @last, align 8, !tbaa !9
  store ptr %9, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %10 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 224) #7
  %11 = load ptr, ptr %3, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.node, ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = add nsw i32 %13, 1
  invoke void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(220) %10, i32 noundef %14)
          to label %15 unwind label %39

15:                                               ; preds = %1
  store ptr %10, ptr %4, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %29, %15
  %17 = load ptr, ptr %3, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %27

19:                                               ; preds = %16
  %20 = load ptr, ptr %3, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.node, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [26 x ptr], ptr %21, i64 0, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = icmp eq ptr %25, null
  br label %27

27:                                               ; preds = %19, %16
  %28 = phi i1 [ false, %16 ], [ %26, %19 ]
  br i1 %28, label %29, label %43

29:                                               ; preds = %27
  %30 = load ptr, ptr %4, align 8, !tbaa !9
  %31 = load ptr, ptr %3, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.node, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [26 x ptr], ptr %32, i64 0, i64 %34
  store ptr %30, ptr %35, align 8, !tbaa !9
  %36 = load ptr, ptr %3, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.node, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  store ptr %38, ptr %3, align 8, !tbaa !9
  br label %16, !llvm.loop !14

39:                                               ; preds = %1
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %5, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %10, i64 noundef 224) #8
  br label %117

43:                                               ; preds = %27
  %44 = load ptr, ptr %3, align 8, !tbaa !9
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %50

46:                                               ; preds = %43
  %47 = load ptr, ptr @root, align 8, !tbaa !9
  %48 = load ptr, ptr %4, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.node, ptr %48, i32 0, i32 1
  store ptr %47, ptr %49, align 8, !tbaa !13
  br label %115

50:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %51 = load ptr, ptr %3, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.node, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [26 x ptr], ptr %52, i64 0, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  store ptr %56, ptr %7, align 8, !tbaa !9
  %57 = load ptr, ptr %7, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.node, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %58, align 8, !tbaa !11
  %60 = load ptr, ptr %3, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.node, ptr %60, i32 0, i32 2
  %62 = load i32, ptr %61, align 8, !tbaa !11
  %63 = add nsw i32 %62, 1
  %64 = icmp eq i32 %59, %63
  br i1 %64, label %65, label %69

65:                                               ; preds = %50
  %66 = load ptr, ptr %7, align 8, !tbaa !9
  %67 = load ptr, ptr %4, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.node, ptr %67, i32 0, i32 1
  store ptr %66, ptr %68, align 8, !tbaa !13
  br label %114

69:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %70 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 224) #7
  invoke void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(220) %70, i32 noundef 0)
          to label %71 unwind label %109

71:                                               ; preds = %69
  store ptr %70, ptr %8, align 8, !tbaa !9
  %72 = load ptr, ptr %7, align 8, !tbaa !9
  %73 = load ptr, ptr %8, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %73, ptr align 8 %72, i64 220, i1 false), !tbaa.struct !16
  %74 = load ptr, ptr %3, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.node, ptr %74, i32 0, i32 2
  %76 = load i32, ptr %75, align 8, !tbaa !11
  %77 = add nsw i32 %76, 1
  %78 = load ptr, ptr %8, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.node, ptr %78, i32 0, i32 2
  store i32 %77, ptr %79, align 8, !tbaa !11
  %80 = load ptr, ptr %8, align 8, !tbaa !9
  %81 = load ptr, ptr %4, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.node, ptr %81, i32 0, i32 1
  store ptr %80, ptr %82, align 8, !tbaa !13
  %83 = load ptr, ptr %7, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.node, ptr %83, i32 0, i32 1
  store ptr %80, ptr %84, align 8, !tbaa !13
  br label %85

85:                                               ; preds = %99, %71
  %86 = load ptr, ptr %3, align 8, !tbaa !9
  %87 = icmp ne ptr %86, null
  br i1 %87, label %88, label %97

88:                                               ; preds = %85
  %89 = load ptr, ptr %3, align 8, !tbaa !9
  %90 = getelementptr inbounds %struct.node, ptr %89, i32 0, i32 0
  %91 = load i32, ptr %2, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [26 x ptr], ptr %90, i64 0, i64 %92
  %94 = load ptr, ptr %93, align 8, !tbaa !9
  %95 = load ptr, ptr %7, align 8, !tbaa !9
  %96 = icmp eq ptr %94, %95
  br label %97

97:                                               ; preds = %88, %85
  %98 = phi i1 [ false, %85 ], [ %96, %88 ]
  br i1 %98, label %99, label %113

99:                                               ; preds = %97
  %100 = load ptr, ptr %8, align 8, !tbaa !9
  %101 = load ptr, ptr %3, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.node, ptr %101, i32 0, i32 0
  %103 = load i32, ptr %2, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [26 x ptr], ptr %102, i64 0, i64 %104
  store ptr %100, ptr %105, align 8, !tbaa !9
  %106 = load ptr, ptr %3, align 8, !tbaa !9
  %107 = getelementptr inbounds %struct.node, ptr %106, i32 0, i32 1
  %108 = load ptr, ptr %107, align 8, !tbaa !13
  store ptr %108, ptr %3, align 8, !tbaa !9
  br label %85, !llvm.loop !18

109:                                              ; preds = %69
  %110 = landingpad { ptr, i32 }
          cleanup
  %111 = extractvalue { ptr, i32 } %110, 0
  store ptr %111, ptr %5, align 8
  %112 = extractvalue { ptr, i32 } %110, 1
  store i32 %112, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %70, i64 noundef 224) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %117

113:                                              ; preds = %97
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %114

114:                                              ; preds = %113, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %115

115:                                              ; preds = %114, %46
  %116 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %116, ptr @last, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret void

117:                                              ; preds = %109, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %118

118:                                              ; preds = %117
  %119 = load ptr, ptr %5, align 8
  %120 = load i32, ptr %6, align 4
  %121 = insertvalue { ptr, i32 } poison, ptr %119, 0
  %122 = insertvalue { ptr, i32 } %121, i32 %120, 1
  resume { ptr, i32 } %122
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

attributes #0 = { nobuiltin 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 #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 = { nobuiltin nounwind "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 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 = !{!"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 = !{!12, !6, i64 216}
!12 = !{!"_ZTS4node", !7, i64 0, !10, i64 208, !6, i64 216}
!13 = !{!12, !10, i64 208}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{i64 0, i64 208, !17, i64 208, i64 8, !9, i64 216, i64 4, !5}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !15}


; 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
@last = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(220), i32 noundef) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6extendi(i32 noundef %0) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
.lr.ph:
  %1 = load ptr, ptr @last, align 8, !tbaa !5
  %2 = tail call noalias noundef nonnull dereferenceable(224) ptr @_Znwm(i64 noundef 224) #4
  %3 = getelementptr inbounds i8, ptr %1, i64 216
  %4 = load i32, ptr %3, align 8, !tbaa !9
  %5 = add nsw i32 %4, 1
  tail call void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(220) %2, i32 noundef %5)
  %6 = sext i32 %0 to i64
  br label %7

7:                                                ; preds = %.lr.ph, %11
  %.037 = phi ptr [ %1, %.lr.ph ], [ %13, %11 ]
  %8 = getelementptr inbounds [26 x ptr], ptr %.037, i64 0, i64 %6
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %.critedge

11:                                               ; preds = %7
  store ptr %2, ptr %8, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %.037, i64 208
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %cond = icmp eq ptr %13, null
  br i1 %cond, label %._crit_edge, label %7, !llvm.loop !13

._crit_edge:                                      ; preds = %11
  %14 = load ptr, ptr @root, align 8, !tbaa !5
  br label %.critedge2.sink.split

.critedge:                                        ; preds = %7
  %15 = getelementptr inbounds i8, ptr %9, i64 216
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %.037, i64 216
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = add nsw i32 %18, 1
  %20 = icmp eq i32 %16, %19
  br i1 %20, label %.critedge2.sink.split, label %21

21:                                               ; preds = %.critedge
  %22 = tail call noalias noundef nonnull dereferenceable(224) ptr @_Znwm(i64 noundef 224) #4
  tail call void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(220) %22, i32 noundef 0)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(220) %22, ptr noundef nonnull align 8 dereferenceable(220) %9, i64 216, i1 false), !tbaa.struct !15
  %23 = load i32, ptr %17, align 8, !tbaa !9
  %24 = add nsw i32 %23, 1
  %25 = getelementptr inbounds i8, ptr %22, i64 216
  store i32 %24, ptr %25, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %2, i64 208
  store ptr %22, ptr %26, align 8, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %9, i64 208
  store ptr %22, ptr %27, align 8, !tbaa !12
  br label %28

28:                                               ; preds = %21, %32
  %.138 = phi ptr [ %.037, %21 ], [ %34, %32 ]
  %29 = getelementptr inbounds [26 x ptr], ptr %.138, i64 0, i64 %6
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = icmp eq ptr %30, %9
  br i1 %31, label %32, label %.critedge2

32:                                               ; preds = %28
  store ptr %22, ptr %29, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %.138, i64 208
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %.not33 = icmp eq ptr %34, null
  br i1 %.not33, label %.critedge2, label %28, !llvm.loop !18

.critedge2.sink.split:                            ; preds = %.critedge, %._crit_edge
  %.lcssa.sink = phi ptr [ %14, %._crit_edge ], [ %9, %.critedge ]
  %35 = getelementptr inbounds i8, ptr %2, i64 208
  store ptr %.lcssa.sink, ptr %35, align 8, !tbaa !12
  br label %.critedge2

.critedge2:                                       ; preds = %32, %28, %.critedge2.sink.split
  store ptr %2, ptr @last, align 8, !tbaa !5
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { nobuiltin 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { builtin 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 216}
!10 = !{!"_ZTS4node", !7, i64 0, !6, i64 208, !11, i64 216}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 208}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i64 0, i64 208, !16, i64 208, i64 8, !5, i64 216, i64 4, !17}
!16 = !{!7, !7, i64 0}
!17 = !{!11, !11, i64 0}
!18 = distinct !{!18, !14}


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