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

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6Matrix6nbColsEv(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

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 @_ZNK6MatrixngEv(ptr dead_on_unwind noalias writable sret(%class.Matrix) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i1, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i1 false, ptr %7, align 1
  %11 = call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  %12 = call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  call void @_ZN6MatrixC1Eii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %11, i32 noundef %12)
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %45, %2
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = invoke noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
          to label %16 unwind label %40

16:                                               ; preds = %13
  %17 = icmp sle i32 %14, %15
  br i1 %17, label %18, label %48

18:                                               ; preds = %16
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %37, %18
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = invoke noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
          to label %22 unwind label %40

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

24:                                               ; preds = %22
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = load ptr, ptr %10, align 8, !tbaa !11
  %28 = getelementptr inbounds ptr, ptr %27, i64 5
  %29 = load ptr, ptr %28, align 8
  %30 = invoke noundef double %29(ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef %25, i32 noundef %26)
          to label %31 unwind label %40

31:                                               ; preds = %24
  %32 = fneg double %30
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %33, i32 noundef %34)
          to label %36 unwind label %40

36:                                               ; preds = %31
  store double %32, ptr %35, align 8, !tbaa !13
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %6, align 4, !tbaa !9
  br label %19, !llvm.loop !15

40:                                               ; preds = %31, %24, %19, %13
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %8, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %9, align 4
  call void @_ZN6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %52

44:                                               ; preds = %22
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %5, align 4, !tbaa !9
  br label %13, !llvm.loop !17

48:                                               ; preds = %16
  store i1 true, ptr %7, align 1
  %49 = load i1, ptr %7, align 1
  br i1 %49, label %51, label %50

50:                                               ; preds = %48
  call void @_ZN6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  br label %51

51:                                               ; preds = %50, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void

52:                                               ; preds = %40
  %53 = load ptr, ptr %8, align 8
  %54 = load i32, ptr %9, align 4
  %55 = insertvalue { ptr, i32 } poison, ptr %53, 0
  %56 = insertvalue { ptr, i32 } %55, i32 %54, 1
  resume { ptr, i32 } %56
}

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}


; 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 @_ZNK6MatrixngEv(ptr dead_on_unwind noalias writable sret(%class.Matrix) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %4 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  tail call void @_ZN6MatrixC1Eii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %3, i32 noundef %4)
  %5 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not15 = icmp slt i32 %5, 1
  br i1 %.not15, label %._crit_edge17, label %.preheader

.preheader:                                       ; preds = %2, %._crit_edge
  %.016 = phi i32 [ %18, %._crit_edge ], [ 1, %2 ]
  %6 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not1213 = icmp slt i32 %6, 1
  br i1 %.not1213, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %11
  %.01114 = phi i32 [ %14, %11 ], [ 1, %.preheader ]
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 40
  %9 = load ptr, ptr %8, align 8
  %10 = invoke noundef double %9(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.016, i32 noundef %.01114)
          to label %11 unwind label %16

11:                                               ; preds = %.lr.ph
  %12 = fneg double %10
  %13 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.016, i32 noundef %.01114)
  store double %12, ptr %13, align 8, !tbaa !8
  %14 = add nuw nsw i32 %.01114, 1
  %15 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not12.not = icmp slt i32 %.01114, %15
  br i1 %.not12.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

16:                                               ; preds = %.lr.ph
  %17 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  resume { ptr, i32 } %17

._crit_edge:                                      ; preds = %11, %.preheader
  %18 = add nuw nsw i32 %.016, 1
  %19 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not.not = icmp slt i32 %.016, %19
  br i1 %.not.not, label %.preheader, label %._crit_edge17, !llvm.loop !13

._crit_edge17:                                    ; preds = %._crit_edge, %2
  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 = !{!6, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"double", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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