; LLVM IR from microsoft/Multiverso :: Applications/WordEmbedding/src (util)

; 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.wordembedding::Sampler" = type { ptr }
%"struct.wordembedding::WordInfo" = type { %"class.std::__cxx11::basic_string", i64 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str.66 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [94 x i8], align 1
@__PRETTY_FUNCTION__._ZN13wordembedding7Sampler31SetNegativeSamplingDistributionEPNS_10DictionaryE = external hidden unnamed_addr constant [75 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: 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 void @_ZN13wordembedding7Sampler31SetNegativeSamplingDistributionEPNS_10DictionaryE(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store float 0.000000e+00, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store float 7.500000e-01, ptr %6, align 4, !tbaa !9
  %12 = call noalias ptr @malloc(i64 noundef 400000000) #7
  %13 = getelementptr inbounds %"class.wordembedding::Sampler", ptr %11, i32 0, i32 0
  store ptr %12, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !13
  br label %14

14:                                               ; preds = %33, %2
  %15 = load i32, ptr %7, align 4, !tbaa !13
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef i32 @_ZN13wordembedding10Dictionary4SizeEv(ptr noundef nonnull align 8 dereferenceable(152) %16)
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %36

20:                                               ; preds = %14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load i32, ptr %7, align 4, !tbaa !13
  %23 = call noundef ptr @_ZN13wordembedding10Dictionary11GetWordInfoEi(ptr noundef nonnull align 8 dereferenceable(152) %21, i32 noundef %22)
  %24 = getelementptr inbounds %"struct.wordembedding::WordInfo", ptr %23, i32 0, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !15
  %26 = sitofp i64 %25 to double
  %27 = load float, ptr %6, align 4, !tbaa !9
  %28 = fpext float %27 to double
  %29 = call double @pow(double noundef %26, double noundef %28) #6
  %30 = fptrunc double %29 to float
  %31 = load float, ptr %5, align 4, !tbaa !9
  %32 = fadd float %31, %30
  store float %32, ptr %5, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %20
  %34 = load i32, ptr %7, align 4, !tbaa !13
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %7, align 4, !tbaa !13
  br label %14, !llvm.loop !20

36:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !13
  %39 = call noundef ptr @_ZN13wordembedding10Dictionary11GetWordInfoEi(ptr noundef nonnull align 8 dereferenceable(152) %37, i32 noundef %38)
  %40 = getelementptr inbounds %"struct.wordembedding::WordInfo", ptr %39, i32 0, i32 1
  %41 = load i64, ptr %40, align 8, !tbaa !15
  %42 = sitofp i64 %41 to double
  %43 = load float, ptr %6, align 4, !tbaa !9
  %44 = fpext float %43 to double
  %45 = call double @pow(double noundef %42, double noundef %44) #6
  %46 = fptrunc double %45 to float
  %47 = load float, ptr %5, align 4, !tbaa !9
  %48 = fdiv float %46, %47
  store float %48, ptr %9, align 4, !tbaa !9
  %49 = getelementptr inbounds %"class.wordembedding::Sampler", ptr %11, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %53

52:                                               ; preds = %36
  br label %55

53:                                               ; preds = %36
  call void @__assert_fail(ptr noundef @.str.66, ptr noundef @.str.67, i32 noundef 126, ptr noundef @__PRETTY_FUNCTION__._ZN13wordembedding7Sampler31SetNegativeSamplingDistributionEPNS_10DictionaryE) #8
  unreachable

54:                                               ; No predecessors!
  br label %55

55:                                               ; preds = %54, %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !13
  br label %56

56:                                               ; preds = %96, %55
  %57 = load i32, ptr %10, align 4, !tbaa !13
  %58 = icmp slt i32 %57, 100000000
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %56
  %61 = load i32, ptr %8, align 4, !tbaa !13
  %62 = getelementptr inbounds %"class.wordembedding::Sampler", ptr %11, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !11
  %64 = load i32, ptr %10, align 4, !tbaa !13
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i32, ptr %63, i64 %65
  store i32 %61, ptr %66, align 4, !tbaa !13
  %67 = load i32, ptr %10, align 4, !tbaa !13
  %68 = sitofp i32 %67 to float
  %69 = load float, ptr %9, align 4, !tbaa !9
  %70 = fmul float %69, 1.000000e+08
  %71 = fcmp ogt float %68, %70
  br i1 %71, label %72, label %95

72:                                               ; preds = %60
  %73 = load i32, ptr %8, align 4, !tbaa !13
  %74 = add nsw i32 %73, 1
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = call noundef i32 @_ZN13wordembedding10Dictionary4SizeEv(ptr noundef nonnull align 8 dereferenceable(152) %75)
  %77 = icmp slt i32 %74, %76
  br i1 %77, label %78, label %95

78:                                               ; preds = %72
  %79 = load i32, ptr %8, align 4, !tbaa !13
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %8, align 4, !tbaa !13
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = load i32, ptr %8, align 4, !tbaa !13
  %83 = call noundef ptr @_ZN13wordembedding10Dictionary11GetWordInfoEi(ptr noundef nonnull align 8 dereferenceable(152) %81, i32 noundef %82)
  %84 = getelementptr inbounds %"struct.wordembedding::WordInfo", ptr %83, i32 0, i32 1
  %85 = load i64, ptr %84, align 8, !tbaa !15
  %86 = sitofp i64 %85 to double
  %87 = load float, ptr %6, align 4, !tbaa !9
  %88 = fpext float %87 to double
  %89 = call double @pow(double noundef %86, double noundef %88) #6
  %90 = fptrunc double %89 to float
  %91 = load float, ptr %5, align 4, !tbaa !9
  %92 = fdiv float %90, %91
  %93 = load float, ptr %9, align 4, !tbaa !9
  %94 = fadd float %93, %92
  store float %94, ptr %9, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %78, %72, %60
  br label %96

96:                                               ; preds = %95
  %97 = load i32, ptr %10, align 4, !tbaa !13
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %10, align 4, !tbaa !13
  br label %56, !llvm.loop !22

99:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  ret void
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

declare noundef i32 @_ZN13wordembedding10Dictionary4SizeEv(ptr noundef nonnull align 8 dereferenceable(152)) #3

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #4

declare noundef ptr @_ZN13wordembedding10Dictionary11GetWordInfoEi(ptr noundef nonnull align 8 dereferenceable(152), i32 noundef) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

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 = { nounwind allocsize(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 = { "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 "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 = { noreturn 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 }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { noreturn 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}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN13wordembedding7SamplerE", !6, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !19, i64 32}
!16 = !{!"_ZTSN13wordembedding8WordInfoE", !17, i64 0, !19, i64 32}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !18, i64 0, !19, i64 8, !7, i64 16}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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.66 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [94 x i8], align 1
@__PRETTY_FUNCTION__._ZN13wordembedding7Sampler31SetNegativeSamplingDistributionEPNS_10DictionaryE = external hidden unnamed_addr constant [75 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13wordembedding7Sampler31SetNegativeSamplingDistributionEPNS_10DictionaryE(ptr nocapture noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noalias dereferenceable_or_null(400000000) ptr @malloc(i64 noundef 400000000) #5
  store ptr %3, ptr %0, align 8, !tbaa !5
  %4 = tail call noundef i32 @_ZN13wordembedding10Dictionary4SizeEv(ptr noundef nonnull align 8 dereferenceable(152) %1)
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.029.lcssa = phi float [ 0.000000e+00, %2 ], [ %18, %.lr.ph ]
  %6 = tail call noundef ptr @_ZN13wordembedding10Dictionary11GetWordInfoEi(ptr noundef nonnull align 8 dereferenceable(152) %1, i32 noundef 0)
  %7 = getelementptr inbounds i8, ptr %6, i64 32
  %8 = load i64, ptr %7, align 8, !tbaa !10
  %9 = sitofp i64 %8 to double
  %10 = tail call double @pow(double noundef %9, double noundef 7.500000e-01) #6
  %11 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %22, label %23

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.02832 = phi i32 [ %19, %.lr.ph ], [ 0, %2 ]
  %.02931 = phi float [ %18, %.lr.ph ], [ 0.000000e+00, %2 ]
  %12 = tail call noundef ptr @_ZN13wordembedding10Dictionary11GetWordInfoEi(ptr noundef nonnull align 8 dereferenceable(152) %1, i32 noundef %.02832)
  %13 = getelementptr inbounds i8, ptr %12, i64 32
  %14 = load i64, ptr %13, align 8, !tbaa !10
  %15 = sitofp i64 %14 to double
  %16 = tail call double @pow(double noundef %15, double noundef 7.500000e-01) #6
  %17 = fptrunc double %16 to float
  %18 = fadd float %.02931, %17
  %19 = add nuw nsw i32 %.02832, 1
  %20 = tail call noundef i32 @_ZN13wordembedding10Dictionary4SizeEv(ptr noundef nonnull align 8 dereferenceable(152) %1)
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !15

22:                                               ; preds = %._crit_edge
  tail call void @__assert_fail(ptr noundef nonnull @.str.66, ptr noundef nonnull @.str.67, i32 noundef 126, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN13wordembedding7Sampler31SetNegativeSamplingDistributionEPNS_10DictionaryE) #7
  unreachable

23:                                               ; preds = %._crit_edge
  %24 = fptrunc double %10 to float
  %25 = fdiv float %24, %.029.lcssa
  br label %27

26:                                               ; preds = %47
  ret void

27:                                               ; preds = %23, %47
  %indvars.iv = phi i64 [ 0, %23 ], [ %indvars.iv.next, %47 ]
  %.02534 = phi float [ %25, %23 ], [ %.1, %47 ]
  %.02633 = phi i32 [ 0, %23 ], [ %.127, %47 ]
  %28 = load ptr, ptr %0, align 8, !tbaa !5
  %29 = getelementptr inbounds i32, ptr %28, i64 %indvars.iv
  store i32 %.02633, ptr %29, align 4, !tbaa !17
  %30 = trunc nuw nsw i64 %indvars.iv to i32
  %31 = uitofp nneg i32 %30 to float
  %32 = fmul float %.02534, 1.000000e+08
  %33 = fcmp olt float %32, %31
  br i1 %33, label %34, label %47

34:                                               ; preds = %27
  %35 = add nsw i32 %.02633, 1
  %36 = tail call noundef i32 @_ZN13wordembedding10Dictionary4SizeEv(ptr noundef nonnull align 8 dereferenceable(152) %1)
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %47

38:                                               ; preds = %34
  %39 = tail call noundef ptr @_ZN13wordembedding10Dictionary11GetWordInfoEi(ptr noundef nonnull align 8 dereferenceable(152) %1, i32 noundef %35)
  %40 = getelementptr inbounds i8, ptr %39, i64 32
  %41 = load i64, ptr %40, align 8, !tbaa !10
  %42 = sitofp i64 %41 to double
  %43 = tail call double @pow(double noundef %42, double noundef 7.500000e-01) #6
  %44 = fptrunc double %43 to float
  %45 = fdiv float %44, %.029.lcssa
  %46 = fadd float %.02534, %45
  br label %47

47:                                               ; preds = %27, %34, %38
  %.127 = phi i32 [ %35, %38 ], [ %.02633, %34 ], [ %.02633, %27 ]
  %.1 = phi float [ %46, %38 ], [ %.02534, %34 ], [ %.02534, %27 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100000000
  br i1 %exitcond.not, label %26, label %27, !llvm.loop !19
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

declare noundef i32 @_ZN13wordembedding10Dictionary4SizeEv(ptr noundef nonnull align 8 dereferenceable(152)) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #3

declare noundef ptr @_ZN13wordembedding10Dictionary11GetWordInfoEi(ptr noundef nonnull align 8 dereferenceable(152), i32 noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 #4 = { noreturn 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 #5 = { nounwind allocsize(0) }
attributes #6 = { nounwind }
attributes #7 = { noreturn 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, !7, i64 0}
!6 = !{!"_ZTSN13wordembedding7SamplerE", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !14, i64 32}
!11 = !{!"_ZTSN13wordembedding8WordInfoE", !12, i64 0, !14, i64 32}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !14, i64 8, !8, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !7, i64 0}
!14 = !{!"long", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !8, i64 0}
!19 = distinct !{!19, !16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass