; LLVM IR from Ayon-SSP/The-SDE-Prep :: 3]_CP/DP/Longest Common Subsequence (Printing LCS)

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

@dp = external dso_local global [1001 x [1001 x i32]], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10fill_tableNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES4_ii(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %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
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = 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
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %43, %4
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = icmp sle i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %46

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %39, %19
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = icmp sle i32 %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %42

25:                                               ; preds = %20
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %31, label %28

28:                                               ; preds = %25
  %29 = load i32, ptr %11, align 4, !tbaa !9
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %38

31:                                               ; preds = %28, %25
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %33
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1001 x i32], ptr %34, i64 0, i64 %36
  store i32 0, ptr %37, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %31, %28
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %11, align 4, !tbaa !9
  br label %20, !llvm.loop !11

42:                                               ; preds = %24
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %9, align 4, !tbaa !9
  br label %14, !llvm.loop !13

46:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 1, ptr %12, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %117, %46
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = icmp sle i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %120

52:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 1, ptr %13, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %113, %52
  %54 = load i32, ptr %13, align 4, !tbaa !9
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = icmp sle i32 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  store i32 11, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %116

58:                                               ; preds = %53
  %59 = load i32, ptr %12, align 4, !tbaa !9
  %60 = sub nsw i32 %59, 1
  %61 = sext i32 %60 to i64
  %62 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %61)
  %63 = load i8, ptr %62, align 1, !tbaa !14
  %64 = sext i8 %63 to i32
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = sub nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %67)
  %69 = load i8, ptr %68, align 1, !tbaa !14
  %70 = sext i8 %69 to i32
  %71 = icmp eq i32 %64, %70
  br i1 %71, label %72, label %89

72:                                               ; preds = %58
  %73 = load i32, ptr %12, align 4, !tbaa !9
  %74 = sub nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %75
  %77 = load i32, ptr %13, align 4, !tbaa !9
  %78 = sub nsw i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1001 x i32], ptr %76, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = add nsw i32 1, %81
  %83 = load i32, ptr %12, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %84
  %86 = load i32, ptr %13, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [1001 x i32], ptr %85, i64 0, i64 %87
  store i32 %82, ptr %88, align 4, !tbaa !9
  br label %112

89:                                               ; preds = %58
  %90 = load i32, ptr %12, align 4, !tbaa !9
  %91 = sub nsw i32 %90, 1
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %92
  %94 = load i32, ptr %13, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [1001 x i32], ptr %93, i64 0, i64 %95
  %97 = load i32, ptr %12, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %98
  %100 = load i32, ptr %13, align 4, !tbaa !9
  %101 = sub nsw i32 %100, 1
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [1001 x i32], ptr %99, i64 0, i64 %102
  %104 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %96, ptr noundef nonnull align 4 dereferenceable(4) %103)
  %105 = load i32, ptr %104, align 4, !tbaa !9
  %106 = load i32, ptr %12, align 4, !tbaa !9
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %107
  %109 = load i32, ptr %13, align 4, !tbaa !9
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [1001 x i32], ptr %108, i64 0, i64 %110
  store i32 %105, ptr %111, align 4, !tbaa !9
  br label %112

112:                                              ; preds = %89, %72
  br label %113

113:                                              ; preds = %112
  %114 = load i32, ptr %13, align 4, !tbaa !9
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %13, align 4, !tbaa !9
  br label %53, !llvm.loop !15

116:                                              ; preds = %57
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %12, align 4, !tbaa !9
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %12, align 4, !tbaa !9
  br label %47, !llvm.loop !16

120:                                              ; preds = %51
  ret void
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { inlinehint 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 #4 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


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

@dp = external dso_local global [1001 x [1001 x i32]], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z10fill_tableNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES4_ii(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %.not40 = icmp slt i32 %2, 0
  br i1 %.not40, label %._crit_edge47, label %.preheader37.lr.ph

.preheader37.lr.ph:                               ; preds = %4
  %.not3538 = icmp slt i32 %3, 0
  br i1 %.not3538, label %.preheader36, label %.preheader37.preheader

.preheader37.preheader:                           ; preds = %.preheader37.lr.ph
  %5 = add nuw i32 %3, 1
  %6 = zext i32 %5 to i64
  %7 = shl nuw nsw i64 %6, 2
  %8 = add nuw i32 %2, 1
  %smax = tail call i32 @llvm.smax.i32(i32 %8, i32 1)
  %wide.trip.count57 = zext nneg i32 %smax to i64
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) @dp, i8 0, i64 %7, i1 false), !tbaa !5
  %exitcond58.peel = icmp slt i32 %8, 2
  br i1 %exitcond58.peel, label %.preheader36, label %.preheader37

.preheader37:                                     ; preds = %.preheader37.preheader, %.preheader37
  %indvar = phi i64 [ %indvar.next, %.preheader37 ], [ 1, %.preheader37.preheader ]
  %9 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvar, i64 0
  store i32 0, ptr %9, align 4, !tbaa !5
  %indvar.next = add nuw nsw i64 %indvar, 1
  %exitcond58 = icmp eq i64 %indvar.next, %wide.trip.count57
  br i1 %exitcond58, label %.preheader36, label %.preheader37, !llvm.loop !9

.preheader36:                                     ; preds = %.preheader37.preheader, %.preheader37, %.preheader37.lr.ph
  %.not3345 = icmp eq i32 %2, 0
  %.not3442 = icmp slt i32 %3, 1
  %or.cond = or i1 %.not3345, %.not3442
  br i1 %or.cond, label %._crit_edge47, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader36
  %10 = add nuw i32 %3, 1
  %11 = add nuw i32 %2, 1
  %wide.trip.count67 = zext i32 %11 to i64
  %wide.trip.count62 = zext i32 %10 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge44
  %indvars.iv64 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next65, %._crit_edge44 ]
  %12 = add nsw i64 %indvars.iv64, -1
  br label %13

._crit_edge47:                                    ; preds = %._crit_edge44, %4, %.preheader36
  ret void

._crit_edge44:                                    ; preds = %29
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %exitcond68.not = icmp eq i64 %indvars.iv.next65, %wide.trip.count67
  br i1 %exitcond68.not, label %._crit_edge47, label %.preheader, !llvm.loop !12

13:                                               ; preds = %.preheader, %29
  %indvars.iv59 = phi i64 [ 1, %.preheader ], [ %indvars.iv.next60, %29 ]
  %14 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %12)
  %15 = load i8, ptr %14, align 1, !tbaa !13
  %16 = add nsw i64 %indvars.iv59, -1
  %17 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %16)
  %18 = load i8, ptr %17, align 1, !tbaa !13
  %19 = icmp eq i8 %15, %18
  br i1 %19, label %20, label %24

20:                                               ; preds = %13
  %21 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %12, i64 %16
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  br label %29

24:                                               ; preds = %13
  %25 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %12, i64 %indvars.iv59
  %26 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv64, i64 %16
  %27 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %25, ptr noundef nonnull align 4 dereferenceable(4) %26)
  %28 = load i32, ptr %27, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %20, %24
  %.sink = phi i32 [ %23, %20 ], [ %28, %24 ]
  %30 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv64, i64 %indvars.iv59
  store i32 %.sink, ptr %30, align 4
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %exitcond63.not = icmp eq i64 %indvars.iv.next60, %wide.trip.count62
  br i1 %exitcond63.not, label %._crit_edge44, label %13, !llvm.loop !14
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

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 = { inlinehint 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 1}
!12 = distinct !{!12, !10}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass