; LLVM IR from facebookresearch/StarSpace :: src/data.ll (ZN9starspace17InternDataHandler14getNextExampleERNS_12ParseResultsE)

; 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.starspace::InternDataHandler" = type { ptr, %"class.std::shared_ptr", %"class.std::vector", i32, i32, i32, %"class.std::vector.0" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<starspace::ParseResults, std::allocator<starspace::ParseResults>>::_Vector_impl" }
%"struct.std::_Vector_base<starspace::ParseResults, std::allocator<starspace::ParseResults>>::_Vector_impl" = type { %"struct.std::_Vector_base<starspace::ParseResults, std::allocator<starspace::ParseResults>>::_Vector_impl_data" }
%"struct.std::_Vector_base<starspace::ParseResults, std::allocator<starspace::ParseResults>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::pair<int, float>, std::allocator<std::pair<int, float>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, float>, std::allocator<std::pair<int, float>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, float>, std::allocator<std::pair<int, float>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, float>, std::allocator<std::pair<int, float>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.13 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__._ZN9starspace17InternDataHandler14getNextExampleERNS_12ParseResultsE = external hidden unnamed_addr constant [66 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9starspace17InternDataHandler14getNextExampleERNS_12ParseResultsE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(80) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 4
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  br label %12

10:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.17, ptr noundef @.str.13, i32 noundef 195, ptr noundef @__PRETTY_FUNCTION__._ZN9starspace17InternDataHandler14getNextExampleERNS_12ParseResultsE) #3
  unreachable

11:                                               ; No predecessors!
  br label %12

12:                                               ; preds = %11, %9
  %13 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 3
  %14 = load i32, ptr %13, align 8, !tbaa !23
  %15 = add nsw i32 %14, 1
  %16 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 3
  store i32 %15, ptr %16, align 8, !tbaa !23
  %17 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 3
  %18 = load i32, ptr %17, align 8, !tbaa !23
  %19 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 4
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = icmp sge i32 %18, %20
  br i1 %21, label %22, label %29

22:                                               ; preds = %12
  %23 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 3
  %24 = load i32, ptr %23, align 8, !tbaa !23
  %25 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 4
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = sub nsw i32 %24, %26
  %28 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 3
  store i32 %27, ptr %28, align 8, !tbaa !23
  br label %29

29:                                               ; preds = %22, %12
  %30 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 2
  %31 = getelementptr inbounds %"class.starspace::InternDataHandler", ptr %5, i32 0, i32 3
  %32 = load i32, ptr %31, align 8, !tbaa !23
  %33 = sext i32 %32 to i64
  %34 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorIN9starspace12ParseResultsESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %33) #4
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !24
  %37 = getelementptr inbounds ptr, ptr %36, i64 1
  %38 = load ptr, ptr %37, align 8
  call void %38(ptr noundef nonnull align 8 dereferenceable(88) %5, ptr noundef nonnull align 8 dereferenceable(80) %34, ptr noundef nonnull align 8 dereferenceable(80) %35)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorIN9starspace12ParseResultsESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

attributes #0 = { 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 #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 = { 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 = { noreturn nounwind }
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, !18, i64 52}
!10 = !{!"_ZTSN9starspace17InternDataHandlerE", !11, i64 8, !14, i64 24, !18, i64 48, !18, i64 52, !18, i64 56, !19, i64 64}
!11 = !{!"_ZTSSt10shared_ptrIN9starspace4ArgsEE", !12, i64 0}
!12 = !{!"_ZTSSt12__shared_ptrIN9starspace4ArgsELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !13, i64 8}
!13 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!14 = !{!"_ZTSSt6vectorIN9starspace12ParseResultsESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIN9starspace12ParseResultsESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN9starspace12ParseResultsESaIS1_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN9starspace12ParseResultsESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTSSt6vectorISt4pairIifESaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseISt4pairIifESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseISt4pairIifESaIS1_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseISt4pairIifESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!10, !18, i64 48}
!24 = !{!25, !25, i64 0}
!25 = !{!"vtable pointer", !8, 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.13 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__._ZN9starspace17InternDataHandler14getNextExampleERNS_12ParseResultsE = external hidden unnamed_addr constant [66 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9starspace17InternDataHandler14getNextExampleERNS_12ParseResultsE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(80) %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 52
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.17, ptr noundef nonnull @.str.13, i32 noundef 195, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN9starspace17InternDataHandler14getNextExampleERNS_12ParseResultsE) #3
  unreachable

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = load i32, ptr %8, align 8, !tbaa !22
  %10 = add nsw i32 %9, 1
  %.not = icmp slt i32 %10, %4
  %11 = select i1 %.not, i32 0, i32 %4
  %spec.select = sub nsw i32 %10, %11
  store i32 %spec.select, ptr %8, align 8, !tbaa !22
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = sext i32 %spec.select to i64
  %14 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorIN9starspace12ParseResultsESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %13) #4
  %15 = load ptr, ptr %0, align 8, !tbaa !23
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load ptr, ptr %16, align 8
  tail call void %17(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(80) %14, ptr noundef nonnull align 8 dereferenceable(80) %1)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorIN9starspace12ParseResultsESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

attributes #0 = { 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 #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 = { 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 = { noreturn nounwind }
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, !17, i64 52}
!6 = !{!"_ZTSN9starspace17InternDataHandlerE", !7, i64 8, !13, i64 24, !17, i64 48, !17, i64 52, !17, i64 56, !18, i64 64}
!7 = !{!"_ZTSSt10shared_ptrIN9starspace4ArgsEE", !8, i64 0}
!8 = !{!"_ZTSSt12__shared_ptrIN9starspace4ArgsELN9__gnu_cxx12_Lock_policyE2EE", !9, i64 0, !12, i64 8}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !9, i64 0}
!13 = !{!"_ZTSSt6vectorIN9starspace12ParseResultsESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN9starspace12ParseResultsESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN9starspace12ParseResultsESaIS1_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN9starspace12ParseResultsESaIS1_EE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!17 = !{!"int", !10, i64 0}
!18 = !{!"_ZTSSt6vectorISt4pairIifESaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseISt4pairIifESaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseISt4pairIifESaIS1_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseISt4pairIifESaIS1_EE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!22 = !{!6, !17, i64 48}
!23 = !{!24, !24, i64 0}
!24 = !{!"vtable pointer", !11, i64 0}


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