; LLVM IR from facebookresearch/StarSpace :: src (model)

; 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.boost::numeric::ublas::matrix_row" = type { %"class.boost::numeric::ublas::matrix_reference", i64 }
%"class.boost::numeric::ublas::matrix_reference" = type { ptr }

declare i32 @__gxx_personality_v0(...)

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

; 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
declare dso_local noundef float @_ZN9starspace3dotEN5boost7numeric5ublas10matrix_rowINS2_6matrixIfNS2_15basic_row_majorImlEENS2_15unbounded_arrayIfSaIfEEEEEEESB_(ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN9starspace10EmbedModel6cosineERKN5boost7numeric5ublas10matrix_rowINS3_6matrixIfNS3_15basic_row_majorImlEENS3_15unbounded_arrayIfSaIfEEEEEEESE_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca float, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %8 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %13 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %14 = alloca i32, align 4
  %15 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %16 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %17, i64 16, i1 false)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %18, i64 16, i1 false)
  %19 = invoke noundef float @_ZN9starspace3dotEN5boost7numeric5ublas10matrix_rowINS2_6matrixIfNS2_15basic_row_majorImlEENS2_15unbounded_arrayIfSaIfEEEEEEESB_(ptr noundef %7, ptr noundef %8)
          to label %20 unwind label %33

20:                                               ; preds = %2
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #4
  store float %19, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %21, i64 16, i1 false)
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %22, i64 16, i1 false)
  %23 = invoke noundef float @_ZN9starspace3dotEN5boost7numeric5ublas10matrix_rowINS2_6matrixIfNS2_15basic_row_majorImlEENS2_15unbounded_arrayIfSaIfEEEEEEESB_(ptr noundef %12, ptr noundef %13)
          to label %24 unwind label %37

24:                                               ; preds = %20
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %12) #4
  store float %23, ptr %11, align 4, !tbaa !9
  %25 = load float, ptr %6, align 4, !tbaa !9
  %26 = fpext float %25 to double
  %27 = fcmp oeq double %26, 0.000000e+00
  br i1 %27, label %32, label %28

28:                                               ; preds = %24
  %29 = load float, ptr %11, align 4, !tbaa !9
  %30 = fpext float %29 to double
  %31 = fcmp oeq double %30, 0.000000e+00
  br i1 %31, label %32, label %41

32:                                               ; preds = %28, %24
  store float 0.000000e+00, ptr %3, align 4
  store i32 1, ptr %14, align 4
  br label %56

33:                                               ; preds = %2
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %9, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %10, align 4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #4
  br label %59

37:                                               ; preds = %20
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %9, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %10, align 4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %12) #4
  br label %58

41:                                               ; preds = %28
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %42, i64 16, i1 false)
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %43, i64 16, i1 false)
  %44 = invoke noundef float @_ZN9starspace3dotEN5boost7numeric5ublas10matrix_rowINS2_6matrixIfNS2_15basic_row_majorImlEENS2_15unbounded_arrayIfSaIfEEEEEEESB_(ptr noundef %15, ptr noundef %16)
          to label %45 unwind label %52

45:                                               ; preds = %41
  %46 = load float, ptr %6, align 4, !tbaa !9
  %47 = load float, ptr %11, align 4, !tbaa !9
  %48 = fmul float %46, %47
  %49 = invoke noundef float @_ZSt4sqrtf(float noundef %48)
          to label %50 unwind label %52

50:                                               ; preds = %45
  %51 = fdiv float %44, %49
  store float %51, ptr %3, align 4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %16) #4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %15) #4
  store i32 1, ptr %14, align 4
  br label %56

52:                                               ; preds = %45, %41
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %9, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %10, align 4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %16) #4
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %15) #4
  br label %58

56:                                               ; preds = %50, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %57 = load float, ptr %3, align 4
  ret float %57

58:                                               ; preds = %52, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %59

59:                                               ; preds = %58, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr %9, align 8
  %62 = load i32, ptr %10, align 4
  %63 = insertvalue { ptr, i32 } poison, ptr %61, 0
  %64 = insertvalue { ptr, i32 } %63, i32 %62, 1
  resume { ptr, i32 } %64
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) #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 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !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"

%"class.boost::numeric::ublas::matrix_row" = type { %"class.boost::numeric::ublas::matrix_reference", i64 }
%"class.boost::numeric::ublas::matrix_reference" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN9starspace3dotEN5boost7numeric5ublas10matrix_rowINS2_6matrixIfNS2_15basic_row_majorImlEENS2_15unbounded_arrayIfSaIfEEEEEEESB_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN9starspace10EmbedModel6cosineERKN5boost7numeric5ublas10matrix_rowINS3_6matrixIfNS3_15basic_row_majorImlEENS3_15unbounded_arrayIfSaIfEEEEEEESE_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %4 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %5 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %6 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %7 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  %8 = alloca %"class.boost::numeric::ublas::matrix_row", align 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %0, i64 16, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %0, i64 16, i1 false)
  %9 = invoke noundef float @_ZN9starspace3dotEN5boost7numeric5ublas10matrix_rowINS2_6matrixIfNS2_15basic_row_majorImlEENS2_15unbounded_arrayIfSaIfEEEEEEESB_(ptr noundef nonnull %3, ptr noundef nonnull %4)
          to label %10 unwind label %15

10:                                               ; preds = %2
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %1, i64 16, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %1, i64 16, i1 false)
  %11 = invoke noundef float @_ZN9starspace3dotEN5boost7numeric5ublas10matrix_rowINS2_6matrixIfNS2_15basic_row_majorImlEENS2_15unbounded_arrayIfSaIfEEEEEEESB_(ptr noundef nonnull %5, ptr noundef nonnull %6)
          to label %12 unwind label %17

12:                                               ; preds = %10
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #3
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #3
  %13 = fcmp oeq float %9, 0.000000e+00
  %14 = fcmp oeq float %11, 0.000000e+00
  %or.cond = or i1 %13, %14
  br i1 %or.cond, label %27, label %19

15:                                               ; preds = %2
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %28

17:                                               ; preds = %10
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %28

19:                                               ; preds = %12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(16) %0, i64 16, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %1, i64 16, i1 false)
  %20 = invoke noundef float @_ZN9starspace3dotEN5boost7numeric5ublas10matrix_rowINS2_6matrixIfNS2_15basic_row_majorImlEENS2_15unbounded_arrayIfSaIfEEEEEEESB_(ptr noundef nonnull %7, ptr noundef nonnull %8)
          to label %21 unwind label %25

21:                                               ; preds = %19
  %22 = fmul float %9, %11
  %23 = call noundef float @_ZSt4sqrtf(float noundef %22)
  %24 = fdiv float %20, %23
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #3
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #3
  br label %27

25:                                               ; preds = %19
  %26 = landingpad { ptr, i32 }
          cleanup
  br label %28

27:                                               ; preds = %12, %21
  %.0 = phi float [ %24, %21 ], [ 0.000000e+00, %12 ]
  ret float %.0

28:                                               ; preds = %17, %25, %15
  %.sink17 = phi ptr [ %6, %17 ], [ %8, %25 ], [ %4, %15 ]
  %.sink = phi ptr [ %5, %17 ], [ %7, %25 ], [ %3, %15 ]
  %.pn.pn = phi { ptr, i32 } [ %18, %17 ], [ %26, %25 ], [ %16, %15 ]
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %.sink17) #3
  call void @_ZN5boost7numeric5ublas10matrix_rowINS1_6matrixIfNS1_15basic_row_majorImlEENS1_15unbounded_arrayIfSaIfEEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %.sink) #3
  resume { ptr, i32 } %.pn.pn
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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)"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass