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

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

; 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 @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z5angleRK6VectorS1_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 1, ptr %9, align 4, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call noundef i32 @_ZNK6Matrix11isAllocatedEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %17

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call noundef i32 @_ZNK6Matrix11isAllocatedEv(ptr noundef nonnull align 8 dereferenceable(24) %14)
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %19, label %17

17:                                               ; preds = %13, %2
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef @.str.3)
  br label %19

19:                                               ; preds = %17, %13
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %20)
  %22 = icmp ne i32 %21, 1
  br i1 %22, label %27, label %23

23:                                               ; preds = %19
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %24)
  %26 = icmp ne i32 %25, 1
  br i1 %26, label %27, label %29

27:                                               ; preds = %23, %19
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %28, ptr noundef @.str.4)
  br label %29

29:                                               ; preds = %27, %23
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %30)
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %32)
  %34 = icmp ne i32 %31, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %29
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %36, ptr noundef @.str.5)
  br label %37

37:                                               ; preds = %35, %29
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %38)
  %40 = icmp eq i32 %39, 2
  br i1 %40, label %41, label %70

41:                                               ; preds = %37
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = getelementptr inbounds ptr, ptr %43, i64 9
  %45 = load ptr, ptr %44, align 8
  %46 = call noundef double %45(ptr noundef nonnull align 8 dereferenceable(32) %42, i32 noundef 1)
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = getelementptr inbounds ptr, ptr %48, i64 9
  %50 = load ptr, ptr %49, align 8
  %51 = call noundef double %50(ptr noundef nonnull align 8 dereferenceable(32) %47, i32 noundef 2)
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = load ptr, ptr %52, align 8, !tbaa !11
  %54 = getelementptr inbounds ptr, ptr %53, i64 9
  %55 = load ptr, ptr %54, align 8
  %56 = call noundef double %55(ptr noundef nonnull align 8 dereferenceable(32) %52, i32 noundef 2)
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load ptr, ptr %57, align 8, !tbaa !11
  %59 = getelementptr inbounds ptr, ptr %58, i64 9
  %60 = load ptr, ptr %59, align 8
  %61 = call noundef double %60(ptr noundef nonnull align 8 dereferenceable(32) %57, i32 noundef 1)
  %62 = fmul double %56, %61
  %63 = fneg double %62
  %64 = call double @llvm.fmuladd.f64(double %46, double %51, double %63)
  %65 = call double @llvm.fabs.f64(double %64)
  %66 = fcmp ogt double %65, 0.000000e+00
  br i1 %66, label %67, label %68

67:                                               ; preds = %41
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %69

68:                                               ; preds = %41
  store i32 -1, ptr %9, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %68, %67
  br label %70

70:                                               ; preds = %69, %37
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = call noundef double @_ZNK6Matrix5norm2Ev(ptr noundef nonnull align 8 dereferenceable(24) %71)
  store double %72, ptr %5, align 8, !tbaa !13
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = call noundef double @_ZNK6Matrix5norm2Ev(ptr noundef nonnull align 8 dereferenceable(24) %73)
  store double %74, ptr %6, align 8, !tbaa !13
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = call noundef double @_Z3dotRK6MatrixS1_(ptr noundef nonnull align 8 dereferenceable(24) %75, ptr noundef nonnull align 8 dereferenceable(24) %76)
  store double %77, ptr %7, align 8, !tbaa !13
  %78 = load double, ptr %7, align 8, !tbaa !13
  %79 = fmul double 1.000000e+00, %78
  %80 = load double, ptr %5, align 8, !tbaa !13
  %81 = load double, ptr %6, align 8, !tbaa !13
  %82 = fmul double %80, %81
  %83 = fdiv double %79, %82
  store double %83, ptr %8, align 8, !tbaa !13
  %84 = load double, ptr %8, align 8, !tbaa !13
  %85 = fcmp ogt double %84, 1.000000e+00
  br i1 %85, label %86, label %87

86:                                               ; preds = %70
  store double 1.000000e+00, ptr %8, align 8, !tbaa !13
  br label %92

87:                                               ; preds = %70
  %88 = load double, ptr %8, align 8, !tbaa !13
  %89 = fcmp olt double %88, -1.000000e+00
  br i1 %89, label %90, label %91

90:                                               ; preds = %87
  store double -1.000000e+00, ptr %8, align 8, !tbaa !13
  br label %91

91:                                               ; preds = %90, %87
  br label %92

92:                                               ; preds = %91, %86
  %93 = load i32, ptr %9, align 4, !tbaa !9
  %94 = sitofp i32 %93 to double
  %95 = load double, ptr %8, align 8, !tbaa !13
  %96 = call double @acos(double noundef %95) #6
  %97 = fmul double %94, %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret double %97
}

declare noundef i32 @_ZNK6Matrix11isAllocatedEv(ptr noundef nonnull align 8 dereferenceable(24)) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #4

declare noundef double @_ZNK6Matrix5norm2Ev(ptr noundef nonnull align 8 dereferenceable(24)) #2

declare noundef double @_Z3dotRK6MatrixS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #2

; Function Attrs: nounwind
declare double @acos(double noundef) #5

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #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++ 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}


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

; 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 @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z5angleRK6VectorS1_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #2 {
  %3 = tail call noundef i32 @_ZNK6Matrix11isAllocatedEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %6, label %4

4:                                                ; preds = %2
  %5 = tail call noundef i32 @_ZNK6Matrix11isAllocatedEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not26 = icmp eq i32 %5, 0
  br i1 %.not26, label %6, label %7

6:                                                ; preds = %4, %2
  tail call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull @.str.3)
  br label %7

7:                                                ; preds = %6, %4
  %8 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %.not27 = icmp eq i32 %8, 1
  br i1 %.not27, label %9, label %11

9:                                                ; preds = %7
  %10 = tail call noundef i32 @_ZNK6Matrix6nbColsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not28 = icmp eq i32 %10, 1
  br i1 %.not28, label %12, label %11

11:                                               ; preds = %9, %7
  tail call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull @.str.4)
  br label %12

12:                                               ; preds = %11, %9
  %13 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %14 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not29 = icmp eq i32 %13, %14
  br i1 %.not29, label %16, label %15

15:                                               ; preds = %12
  tail call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull @.str.5)
  br label %16

16:                                               ; preds = %15, %12
  %17 = tail call noundef i32 @_ZNK6Matrix6nbRowsEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %19, label %40

19:                                               ; preds = %16
  %20 = load ptr, ptr %0, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 72
  %22 = load ptr, ptr %21, align 8
  %23 = tail call noundef double %22(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 1)
  %24 = load ptr, ptr %1, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 72
  %26 = load ptr, ptr %25, align 8
  %27 = tail call noundef double %26(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 2)
  %28 = load ptr, ptr %0, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 72
  %30 = load ptr, ptr %29, align 8
  %31 = tail call noundef double %30(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 2)
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 72
  %34 = load ptr, ptr %33, align 8
  %35 = tail call noundef double %34(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 1)
  %36 = fneg double %31
  %37 = fmul double %35, %36
  %38 = tail call double @llvm.fmuladd.f64(double %23, double %27, double %37)
  %39 = fcmp ueq double %38, 0.000000e+00
  %. = select i1 %39, double -1.000000e+00, double 1.000000e+00
  br label %40

40:                                               ; preds = %19, %16
  %.0 = phi double [ 1.000000e+00, %16 ], [ %., %19 ]
  %41 = tail call noundef double @_ZNK6Matrix5norm2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %42 = tail call noundef double @_ZNK6Matrix5norm2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %43 = tail call noundef double @_Z3dotRK6MatrixS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %44 = fmul double %41, %42
  %45 = fdiv double %43, %44
  %46 = fcmp ogt double %45, 1.000000e+00
  br i1 %46, label %50, label %47

47:                                               ; preds = %40
  %48 = fcmp olt double %45, -1.000000e+00
  br i1 %48, label %49, label %50

49:                                               ; preds = %47
  br label %50

50:                                               ; preds = %40, %47, %49
  %.024 = phi double [ -1.000000e+00, %49 ], [ %45, %47 ], [ 1.000000e+00, %40 ]
  %51 = tail call double @acos(double noundef %.024) #5
  %52 = fmul double %.0, %51
  ret double %52
}

declare noundef i32 @_ZNK6Matrix11isAllocatedEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

declare noundef double @_ZNK6Matrix5norm2Ev(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

declare noundef double @_Z3dotRK6MatrixS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @acos(double noundef) local_unnamed_addr #4

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 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { mustprogress nofree nounwind willreturn memory(write) "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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass