; LLVM IR from lolosssss/leetcode :: c (240_search_a_2d_matrix_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 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @searchMatrix(ptr noundef, i32 noundef, i32 noundef, i32 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: 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 i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %5 = call noalias ptr @malloc(i64 noundef 40) #6
  store ptr %5, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %16, %0
  %7 = load i32, ptr %3, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 5
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %19

10:                                               ; preds = %6
  %11 = call noalias ptr @malloc(i64 noundef 20) #6
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds ptr, ptr %12, i64 %14
  store ptr %11, ptr %15, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %10
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !11

19:                                               ; preds = %9
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds ptr, ptr %20, i64 0
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i32, ptr %22, i64 0
  store i32 1, ptr %23, align 4, !tbaa !9
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds ptr, ptr %24, i64 0
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds i32, ptr %26, i64 1
  store i32 4, ptr %27, align 4, !tbaa !9
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds ptr, ptr %28, i64 0
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds i32, ptr %30, i64 2
  store i32 7, ptr %31, align 4, !tbaa !9
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds ptr, ptr %32, i64 0
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds i32, ptr %34, i64 3
  store i32 11, ptr %35, align 4, !tbaa !9
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds ptr, ptr %36, i64 0
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds i32, ptr %38, i64 4
  store i32 15, ptr %39, align 4, !tbaa !9
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds ptr, ptr %40, i64 1
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = getelementptr inbounds i32, ptr %42, i64 0
  store i32 2, ptr %43, align 4, !tbaa !9
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds ptr, ptr %44, i64 1
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds i32, ptr %46, i64 1
  store i32 5, ptr %47, align 4, !tbaa !9
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds ptr, ptr %48, i64 1
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds i32, ptr %50, i64 2
  store i32 8, ptr %51, align 4, !tbaa !9
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds ptr, ptr %52, i64 1
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = getelementptr inbounds i32, ptr %54, i64 3
  store i32 12, ptr %55, align 4, !tbaa !9
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds ptr, ptr %56, i64 1
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = getelementptr inbounds i32, ptr %58, i64 4
  store i32 19, ptr %59, align 4, !tbaa !9
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds ptr, ptr %60, i64 2
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = getelementptr inbounds i32, ptr %62, i64 0
  store i32 3, ptr %63, align 4, !tbaa !9
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds ptr, ptr %64, i64 2
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  %67 = getelementptr inbounds i32, ptr %66, i64 1
  store i32 6, ptr %67, align 4, !tbaa !9
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds ptr, ptr %68, i64 2
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = getelementptr inbounds i32, ptr %70, i64 2
  store i32 9, ptr %71, align 4, !tbaa !9
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds ptr, ptr %72, i64 2
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  %75 = getelementptr inbounds i32, ptr %74, i64 3
  store i32 16, ptr %75, align 4, !tbaa !9
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds ptr, ptr %76, i64 2
  %78 = load ptr, ptr %77, align 8, !tbaa !5
  %79 = getelementptr inbounds i32, ptr %78, i64 4
  store i32 22, ptr %79, align 4, !tbaa !9
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds ptr, ptr %80, i64 3
  %82 = load ptr, ptr %81, align 8, !tbaa !5
  %83 = getelementptr inbounds i32, ptr %82, i64 0
  store i32 10, ptr %83, align 4, !tbaa !9
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds ptr, ptr %84, i64 3
  %86 = load ptr, ptr %85, align 8, !tbaa !5
  %87 = getelementptr inbounds i32, ptr %86, i64 1
  store i32 13, ptr %87, align 4, !tbaa !9
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds ptr, ptr %88, i64 3
  %90 = load ptr, ptr %89, align 8, !tbaa !5
  %91 = getelementptr inbounds i32, ptr %90, i64 2
  store i32 14, ptr %91, align 4, !tbaa !9
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = getelementptr inbounds ptr, ptr %92, i64 3
  %94 = load ptr, ptr %93, align 8, !tbaa !5
  %95 = getelementptr inbounds i32, ptr %94, i64 3
  store i32 17, ptr %95, align 4, !tbaa !9
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds ptr, ptr %96, i64 3
  %98 = load ptr, ptr %97, align 8, !tbaa !5
  %99 = getelementptr inbounds i32, ptr %98, i64 4
  store i32 24, ptr %99, align 4, !tbaa !9
  %100 = load ptr, ptr %2, align 8, !tbaa !5
  %101 = getelementptr inbounds ptr, ptr %100, i64 4
  %102 = load ptr, ptr %101, align 8, !tbaa !5
  %103 = getelementptr inbounds i32, ptr %102, i64 0
  store i32 18, ptr %103, align 4, !tbaa !9
  %104 = load ptr, ptr %2, align 8, !tbaa !5
  %105 = getelementptr inbounds ptr, ptr %104, i64 4
  %106 = load ptr, ptr %105, align 8, !tbaa !5
  %107 = getelementptr inbounds i32, ptr %106, i64 1
  store i32 21, ptr %107, align 4, !tbaa !9
  %108 = load ptr, ptr %2, align 8, !tbaa !5
  %109 = getelementptr inbounds ptr, ptr %108, i64 4
  %110 = load ptr, ptr %109, align 8, !tbaa !5
  %111 = getelementptr inbounds i32, ptr %110, i64 2
  store i32 23, ptr %111, align 4, !tbaa !9
  %112 = load ptr, ptr %2, align 8, !tbaa !5
  %113 = getelementptr inbounds ptr, ptr %112, i64 4
  %114 = load ptr, ptr %113, align 8, !tbaa !5
  %115 = getelementptr inbounds i32, ptr %114, i64 3
  store i32 26, ptr %115, align 4, !tbaa !9
  %116 = load ptr, ptr %2, align 8, !tbaa !5
  %117 = getelementptr inbounds ptr, ptr %116, i64 4
  %118 = load ptr, ptr %117, align 8, !tbaa !5
  %119 = getelementptr inbounds i32, ptr %118, i64 4
  store i32 30, ptr %119, align 4, !tbaa !9
  %120 = load ptr, ptr %2, align 8, !tbaa !5
  %121 = call zeroext i1 @searchMatrix(ptr noundef %120, i32 noundef 5, i32 noundef 5, i32 noundef 5)
  %122 = zext i1 %121 to i32
  %123 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %122)
  %124 = load ptr, ptr %2, align 8, !tbaa !5
  %125 = call zeroext i1 @searchMatrix(ptr noundef %124, i32 noundef 5, i32 noundef 5, i32 noundef 20)
  %126 = zext i1 %125 to i32
  %127 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %126)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %128

128:                                              ; preds = %138, %19
  %129 = load i32, ptr %4, align 4, !tbaa !9
  %130 = icmp slt i32 %129, 5
  br i1 %130, label %132, label %131

131:                                              ; preds = %128
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %141

132:                                              ; preds = %128
  %133 = load ptr, ptr %2, align 8, !tbaa !5
  %134 = load i32, ptr %4, align 4, !tbaa !9
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds ptr, ptr %133, i64 %135
  %137 = load ptr, ptr %136, align 8, !tbaa !5
  call void @free(ptr noundef %137) #5
  br label %138

138:                                              ; preds = %132
  %139 = load i32, ptr %4, align 4, !tbaa !9
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %4, align 4, !tbaa !9
  br label %128, !llvm.loop !13

141:                                              ; preds = %131
  %142 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %142) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  ret i32 0
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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 = { "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 "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @searchMatrix(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noalias dereferenceable_or_null(40) ptr @malloc(i64 noundef 40) #4
  %2 = tail call noalias dereferenceable_or_null(20) ptr @malloc(i64 noundef 20) #4
  store ptr %2, ptr %1, align 8, !tbaa !5
  %3 = tail call noalias dereferenceable_or_null(20) ptr @malloc(i64 noundef 20) #4
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %3, ptr %4, align 8, !tbaa !5
  %5 = tail call noalias dereferenceable_or_null(20) ptr @malloc(i64 noundef 20) #4
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %5, ptr %6, align 8, !tbaa !5
  %7 = tail call noalias dereferenceable_or_null(20) ptr @malloc(i64 noundef 20) #4
  %8 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %7, ptr %8, align 8, !tbaa !5
  %9 = tail call noalias dereferenceable_or_null(20) ptr @malloc(i64 noundef 20) #4
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr %9, ptr %10, align 8, !tbaa !5
  store <4 x i32> <i32 1, i32 4, i32 7, i32 11>, ptr %2, align 4, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 15, ptr %11, align 4, !tbaa !9
  store <4 x i32> <i32 2, i32 5, i32 8, i32 12>, ptr %3, align 4, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 19, ptr %12, align 4, !tbaa !9
  store <4 x i32> <i32 3, i32 6, i32 9, i32 16>, ptr %5, align 4, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 22, ptr %13, align 4, !tbaa !9
  store <4 x i32> <i32 10, i32 13, i32 14, i32 17>, ptr %7, align 4, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 24, ptr %14, align 4, !tbaa !9
  store <4 x i32> <i32 18, i32 21, i32 23, i32 26>, ptr %9, align 4, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %9, i64 16
  store i32 30, ptr %15, align 4, !tbaa !9
  %16 = tail call zeroext i1 @searchMatrix(ptr noundef nonnull %1, i32 noundef 5, i32 noundef 5, i32 noundef 5)
  %17 = zext i1 %16 to i32
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %17)
  %19 = tail call zeroext i1 @searchMatrix(ptr noundef nonnull %1, i32 noundef 5, i32 noundef 5, i32 noundef 20)
  %20 = zext i1 %19 to i32
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %20)
  %22 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @free(ptr noundef %22) #5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  tail call void @free(ptr noundef %23) #5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  tail call void @free(ptr noundef %24) #5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  tail call void @free(ptr noundef %25) #5
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  tail call void @free(ptr noundef %26) #5
  tail call void @free(ptr noundef nonnull %1) #5
  ret i32 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

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 = { 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 #3 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #4 = { nounwind allocsize(0) }
attributes #5 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass