; LLVM IR from NervanaSystems/ngraph :: doc/examples/mnist_mlp (mnist_loader)

; 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.MNistDataLoader = type { i64, %class.MNistImageLoader, %class.MNistLabelLoader, i32, i64, i64, %"class.std::unique_ptr", %"class.std::unique_ptr", i64 }
%class.MNistImageLoader = type { %class.MNistLoader, i32, i32 }
%class.MNistLoader = type { ptr, %"class.std::__cxx11::basic_string", ptr, i32, i32, %struct._G_fpos_t }
%"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] }
%struct._G_fpos_t = type { i64, %struct.__mbstate_t }
%struct.__mbstate_t = type { i32, %union.anon.0 }
%union.anon.0 = type { i32 }
%class.MNistLabelLoader = type { %class.MNistLoader }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.3" }
%"struct.std::_Head_base.3" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15MNistDataLoaderC2EmRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_(ptr noundef nonnull align 8 dereferenceable(208) %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(32) %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  %12 = getelementptr inbounds %class.MNistDataLoader, ptr %11, i32 0, i32 0
  %13 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %13, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds %class.MNistDataLoader, ptr %11, i32 0, i32 1
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN16MNistImageLoaderC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(80) %14, ptr noundef nonnull align 8 dereferenceable(32) %15)
  %16 = getelementptr inbounds %class.MNistDataLoader, ptr %11, i32 0, i32 2
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  invoke void @_ZN16MNistLabelLoaderC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(72) %16, ptr noundef nonnull align 8 dereferenceable(32) %17)
          to label %18 unwind label %25

18:                                               ; preds = %4
  %19 = getelementptr inbounds %class.MNistDataLoader, ptr %11, i32 0, i32 3
  store i32 0, ptr %19, align 8, !tbaa !27
  %20 = getelementptr inbounds %class.MNistDataLoader, ptr %11, i32 0, i32 4
  store i64 0, ptr %20, align 8, !tbaa !28
  %21 = getelementptr inbounds %class.MNistDataLoader, ptr %11, i32 0, i32 5
  store i64 0, ptr %21, align 8, !tbaa !29
  %22 = getelementptr inbounds %class.MNistDataLoader, ptr %11, i32 0, i32 6
  call void @_ZNSt10unique_ptrIA_fSt14default_deleteIS0_EEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(8) %22) #2
  %23 = getelementptr inbounds %class.MNistDataLoader, ptr %11, i32 0, i32 7
  call void @_ZNSt10unique_ptrIA_fSt14default_deleteIS0_EEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(8) %23) #2
  %24 = getelementptr inbounds %class.MNistDataLoader, ptr %11, i32 0, i32 8
  store i64 0, ptr %24, align 8, !tbaa !30
  ret void

25:                                               ; preds = %4
  %26 = landingpad { ptr, i32 }
          cleanup
  %27 = extractvalue { ptr, i32 } %26, 0
  store ptr %27, ptr %9, align 8
  %28 = extractvalue { ptr, i32 } %26, 1
  store i32 %28, ptr %10, align 4
  call void @_ZN11MNistLoaderD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %14) #2
  br label %29

29:                                               ; preds = %25
  %30 = load ptr, ptr %9, align 8
  %31 = load i32, ptr %10, align 4
  %32 = insertvalue { ptr, i32 } poison, ptr %30, 0
  %33 = insertvalue { ptr, i32 } %32, i32 %31, 1
  resume { ptr, i32 } %33
}

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

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

declare void @_ZN16MNistImageLoaderC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr, ptr)

declare void @_ZN16MNistLabelLoaderC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr, ptr)

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 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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS15MNistDataLoader", !10, i64 0, !13, i64 8, !20, i64 88, !17, i64 160, !10, i64 168, !10, i64 176, !21, i64 184, !21, i64 192, !10, i64 200}
!13 = !{!"_ZTS16MNistImageLoader", !14, i64 0, !17, i64 72, !17, i64 76}
!14 = !{!"_ZTS11MNistLoader", !15, i64 8, !6, i64 40, !17, i64 48, !17, i64 52, !18, i64 56}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !10, i64 8, !7, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!"_ZTS9_G_fpos_t", !10, i64 0, !19, i64 8}
!19 = !{!"_ZTS11__mbstate_t", !17, i64 0, !7, i64 4}
!20 = !{!"_ZTS16MNistLabelLoader", !14, i64 0}
!21 = !{!"_ZTSSt10unique_ptrIA_fSt14default_deleteIS0_EE", !22, i64 0}
!22 = !{!"_ZTSSt15__uniq_ptr_dataIfSt14default_deleteIA_fELb1ELb1EE", !23, i64 0}
!23 = !{!"_ZTSSt15__uniq_ptr_implIfSt14default_deleteIA_fEE", !24, i64 0}
!24 = !{!"_ZTSSt5tupleIJPfSt14default_deleteIA_fEEE", !25, i64 0}
!25 = !{!"_ZTSSt11_Tuple_implILm0EJPfSt14default_deleteIA_fEEE", !26, i64 0}
!26 = !{!"_ZTSSt10_Head_baseILm0EPfLb0EE", !6, i64 0}
!27 = !{!12, !17, i64 160}
!28 = !{!12, !10, i64 168}
!29 = !{!12, !10, i64 176}
!30 = !{!12, !10, i64 200}


; 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"

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15MNistDataLoaderC2EmRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_(ptr noundef nonnull align 8 dereferenceable(208) %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(32) %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store i64 %1, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN16MNistImageLoaderC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(32) %2)
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  invoke void @_ZN16MNistLabelLoaderC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(72) %6, ptr noundef nonnull align 8 dereferenceable(32) %3)
          to label %7 unwind label %13

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 160
  store i32 0, ptr %8, align 8, !tbaa !25
  %9 = getelementptr inbounds i8, ptr %0, i64 168
  %10 = getelementptr inbounds i8, ptr %0, i64 184
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %9, i8 0, i64 16, i1 false)
  tail call void @_ZNSt10unique_ptrIA_fSt14default_deleteIS0_EEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #3
  %11 = getelementptr inbounds i8, ptr %0, i64 192
  tail call void @_ZNSt10unique_ptrIA_fSt14default_deleteIS0_EEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #3
  %12 = getelementptr inbounds i8, ptr %0, i64 200
  store i64 0, ptr %12, align 8, !tbaa !26
  ret void

13:                                               ; preds = %4
  %14 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN11MNistLoaderD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %5) #3
  resume { ptr, i32 } %14
}

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

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

declare void @_ZN16MNistImageLoaderC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr, ptr) local_unnamed_addr

declare void @_ZN16MNistLabelLoaderC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr, ptr) local_unnamed_addr

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTS15MNistDataLoader", !7, i64 0, !10, i64 8, !18, i64 88, !15, i64 160, !7, i64 168, !7, i64 176, !19, i64 184, !19, i64 192, !7, i64 200}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS16MNistImageLoader", !11, i64 0, !15, i64 72, !15, i64 76}
!11 = !{!"_ZTS11MNistLoader", !12, i64 8, !14, i64 40, !15, i64 48, !15, i64 52, !16, i64 56}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !7, i64 8, !8, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !14, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!"_ZTS9_G_fpos_t", !7, i64 0, !17, i64 8}
!17 = !{!"_ZTS11__mbstate_t", !15, i64 0, !8, i64 4}
!18 = !{!"_ZTS16MNistLabelLoader", !11, i64 0}
!19 = !{!"_ZTSSt10unique_ptrIA_fSt14default_deleteIS0_EE", !20, i64 0}
!20 = !{!"_ZTSSt15__uniq_ptr_dataIfSt14default_deleteIA_fELb1ELb1EE", !21, i64 0}
!21 = !{!"_ZTSSt15__uniq_ptr_implIfSt14default_deleteIA_fEE", !22, i64 0}
!22 = !{!"_ZTSSt5tupleIJPfSt14default_deleteIA_fEEE", !23, i64 0}
!23 = !{!"_ZTSSt11_Tuple_implILm0EJPfSt14default_deleteIA_fEEE", !24, i64 0}
!24 = !{!"_ZTSSt10_Head_baseILm0EPfLb0EE", !14, i64 0}
!25 = !{!6, !15, i64 160}
!26 = !{!6, !7, i64 200}


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