; LLVM IR from ox-vgg/vise :: src/search_engine/relja_retrival/external/KMCode_relja/matrix (manip)

; 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.Matrix = type { ptr, ptr, i32, i32 }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

declare void @_ZN6MatrixC1Eii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) unnamed_addr #1 align 2

; Function Attrs: nounwind
declare void @_ZN6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK6Matrix7delColsEii(ptr dead_on_unwind noalias writable sret(%class.Matrix) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2, i32 noundef %3) #4 align 2 personality ptr @__gxx_personality_v0 {
  %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 i1, align 1
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8
  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
  %14 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i1 false, ptr %11, align 1
  %15 = call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %14)
  %16 = call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %14)
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = sub nsw i32 %16, %17
  call void @_ZN6MatrixC1Eii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %15, i32 noundef %18)
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %73, %4
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = invoke noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %14)
          to label %22 unwind label %44

22:                                               ; preds = %19
  %23 = icmp sle i32 %20, %21
  br i1 %23, label %24, label %76

24:                                               ; preds = %22
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %41, %24
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %48

29:                                               ; preds = %25
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = load ptr, ptr %14, align 8, !tbaa !11
  %33 = getelementptr inbounds ptr, ptr %32, i64 5
  %34 = load ptr, ptr %33, align 8
  %35 = invoke noundef double %34(ptr noundef nonnull align 8 dereferenceable(24) %14, i32 noundef %30, i32 noundef %31)
          to label %36 unwind label %44

36:                                               ; preds = %29
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %37, i32 noundef %38)
          to label %40 unwind label %44

40:                                               ; preds = %36
  store double %35, ptr %39, align 8, !tbaa !13
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %10, align 4, !tbaa !9
  br label %25, !llvm.loop !15

44:                                               ; preds = %64, %55, %50, %36, %29, %19
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %12, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %13, align 4
  call void @_ZN6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %80

48:                                               ; preds = %25
  %49 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %49, ptr %10, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %69, %48
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = invoke noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %53 unwind label %44

53:                                               ; preds = %50
  %54 = icmp slt i32 %51, %52
  br i1 %54, label %55, label %72

55:                                               ; preds = %53
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = load i32, ptr %10, align 4, !tbaa !9
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = add nsw i32 %57, %58
  %60 = load ptr, ptr %14, align 8, !tbaa !11
  %61 = getelementptr inbounds ptr, ptr %60, i64 5
  %62 = load ptr, ptr %61, align 8
  %63 = invoke noundef double %62(ptr noundef nonnull align 8 dereferenceable(24) %14, i32 noundef %56, i32 noundef %59)
          to label %64 unwind label %44

64:                                               ; preds = %55
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = load i32, ptr %10, align 4, !tbaa !9
  %67 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %65, i32 noundef %66)
          to label %68 unwind label %44

68:                                               ; preds = %64
  store double %63, ptr %67, align 8, !tbaa !13
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %10, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %10, align 4, !tbaa !9
  br label %50, !llvm.loop !17

72:                                               ; preds = %53
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %9, align 4, !tbaa !9
  br label %19, !llvm.loop !18

76:                                               ; preds = %22
  store i1 true, ptr %11, align 1
  %77 = load i1, ptr %11, align 1
  br i1 %77, label %79, label %78

78:                                               ; preds = %76
  call void @_ZN6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  br label %79

79:                                               ; preds = %78, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret void

80:                                               ; preds = %44
  %81 = load ptr, ptr %12, align 8
  %82 = load i32, ptr %13, align 4
  %83 = insertvalue { ptr, i32 } poison, ptr %81, 0
  %84 = insertvalue { ptr, i32 } %83, i32 %82, 1
  resume { ptr, i32 } %84
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; 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.Matrix = type { ptr, ptr, i32, i32 }

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

declare void @_ZN6MatrixC1Eii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) unnamed_addr #0 align 2

; Function Attrs: nounwind
declare void @_ZN6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK6Matrix7delColsEii(ptr dead_on_unwind noalias writable sret(%class.Matrix) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %6 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %7 = sub nsw i32 %6, %3
  tail call void @_ZN6MatrixC1Eii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %5, i32 noundef %7)
  %8 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not27 = icmp slt i32 %8, 1
  br i1 %.not27, label %._crit_edge29, label %.preheader23.lr.ph

.preheader23.lr.ph:                               ; preds = %4
  %9 = icmp sgt i32 %2, 1
  br i1 %9, label %.preheader23.us, label %.preheader23

.preheader23.us:                                  ; preds = %.preheader23.lr.ph, %._crit_edge.us
  %.028.us = phi i32 [ %10, %._crit_edge.us ], [ 1, %.preheader23.lr.ph ]
  br label %22

._crit_edge.us:                                   ; preds = %17, %..preheader_crit_edge.us
  %10 = add nuw nsw i32 %.028.us, 1
  %11 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not.us.not = icmp slt i32 %.028.us, %11
  br i1 %.not.us.not, label %.preheader23.us, label %._crit_edge29, !llvm.loop !5

.lr.ph26.us:                                      ; preds = %..preheader_crit_edge.us, %17
  %.125.us = phi i32 [ %19, %17 ], [ %2, %..preheader_crit_edge.us ]
  %12 = add nsw i32 %.125.us, %3
  %13 = load ptr, ptr %1, align 8, !tbaa !7
  %14 = getelementptr inbounds i8, ptr %13, i64 40
  %15 = load ptr, ptr %14, align 8
  %16 = invoke noundef double %15(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.028.us, i32 noundef %12)
          to label %17 unwind label %.loopexit.split.us

17:                                               ; preds = %.lr.ph26.us
  %18 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.028.us, i32 noundef %.125.us)
  store double %16, ptr %18, align 8, !tbaa !10
  %19 = add nuw nsw i32 %.125.us, 1
  %20 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %.lr.ph26.us, label %._crit_edge.us, !llvm.loop !13

22:                                               ; preds = %.preheader23.us, %27
  %.02124.us = phi i32 [ 1, %.preheader23.us ], [ %29, %27 ]
  %23 = load ptr, ptr %1, align 8, !tbaa !7
  %24 = getelementptr inbounds i8, ptr %23, i64 40
  %25 = load ptr, ptr %24, align 8
  %26 = invoke noundef double %25(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.028.us, i32 noundef %.02124.us)
          to label %27 unwind label %.loopexit.split-lp.split.us

27:                                               ; preds = %22
  %28 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.028.us, i32 noundef %.02124.us)
  store double %26, ptr %28, align 8, !tbaa !10
  %29 = add nuw nsw i32 %.02124.us, 1
  %exitcond.not = icmp eq i32 %29, %2
  br i1 %exitcond.not, label %..preheader_crit_edge.us, label %22, !llvm.loop !14

..preheader_crit_edge.us:                         ; preds = %27
  %30 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %31 = icmp sgt i32 %30, %2
  br i1 %31, label %.lr.ph26.us, label %._crit_edge.us

.loopexit.split.us:                               ; preds = %.lr.ph26.us
  %lpad.loopexit.us = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit

.loopexit.split-lp.split.us:                      ; preds = %22
  %lpad.loopexit.split-lp.us = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit

.preheader23:                                     ; preds = %.preheader23.lr.ph, %._crit_edge
  %.028 = phi i32 [ %44, %._crit_edge ], [ 1, %.preheader23.lr.ph ]
  %32 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %33 = icmp sgt i32 %32, %2
  br i1 %33, label %.lr.ph26, label %._crit_edge

.loopexit.split:                                  ; preds = %.lr.ph26
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.split, %.loopexit.split.us, %.loopexit.split-lp.split.us
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit.split-lp.us, %.loopexit.split-lp.split.us ], [ %lpad.loopexit, %.loopexit.split ], [ %lpad.loopexit.us, %.loopexit.split.us ]
  tail call void @_ZN6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  resume { ptr, i32 } %lpad.phi

.lr.ph26:                                         ; preds = %.preheader23, %39
  %.125 = phi i32 [ %41, %39 ], [ %2, %.preheader23 ]
  %34 = add nsw i32 %.125, %3
  %35 = load ptr, ptr %1, align 8, !tbaa !7
  %36 = getelementptr inbounds i8, ptr %35, i64 40
  %37 = load ptr, ptr %36, align 8
  %38 = invoke noundef double %37(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.028, i32 noundef %34)
          to label %39 unwind label %.loopexit.split

39:                                               ; preds = %.lr.ph26
  %40 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.028, i32 noundef %.125)
  store double %38, ptr %40, align 8, !tbaa !10
  %41 = add nsw i32 %.125, 1
  %42 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %.lr.ph26, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %39, %.preheader23
  %44 = add nuw nsw i32 %.028, 1
  %45 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not.not = icmp slt i32 %.028, %45
  br i1 %.not.not, label %.preheader23, label %._crit_edge29, !llvm.loop !5

._crit_edge29:                                    ; preds = %._crit_edge, %._crit_edge.us, %4
  ret void
}

attributes #0 = { 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 #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" }
attributes #2 = { 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 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"vtable pointer", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !12, i64 0}
!12 = !{!"omnipotent char", !9, i64 0}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}


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