; LLVM IR from o0o0o0o0o0o0o/image-processing-from-scratch :: ImageMatting/Eigen/blas (double)

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

%"class.Eigen::Map.9" = type { %"class.Eigen::MapBase.base.19", [7 x i8] }
%"class.Eigen::MapBase.base.19" = type { %"class.Eigen::MapBase.base.18" }
%"class.Eigen::MapBase.base.18" = type <{ ptr, %"class.Eigen::internal::variable_if_dynamic", i8 }>
%"class.Eigen::internal::variable_if_dynamic" = type { i64 }

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11make_vectorIdEN5Eigen3MapINS0_6MatrixIT_Lin1ELi1ELi0ELin1ELi1EEELi0ENS0_6StrideILi0ELi0EEEEEPS3_i(ptr dead_on_unwind noalias writable sret(%"class.Eigen::Map.9") align 8, ptr noundef, i32 noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @dcopy_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca %"class.Eigen::Map.9", align 8
  %15 = alloca %"class.Eigen::Map.9", align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = icmp sle i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  br label %95

21:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %22, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %23, ptr %13, align 8, !tbaa !5
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %39

27:                                               ; preds = %21
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %39

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #3
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load i32, ptr %33, align 4, !tbaa !9
  call void @_Z11make_vectorIdEN5Eigen3MapINS0_6MatrixIT_Lin1ELi1ELi0ELin1ELi1EEELi0ENS0_6StrideILi0ELi0EEEEEPS3_i(ptr dead_on_unwind writable sret(%"class.Eigen::Map.9") align 8 %14, ptr noundef %32, i32 noundef %34)
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #3
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load i32, ptr %36, align 4, !tbaa !9
  call void @_Z11make_vectorIdEN5Eigen3MapINS0_6MatrixIT_Lin1ELi1ELi0ELin1ELi1EEELi0ENS0_6StrideILi0ELi0EEEEEPS3_i(ptr dead_on_unwind writable sret(%"class.Eigen::Map.9") align 8 %15, ptr noundef %35, i32 noundef %37)
  %38 = call noundef nonnull align 8 dereferenceable(19) ptr @_ZN5Eigen3MapINS_6MatrixIdLin1ELi1ELi0ELin1ELi1EEELi0ENS_6StrideILi0ELi0EEEEaSERKS5_(ptr noundef nonnull align 8 dereferenceable(19) %15, ptr noundef nonnull align 8 dereferenceable(19) %14)
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #3
  br label %94

39:                                               ; preds = %27, %21
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = icmp slt i32 %41, 0
  br i1 %42, label %43, label %54

43:                                               ; preds = %39
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = sub nsw i32 %46, 1
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = mul nsw i32 %47, %49
  %51 = sext i32 %50 to i64
  %52 = sub i64 0, %51
  %53 = getelementptr inbounds double, ptr %44, i64 %52
  store ptr %53, ptr %12, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %43, %39
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = icmp slt i32 %56, 0
  br i1 %57, label %58, label %69

58:                                               ; preds = %54
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = sub nsw i32 %61, 1
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = mul nsw i32 %62, %64
  %66 = sext i32 %65 to i64
  %67 = sub i64 0, %66
  %68 = getelementptr inbounds double, ptr %59, i64 %67
  store ptr %68, ptr %13, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %58, %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %90, %69
  %71 = load i32, ptr %16, align 4, !tbaa !9
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = icmp slt i32 %71, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %93

76:                                               ; preds = %70
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = load double, ptr %77, align 8, !tbaa !11
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  store double %78, ptr %79, align 8, !tbaa !11
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = sext i32 %81 to i64
  %84 = getelementptr inbounds double, ptr %82, i64 %83
  store ptr %84, ptr %12, align 8, !tbaa !5
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = load i32, ptr %85, align 4, !tbaa !9
  %87 = load ptr, ptr %13, align 8, !tbaa !5
  %88 = sext i32 %86 to i64
  %89 = getelementptr inbounds double, ptr %87, i64 %88
  store ptr %89, ptr %13, align 8, !tbaa !5
  br label %90

90:                                               ; preds = %76
  %91 = load i32, ptr %16, align 4, !tbaa !9
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %16, align 4, !tbaa !9
  br label %70, !llvm.loop !13

93:                                               ; preds = %75
  br label %94

94:                                               ; preds = %93, %31
  store i32 0, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %95

95:                                               ; preds = %94, %20
  %96 = load i32, ptr %6, align 4
  ret i32 %96
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(19) ptr @_ZN5Eigen3MapINS_6MatrixIdLin1ELi1ELi0ELin1ELi1EEELi0ENS_6StrideILi0ELi0EEEEaSERKS5_(ptr noundef nonnull align 8 dereferenceable(19), ptr noundef nonnull align 8 dereferenceable(19)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%"class.Eigen::Map.9" = type { %"class.Eigen::MapBase.base.19", [7 x i8] }
%"class.Eigen::MapBase.base.19" = type { %"class.Eigen::MapBase.base.18" }
%"class.Eigen::MapBase.base.18" = type <{ ptr, %"class.Eigen::internal::variable_if_dynamic", i8 }>
%"class.Eigen::internal::variable_if_dynamic" = type { i64 }

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11make_vectorIdEN5Eigen3MapINS0_6MatrixIT_Lin1ELi1ELi0ELin1ELi1EEELi0ENS0_6StrideILi0ELi0EEEEEPS3_i(ptr dead_on_unwind noalias writable sret(%"class.Eigen::Map.9") align 8, ptr noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @dcopy_(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #1 {
  %6 = alloca %"class.Eigen::Map.9", align 8
  %7 = alloca %"class.Eigen::Map.9", align 8
  %8 = load i32, ptr %0, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 1
  br i1 %9, label %.loopexit, label %10

10:                                               ; preds = %5
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %13, label %thread-pre-split

13:                                               ; preds = %10
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %16, label %.lr.ph

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  call void @_Z11make_vectorIdEN5Eigen3MapINS0_6MatrixIT_Lin1ELi1ELi0ELin1ELi1EEELi0ENS0_6StrideILi0ELi0EEEEEPS3_i(ptr dead_on_unwind nonnull writable sret(%"class.Eigen::Map.9") align 8 %6, ptr noundef %1, i32 noundef %8)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  %17 = load i32, ptr %0, align 4, !tbaa !5
  call void @_Z11make_vectorIdEN5Eigen3MapINS0_6MatrixIT_Lin1ELi1ELi0ELin1ELi1EEELi0ENS0_6StrideILi0ELi0EEEEEPS3_i(ptr dead_on_unwind nonnull writable sret(%"class.Eigen::Map.9") align 8 %7, ptr noundef %3, i32 noundef %17)
  %18 = call noundef nonnull align 8 dereferenceable(19) ptr @_ZN5Eigen3MapINS_6MatrixIdLin1ELi1ELi0ELin1ELi1EEELi0ENS_6StrideILi0ELi0EEEEaSERKS5_(ptr noundef nonnull align 8 dereferenceable(19) %7, ptr noundef nonnull align 8 dereferenceable(19) %6)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  br label %.loopexit

thread-pre-split:                                 ; preds = %10
  %19 = icmp slt i32 %11, 0
  %20 = add nsw i32 %8, -1
  %21 = mul nsw i32 %11, %20
  %22 = sext i32 %21 to i64
  %23 = sub nsw i64 0, %22
  %.027.ph.idx = select i1 %19, i64 %23, i64 0
  %.027.ph = getelementptr inbounds double, ptr %1, i64 %.027.ph.idx
  %.pr = load i32, ptr %4, align 4, !tbaa !5
  br label %.lr.ph

.lr.ph:                                           ; preds = %thread-pre-split, %13
  %24 = phi i32 [ %.pr, %thread-pre-split ], [ %14, %13 ]
  %.027 = phi ptr [ %.027.ph, %thread-pre-split ], [ %1, %13 ]
  %25 = icmp slt i32 %24, 0
  %26 = add nsw i32 %8, -1
  %27 = mul nsw i32 %24, %26
  %28 = sext i32 %27 to i64
  %29 = sub nsw i64 0, %28
  %.026.idx = select i1 %25, i64 %29, i64 0
  %.026 = getelementptr inbounds double, ptr %3, i64 %.026.idx
  %30 = sext i32 %11 to i64
  %31 = sext i32 %24 to i64
  %xtraiter = and i32 %8, 7
  %32 = icmp ult i32 %8, 8
  br i1 %32, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i32 %8, 2147483640
  br label %33

33:                                               ; preds = %33, %.lr.ph.new
  %.133 = phi ptr [ %.026, %.lr.ph.new ], [ %57, %33 ]
  %.12832 = phi ptr [ %.027, %.lr.ph.new ], [ %56, %33 ]
  %niter = phi i32 [ 0, %.lr.ph.new ], [ %niter.next.7, %33 ]
  %34 = load double, ptr %.12832, align 8, !tbaa !9
  store double %34, ptr %.133, align 8, !tbaa !9
  %35 = getelementptr inbounds double, ptr %.12832, i64 %30
  %36 = getelementptr inbounds double, ptr %.133, i64 %31
  %37 = load double, ptr %35, align 8, !tbaa !9
  store double %37, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds double, ptr %35, i64 %30
  %39 = getelementptr inbounds double, ptr %36, i64 %31
  %40 = load double, ptr %38, align 8, !tbaa !9
  store double %40, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds double, ptr %38, i64 %30
  %42 = getelementptr inbounds double, ptr %39, i64 %31
  %43 = load double, ptr %41, align 8, !tbaa !9
  store double %43, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds double, ptr %41, i64 %30
  %45 = getelementptr inbounds double, ptr %42, i64 %31
  %46 = load double, ptr %44, align 8, !tbaa !9
  store double %46, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds double, ptr %44, i64 %30
  %48 = getelementptr inbounds double, ptr %45, i64 %31
  %49 = load double, ptr %47, align 8, !tbaa !9
  store double %49, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds double, ptr %47, i64 %30
  %51 = getelementptr inbounds double, ptr %48, i64 %31
  %52 = load double, ptr %50, align 8, !tbaa !9
  store double %52, ptr %51, align 8, !tbaa !9
  %53 = getelementptr inbounds double, ptr %50, i64 %30
  %54 = getelementptr inbounds double, ptr %51, i64 %31
  %55 = load double, ptr %53, align 8, !tbaa !9
  store double %55, ptr %54, align 8, !tbaa !9
  %56 = getelementptr inbounds double, ptr %53, i64 %30
  %57 = getelementptr inbounds double, ptr %54, i64 %31
  %niter.next.7 = add i32 %niter, 8
  %niter.ncmp.7 = icmp eq i32 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.loopexit.loopexit.unr-lcssa, label %33, !llvm.loop !11

.loopexit.loopexit.unr-lcssa:                     ; preds = %33, %.lr.ph
  %.133.unr = phi ptr [ %.026, %.lr.ph ], [ %57, %33 ]
  %.12832.unr = phi ptr [ %.027, %.lr.ph ], [ %56, %33 ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader
  %.133.epil = phi ptr [ %60, %.epil.preheader ], [ %.133.unr, %.loopexit.loopexit.unr-lcssa ]
  %.12832.epil = phi ptr [ %59, %.epil.preheader ], [ %.12832.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.epil.preheader ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %58 = load double, ptr %.12832.epil, align 8, !tbaa !9
  store double %58, ptr %.133.epil, align 8, !tbaa !9
  %59 = getelementptr inbounds double, ptr %.12832.epil, i64 %30
  %60 = getelementptr inbounds double, ptr %.133.epil, i64 %31
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.epil.preheader, !llvm.loop !13

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader, %16, %5
  ret i32 0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(19) ptr @_ZN5Eigen3MapINS_6MatrixIdLin1ELi1ELi0ELin1ELi1EEELi0ENS_6StrideILi0ELi0EEEEaSERKS5_(ptr noundef nonnull align 8 dereferenceable(19), ptr noundef nonnull align 8 dereferenceable(19)) local_unnamed_addr #2 align 2

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


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