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

; 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::WordEmbedding" = type { float, i64, ptr, ptr, ptr, ptr, %"class.std::unordered_set", %"class.std::unordered_set", i32, ptr }
%"class.std::unordered_set" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"struct.wordembedding::Option" = type <{ ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, i8, i8, [2 x i8], float, [4 x i8], i64, i32, i32, i32, i32, i32, i32, i64, i64, float, [4 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN13wordembedding13WordEmbedding18UpdateLearningRateEv(ptr noundef nonnull align 8 dereferenceable(176) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 2
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %"struct.wordembedding::Option", ptr %5, i32 0, i32 9
  %7 = load i8, ptr %6, align 4, !tbaa !18, !range !21, !noundef !22
  %8 = trunc i8 %7 to i1
  %9 = zext i1 %8 to i32
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %57

11:                                               ; preds = %1
  %12 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %"struct.wordembedding::Option", ptr %13, i32 0, i32 23
  %15 = load float, ptr %14, align 8, !tbaa !23
  %16 = fpext float %15 to double
  %17 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 1
  %18 = load i64, ptr %17, align 8, !tbaa !24
  %19 = sitofp i64 %18 to double
  %20 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds %"struct.wordembedding::Option", ptr %21, i32 0, i32 21
  %23 = load i64, ptr %22, align 8, !tbaa !25
  %24 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds %"struct.wordembedding::Option", ptr %25, i32 0, i32 20
  %27 = load i32, ptr %26, align 4, !tbaa !26
  %28 = sext i32 %27 to i64
  %29 = mul nsw i64 %23, %28
  %30 = sitofp i64 %29 to double
  %31 = fadd double %30, 1.000000e+00
  %32 = fdiv double %19, %31
  %33 = fsub double 1.000000e+00, %32
  %34 = fmul double %16, %33
  %35 = fptrunc double %34 to float
  %36 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 0
  store float %35, ptr %36, align 8, !tbaa !27
  %37 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 0
  %38 = load float, ptr %37, align 8, !tbaa !27
  %39 = fpext float %38 to double
  %40 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = getelementptr inbounds %"struct.wordembedding::Option", ptr %41, i32 0, i32 23
  %43 = load float, ptr %42, align 8, !tbaa !23
  %44 = fpext float %43 to double
  %45 = fmul double %44, 1.000000e-04
  %46 = fcmp olt double %39, %45
  br i1 %46, label %47, label %56

47:                                               ; preds = %11
  %48 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds %"struct.wordembedding::Option", ptr %49, i32 0, i32 23
  %51 = load float, ptr %50, align 8, !tbaa !23
  %52 = fpext float %51 to double
  %53 = fmul double %52, 1.000000e-04
  %54 = fptrunc double %53 to float
  %55 = getelementptr inbounds %"class.wordembedding::WordEmbedding", ptr %3, i32 0, i32 0
  store float %54, ptr %55, align 8, !tbaa !27
  br label %56

56:                                               ; preds = %47, %11
  br label %57

57:                                               ; preds = %56, %1
  ret void
}

attributes #0 = { 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" }

!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, !6, i64 16}
!10 = !{!"_ZTSN13wordembedding13WordEmbeddingE", !11, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !13, i64 48, !13, i64 104, !17, i64 160, !6, i64 168}
!11 = !{!"float", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_ZTSSt13unordered_setIiSt4hashIiESt8equal_toIiESaIiEE", !14, i64 0}
!14 = !{!"_ZTSSt10_HashtableIiiSaIiENSt8__detail9_IdentityESt8equal_toIiESt4hashIiENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEE", !6, i64 0, !12, i64 8, !15, i64 16, !12, i64 24, !16, i64 32, !6, i64 48}
!15 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!16 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !11, i64 0, !12, i64 8}
!17 = !{!"int", !7, i64 0}
!18 = !{!19, !20, i64 44}
!19 = !{!"_ZTSN13wordembedding6OptionE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !20, i64 40, !20, i64 41, !20, i64 42, !20, i64 43, !20, i64 44, !20, i64 45, !11, i64 48, !12, i64 56, !17, i64 64, !17, i64 68, !17, i64 72, !17, i64 76, !17, i64 80, !17, i64 84, !12, i64 88, !12, i64 96, !11, i64 104}
!20 = !{!"bool", !7, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!19, !11, i64 104}
!24 = !{!10, !12, i64 8}
!25 = !{!19, !12, i64 88}
!26 = !{!19, !17, i64 84}
!27 = !{!10, !11, 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN13wordembedding13WordEmbedding18UpdateLearningRateEv(ptr nocapture noundef nonnull align 8 dereferenceable(176) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 44
  %5 = load i8, ptr %4, align 4, !tbaa !17, !range !20, !noundef !21
  %6 = icmp eq i8 %5, 0
  br i1 %6, label %7, label %31

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %3, i64 104
  %9 = load float, ptr %8, align 8, !tbaa !22
  %10 = fpext float %9 to double
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !23
  %13 = sitofp i64 %12 to double
  %14 = getelementptr inbounds i8, ptr %3, i64 88
  %15 = load i64, ptr %14, align 8, !tbaa !24
  %16 = getelementptr inbounds i8, ptr %3, i64 84
  %17 = load i32, ptr %16, align 4, !tbaa !25
  %18 = sext i32 %17 to i64
  %19 = mul nsw i64 %15, %18
  %20 = sitofp i64 %19 to double
  %21 = fadd double %20, 1.000000e+00
  %22 = fdiv double %13, %21
  %23 = fsub double 1.000000e+00, %22
  %24 = fmul double %23, %10
  %25 = fptrunc double %24 to float
  store float %25, ptr %0, align 8, !tbaa !26
  %26 = fpext float %25 to double
  %27 = fmul double %10, 1.000000e-04
  %28 = fcmp ogt double %27, %26
  br i1 %28, label %29, label %31

29:                                               ; preds = %7
  %30 = fptrunc double %27 to float
  store float %30, ptr %0, align 8, !tbaa !26
  br label %31

31:                                               ; preds = %7, %29, %1
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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, !11, i64 16}
!6 = !{!"_ZTSN13wordembedding13WordEmbeddingE", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !12, i64 48, !12, i64 104, !16, i64 160, !11, i64 168}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTSSt13unordered_setIiSt4hashIiESt8equal_toIiESaIiEE", !13, i64 0}
!13 = !{!"_ZTSSt10_HashtableIiiSaIiENSt8__detail9_IdentityESt8equal_toIiESt4hashIiENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEE", !11, i64 0, !10, i64 8, !14, i64 16, !10, i64 24, !15, i64 32, !11, i64 48}
!14 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !11, i64 0}
!15 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !7, i64 0, !10, i64 8}
!16 = !{!"int", !8, i64 0}
!17 = !{!18, !19, i64 44}
!18 = !{!"_ZTSN13wordembedding6OptionE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !19, i64 40, !19, i64 41, !19, i64 42, !19, i64 43, !19, i64 44, !19, i64 45, !7, i64 48, !10, i64 56, !16, i64 64, !16, i64 68, !16, i64 72, !16, i64 76, !16, i64 80, !16, i64 84, !10, i64 88, !10, i64 96, !7, i64 104}
!19 = !{!"bool", !8, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!18, !7, i64 104}
!23 = !{!6, !10, i64 8}
!24 = !{!18, !10, i64 88}
!25 = !{!18, !16, i64 84}
!26 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass