; LLVM IR from MinhasKamal/AlgorithmImplementations :: dataStructures/string/StringLongestCommonSubSecuence.ll (Z8printLcsPPcS_ii)

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

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8printLcsPPcS_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
  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
  %9 = load i32, ptr %7, align 4, !tbaa !9
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %14, label %11

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

14:                                               ; preds = %11, %4
  br label %87

15:                                               ; preds = %11
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = sub nsw i32 %17, 1
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds ptr, ptr %16, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %21, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i32
  %28 = icmp eq i32 %27, 92
  br i1 %28, label %29, label %44

29:                                               ; preds = %15
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = sub nsw i32 %32, 1
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = sub nsw i32 %34, 1
  call void @_Z8printLcsPPcS_ii(ptr noundef %30, ptr noundef %31, i32 noundef %33, i32 noundef %35)
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = sub nsw i32 %37, 1
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %36, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = sext i8 %41 to i32
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %42)
  br label %86

44:                                               ; preds = %15
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = sub nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds ptr, ptr %45, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = sub nsw i32 %51, 1
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i8, ptr %50, i64 %53
  %55 = load i8, ptr %54, align 1, !tbaa !11
  %56 = sext i8 %55 to i32
  %57 = icmp eq i32 %56, 124
  br i1 %57, label %58, label %64

58:                                               ; preds = %44
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = sub nsw i32 %61, 1
  %63 = load i32, ptr %8, align 4, !tbaa !9
  call void @_Z8printLcsPPcS_ii(ptr noundef %59, ptr noundef %60, i32 noundef %62, i32 noundef %63)
  br label %85

64:                                               ; preds = %44
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = sub nsw i32 %66, 1
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds ptr, ptr %65, i64 %68
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = sub nsw i32 %71, 1
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i8, ptr %70, i64 %73
  %75 = load i8, ptr %74, align 1, !tbaa !11
  %76 = sext i8 %75 to i32
  %77 = icmp eq i32 %76, 45
  br i1 %77, label %78, label %84

78:                                               ; preds = %64
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = load i32, ptr %8, align 4, !tbaa !9
  %83 = sub nsw i32 %82, 1
  call void @_Z8printLcsPPcS_ii(ptr noundef %79, ptr noundef %80, i32 noundef %81, i32 noundef %83)
  br label %84

84:                                               ; preds = %78, %64
  br label %85

85:                                               ; preds = %84, %58
  br label %86

86:                                               ; preds = %85, %29
  br label %87

87:                                               ; preds = %86, %14
  ret void
}

declare i32 @printf(ptr noundef, ...) #1

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 = { "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 = !{!"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 = !{!7, !7, i64 0}


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

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z8printLcsPPcS_ii(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq i32 %2, 0
  %6 = icmp eq i32 %3, 0
  %or.cond3743 = or i1 %5, %6
  br i1 %or.cond3743, label %common.ret100, label %.lr.ph.split.preheader

tailrecurse.outer.loopexit:                       ; preds = %.lr.ph.split
  %7 = trunc nsw i64 %indvars.iv to i32
  %8 = icmp eq i32 %10, 0
  %9 = icmp eq i64 %indvars.iv, 0
  %or.cond37 = or i1 %8, %9
  br i1 %or.cond37, label %common.ret100, label %.lr.ph.split.preheader

.lr.ph.split.preheader:                           ; preds = %4, %tailrecurse.outer.loopexit
  %.tr29.ph45 = phi i32 [ %7, %tailrecurse.outer.loopexit ], [ %3, %4 ]
  %.tr28.ph44 = phi i32 [ %10, %tailrecurse.outer.loopexit ], [ %2, %4 ]
  %10 = add i32 %.tr28.ph44, -1
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds ptr, ptr %0, i64 %11
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = sext i32 %.tr29.ph45 to i64
  br label %.lr.ph.split

.lr.ph.split:                                     ; preds = %.lr.ph.split.preheader, %tailrecurse
  %indvars.iv = phi i64 [ %14, %.lr.ph.split.preheader ], [ %indvars.iv.next, %tailrecurse ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %15 = getelementptr inbounds i8, ptr %13, i64 %indvars.iv.next
  %16 = load i8, ptr %15, align 1, !tbaa !9
  switch i8 %16, label %common.ret100 [
    i8 92, label %.split.us
    i8 124, label %tailrecurse.outer.loopexit
    i8 45, label %tailrecurse
  ]

common.ret100:                                    ; preds = %4, %tailrecurse, %.lr.ph.split, %tailrecurse.outer.loopexit, %.split.us
  ret void

.split.us:                                        ; preds = %.lr.ph.split
  %17 = trunc nsw i64 %indvars.iv.next to i32
  tail call void @_Z8printLcsPPcS_ii(ptr noundef nonnull %0, ptr noundef %1, i32 noundef %10, i32 noundef %17)
  %18 = getelementptr inbounds i8, ptr %1, i64 %11
  %19 = load i8, ptr %18, align 1, !tbaa !9
  %20 = sext i8 %19 to i32
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %20)
  br label %common.ret100

tailrecurse:                                      ; preds = %.lr.ph.split
  %22 = icmp eq i64 %indvars.iv.next, 0
  br i1 %22, label %common.ret100, label %.lr.ph.split
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { mustprogress nofree 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 = { nofree 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" }

!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 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass