; LLVM IR from begeekmyfriend/leetcode :: 0212_word_search_ii (word_search)

; 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 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 2, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 2, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = mul i64 %11, 8
  %13 = call noalias ptr @malloc(i64 noundef %12) #6
  store ptr %13, ptr %5, align 8, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = call noalias ptr @malloc(i64 noundef %15) #6
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  %18 = getelementptr inbounds ptr, ptr %17, i64 0
  store ptr %16, ptr %18, align 8, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds ptr, ptr %19, i64 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %21, i64 0
  store i8 97, ptr %22, align 1, !tbaa !11
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds ptr, ptr %23, i64 0
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %25, i64 1
  store i8 98, ptr %26, align 1, !tbaa !11
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = call noalias ptr @malloc(i64 noundef %28) #6
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds ptr, ptr %30, i64 1
  store ptr %29, ptr %31, align 8, !tbaa !9
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = getelementptr inbounds ptr, ptr %32, i64 1
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %34, i64 0
  store i8 97, ptr %35, align 1, !tbaa !11
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  %37 = getelementptr inbounds ptr, ptr %36, i64 1
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds i8, ptr %38, i64 1
  store i8 97, ptr %39, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 7, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = mul i64 %41, 8
  %43 = call noalias ptr @malloc(i64 noundef %42) #6
  store ptr %43, ptr %7, align 8, !tbaa !9
  %44 = call noalias ptr @malloc(i64 noundef 5) #6
  %45 = load ptr, ptr %7, align 8, !tbaa !9
  %46 = getelementptr inbounds ptr, ptr %45, i64 0
  store ptr %44, ptr %46, align 8, !tbaa !9
  %47 = call noalias ptr @malloc(i64 noundef 5) #6
  %48 = load ptr, ptr %7, align 8, !tbaa !9
  %49 = getelementptr inbounds ptr, ptr %48, i64 1
  store ptr %47, ptr %49, align 8, !tbaa !9
  %50 = call noalias ptr @malloc(i64 noundef 5) #6
  %51 = load ptr, ptr %7, align 8, !tbaa !9
  %52 = getelementptr inbounds ptr, ptr %51, i64 2
  store ptr %50, ptr %52, align 8, !tbaa !9
  %53 = call noalias ptr @malloc(i64 noundef 5) #6
  %54 = load ptr, ptr %7, align 8, !tbaa !9
  %55 = getelementptr inbounds ptr, ptr %54, i64 3
  store ptr %53, ptr %55, align 8, !tbaa !9
  %56 = call noalias ptr @malloc(i64 noundef 5) #6
  %57 = load ptr, ptr %7, align 8, !tbaa !9
  %58 = getelementptr inbounds ptr, ptr %57, i64 4
  store ptr %56, ptr %58, align 8, !tbaa !9
  %59 = call noalias ptr @malloc(i64 noundef 5) #6
  %60 = load ptr, ptr %7, align 8, !tbaa !9
  %61 = getelementptr inbounds ptr, ptr %60, i64 5
  store ptr %59, ptr %61, align 8, !tbaa !9
  %62 = call noalias ptr @malloc(i64 noundef 5) #6
  %63 = load ptr, ptr %7, align 8, !tbaa !9
  %64 = getelementptr inbounds ptr, ptr %63, i64 6
  store ptr %62, ptr %64, align 8, !tbaa !9
  %65 = load ptr, ptr %7, align 8, !tbaa !9
  %66 = getelementptr inbounds ptr, ptr %65, i64 0
  %67 = load ptr, ptr %66, align 8, !tbaa !9
  %68 = call ptr @strcpy(ptr noundef %67, ptr noundef @.str) #5
  %69 = load ptr, ptr %7, align 8, !tbaa !9
  %70 = getelementptr inbounds ptr, ptr %69, i64 1
  %71 = load ptr, ptr %70, align 8, !tbaa !9
  %72 = call ptr @strcpy(ptr noundef %71, ptr noundef @.str.1) #5
  %73 = load ptr, ptr %7, align 8, !tbaa !9
  %74 = getelementptr inbounds ptr, ptr %73, i64 2
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = call ptr @strcpy(ptr noundef %75, ptr noundef @.str.2) #5
  %77 = load ptr, ptr %7, align 8, !tbaa !9
  %78 = getelementptr inbounds ptr, ptr %77, i64 3
  %79 = load ptr, ptr %78, align 8, !tbaa !9
  %80 = call ptr @strcpy(ptr noundef %79, ptr noundef @.str.3) #5
  %81 = load ptr, ptr %7, align 8, !tbaa !9
  %82 = getelementptr inbounds ptr, ptr %81, i64 4
  %83 = load ptr, ptr %82, align 8, !tbaa !9
  %84 = call ptr @strcpy(ptr noundef %83, ptr noundef @.str.4) #5
  %85 = load ptr, ptr %7, align 8, !tbaa !9
  %86 = getelementptr inbounds ptr, ptr %85, i64 5
  %87 = load ptr, ptr %86, align 8, !tbaa !9
  %88 = call ptr @strcpy(ptr noundef %87, ptr noundef @.str.5) #5
  %89 = load ptr, ptr %7, align 8, !tbaa !9
  %90 = getelementptr inbounds ptr, ptr %89, i64 6
  %91 = load ptr, ptr %90, align 8, !tbaa !9
  %92 = call ptr @strcpy(ptr noundef %91, ptr noundef @.str.6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %93 = load ptr, ptr %5, align 8, !tbaa !9
  %94 = load i32, ptr %3, align 4, !tbaa !5
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = load ptr, ptr %7, align 8, !tbaa !9
  %97 = load i32, ptr %6, align 4, !tbaa !5
  %98 = call ptr @findWords(ptr noundef %93, i32 noundef %94, i32 noundef %95, ptr noundef %96, i32 noundef %97, ptr noundef %8)
  store ptr %98, ptr %9, align 8, !tbaa !9
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %110, %0
  %100 = load i32, ptr %2, align 4, !tbaa !5
  %101 = load i32, ptr %8, align 4, !tbaa !5
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %103, label %113

103:                                              ; preds = %99
  %104 = load ptr, ptr %9, align 8, !tbaa !9
  %105 = load i32, ptr %2, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds ptr, ptr %104, i64 %106
  %108 = load ptr, ptr %107, align 8, !tbaa !9
  %109 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, ptr noundef %108)
  br label %110

110:                                              ; preds = %103
  %111 = load i32, ptr %2, align 4, !tbaa !5
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %2, align 4, !tbaa !5
  br label %99, !llvm.loop !12

113:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 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: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden ptr @findWords(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

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 "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 = { "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 #5 = { nounwind }
attributes #6 = { 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 = distinct !{!12, !13}
!13 = !{!"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"

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #5
  %3 = tail call noalias dereferenceable_or_null(2) ptr @malloc(i64 noundef 2) #5
  store ptr %3, ptr %2, align 8, !tbaa !5
  store i8 97, ptr %3, align 1, !tbaa !9
  %4 = getelementptr inbounds i8, ptr %3, i64 1
  store i8 98, ptr %4, align 1, !tbaa !9
  %5 = tail call noalias dereferenceable_or_null(2) ptr @malloc(i64 noundef 2) #5
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %5, ptr %6, align 8, !tbaa !5
  store i8 97, ptr %5, align 1, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %5, i64 1
  store i8 97, ptr %7, align 1, !tbaa !9
  %8 = tail call noalias dereferenceable_or_null(56) ptr @malloc(i64 noundef 56) #5
  %9 = tail call noalias dereferenceable_or_null(5) ptr @malloc(i64 noundef 5) #5
  store ptr %9, ptr %8, align 8, !tbaa !5
  %10 = tail call noalias dereferenceable_or_null(5) ptr @malloc(i64 noundef 5) #5
  %11 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %10, ptr %11, align 8, !tbaa !5
  %12 = tail call noalias dereferenceable_or_null(5) ptr @malloc(i64 noundef 5) #5
  %13 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %12, ptr %13, align 8, !tbaa !5
  %14 = tail call noalias dereferenceable_or_null(5) ptr @malloc(i64 noundef 5) #5
  %15 = getelementptr inbounds i8, ptr %8, i64 24
  store ptr %14, ptr %15, align 8, !tbaa !5
  %16 = tail call noalias dereferenceable_or_null(5) ptr @malloc(i64 noundef 5) #5
  %17 = getelementptr inbounds i8, ptr %8, i64 32
  store ptr %16, ptr %17, align 8, !tbaa !5
  %18 = tail call noalias dereferenceable_or_null(5) ptr @malloc(i64 noundef 5) #5
  %19 = getelementptr inbounds i8, ptr %8, i64 40
  store ptr %18, ptr %19, align 8, !tbaa !5
  %20 = tail call noalias dereferenceable_or_null(5) ptr @malloc(i64 noundef 5) #5
  %21 = getelementptr inbounds i8, ptr %8, i64 48
  store ptr %20, ptr %21, align 8, !tbaa !5
  %22 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) @.str) #6
  %23 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %10, ptr noundef nonnull dereferenceable(1) @.str.1) #6
  %24 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %12, ptr noundef nonnull dereferenceable(1) @.str.2) #6
  %25 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %14, ptr noundef nonnull dereferenceable(1) @.str.3) #6
  %26 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.4) #6
  %27 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) @.str.5) #6
  %28 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %20, ptr noundef nonnull dereferenceable(1) @.str.6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 0, ptr %1, align 4, !tbaa !10
  %29 = call ptr @findWords(ptr noundef nonnull %2, i32 noundef 2, i32 noundef 2, ptr noundef nonnull %8, i32 noundef 7, ptr noundef nonnull %1)
  %30 = load i32, ptr %1, align 4, !tbaa !10
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %32 = getelementptr inbounds ptr, ptr %29, i64 %indvars.iv
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef %33)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %35 = load i32, ptr %1, align 4, !tbaa !10
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %indvars.iv.next, %36
  br i1 %37, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 0
}

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden ptr @findWords(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { 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" }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { 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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass