; LLVM IR from moarseniy/CudaFEMproject :: FEMproject/DataKeeper/src/datakeeper.ll (ZN10dataKeeper13ParseElementsEv)

; 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.dataKeeper = type { %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i8, i64, i64, i64, i64, i64, i64, i64, %"class.std::unordered_map", ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.MechanicalParams, %struct.dataPaths, %struct.WaveletParams, %"class.std::basic_fstream", %"class.std::basic_fstream", %"class.std::basic_fstream", %"class.std::basic_fstream", %"class.std::basic_fstream" }
%"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] }
%"class.std::unordered_map" = 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.MechanicalParams = type { float, float, float, float, float, float, float, float, float }
%struct.dataPaths = type { %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string" }
%struct.WaveletParams = type <{ %"class.std::__cxx11::basic_string", float, float, float, [4 x i8] }>
%"class.std::basic_fstream" = type { %"class.std::basic_iostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_iostream.base" = type { %"class.std::basic_istream.base", %"class.std::basic_ostream.base" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon.0 }
%union.anon.0 = type { i32 }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }

; 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

declare noundef ptr @_ZN6Matrix9setMatrixE11DEVICE_NAMEmm(i32 noundef, i64 noundef, i64 noundef) #1

declare noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49)) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERf(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10dataKeeper13ParseElementsEv(ptr noundef nonnull align 8 dereferenceable(3168) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %class.dataKeeper, ptr %4, i32 0, i32 5
  %6 = load i64, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds %class.dataKeeper, ptr %4, i32 0, i32 3
  %8 = load i64, ptr %7, align 8, !tbaa !34
  %9 = add i64 %8, 1
  %10 = call noundef ptr @_ZN6Matrix9setMatrixE11DEVICE_NAMEmm(i32 noundef 0, i64 noundef %6, i64 noundef %9)
  %11 = getelementptr inbounds %class.dataKeeper, ptr %4, i32 0, i32 12
  store ptr %10, ptr %11, align 8, !tbaa !35
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !36
  br label %12

12:                                               ; preds = %26, %1
  %13 = load i64, ptr %3, align 8, !tbaa !36
  %14 = getelementptr inbounds %class.dataKeeper, ptr %4, i32 0, i32 12
  %15 = load ptr, ptr %14, align 8, !tbaa !35
  %16 = call noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49) %15)
  %17 = icmp ult i64 %13, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %29

19:                                               ; preds = %12
  %20 = getelementptr inbounds %class.dataKeeper, ptr %4, i32 0, i32 27
  %21 = getelementptr inbounds %class.dataKeeper, ptr %4, i32 0, i32 12
  %22 = load ptr, ptr %21, align 8, !tbaa !35
  %23 = load i64, ptr %3, align 8, !tbaa !36
  %24 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49) %22, i64 noundef %23)
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERf(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 4 dereferenceable(4) %24)
  br label %26

26:                                               ; preds = %19
  %27 = load i64, ptr %3, align 8, !tbaa !36
  %28 = add i64 %27, 1
  store i64 %28, ptr %3, align 8, !tbaa !36
  br label %12, !llvm.loop !37

29:                                               ; preds = %18
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = { 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, !13, i64 88}
!10 = !{!"_ZTS10dataKeeper", !11, i64 0, !11, i64 32, !14, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !15, i64 128, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !20, i64 280, !21, i64 320, !22, i64 480, !23, i64 528, !23, i64 1056, !23, i64 1584, !23, i64 2112, !23, i64 2640}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !13, i64 8, !7, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSSt13unordered_mapIiSt6vectorIiSaIiEESt4hashIiESt8equal_toIiESaISt4pairIKiS2_EEE", !16, i64 0}
!16 = !{!"_ZTSSt10_HashtableIiSt4pairIKiSt6vectorIiSaIiEEESaIS5_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS7_18_Mod_range_hashingENS7_20_Default_ranged_hashENS7_20_Prime_rehash_policyENS7_17_Hashtable_traitsILb0ELb0ELb1EEEE", !6, i64 0, !13, i64 8, !17, i64 16, !13, i64 24, !18, i64 32, !6, i64 48}
!17 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!18 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !19, i64 0, !13, i64 8}
!19 = !{!"float", !7, i64 0}
!20 = !{!"_ZTS16MechanicalParams", !19, i64 0, !19, i64 4, !19, i64 8, !19, i64 12, !19, i64 16, !19, i64 20, !19, i64 24, !19, i64 28, !19, i64 32}
!21 = !{!"_ZTS9dataPaths", !11, i64 0, !11, i64 32, !11, i64 64, !11, i64 96, !11, i64 128}
!22 = !{!"_ZTS13WaveletParams", !11, i64 0, !19, i64 32, !19, i64 36, !19, i64 40}
!23 = !{!"_ZTSSt13basic_fstreamIcSt11char_traitsIcEE", !24, i64 0, !27, i64 24}
!24 = !{!"_ZTSSd", !25, i64 0, !26, i64 16}
!25 = !{!"_ZTSSi", !13, i64 8}
!26 = !{!"_ZTSSo"}
!27 = !{!"_ZTSSt13basic_filebufIcSt11char_traitsIcEE", !28, i64 0, !7, i64 64, !30, i64 104, !31, i64 120, !32, i64 124, !32, i64 132, !32, i64 140, !6, i64 152, !13, i64 160, !14, i64 168, !14, i64 169, !14, i64 170, !7, i64 171, !6, i64 176, !6, i64 184, !14, i64 192, !6, i64 200, !6, i64 208, !13, i64 216, !6, i64 224, !6, i64 232}
!28 = !{!"_ZTSSt15basic_streambufIcSt11char_traitsIcEE", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !29, i64 56}
!29 = !{!"_ZTSSt6locale", !6, i64 0}
!30 = !{!"_ZTSSt12__basic_fileIcE", !6, i64 0, !14, i64 8}
!31 = !{!"_ZTSSt13_Ios_Openmode", !7, i64 0}
!32 = !{!"_ZTS11__mbstate_t", !33, i64 0, !7, i64 4}
!33 = !{!"int", !7, i64 0}
!34 = !{!10, !13, i64 72}
!35 = !{!10, !6, i64 192}
!36 = !{!13, !13, i64 0}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}


; 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 noundef ptr @_ZN6Matrix9setMatrixE11DEVICE_NAMEmm(i32 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

declare noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERf(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10dataKeeper13ParseElementsEv(ptr noundef nonnull align 8 dereferenceable(3168) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 88
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 72
  %5 = load i64, ptr %4, align 8, !tbaa !33
  %6 = add i64 %5, 1
  %7 = tail call noundef ptr @_ZN6Matrix9setMatrixE11DEVICE_NAMEmm(i32 noundef 0, i64 noundef %3, i64 noundef %6)
  %8 = getelementptr inbounds i8, ptr %0, i64 192
  store ptr %7, ptr %8, align 8, !tbaa !34
  %9 = tail call noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49) %7)
  %.not = icmp eq i64 %9, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 1056
  br label %11

._crit_edge:                                      ; preds = %11, %1
  ret void

11:                                               ; preds = %.lr.ph, %11
  %.03 = phi i64 [ 0, %.lr.ph ], [ %15, %11 ]
  %12 = load ptr, ptr %8, align 8, !tbaa !34
  %13 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixixEm(ptr noundef nonnull align 8 dereferenceable(49) %12, i64 noundef %.03)
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERf(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %15 = add nuw i64 %.03, 1
  %16 = load ptr, ptr %8, align 8, !tbaa !34
  %17 = tail call noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49) %16)
  %18 = icmp ult i64 %15, %17
  br i1 %18, label %11, label %._crit_edge, !llvm.loop !35
}

attributes #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 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, !12, i64 88}
!6 = !{!"_ZTS10dataKeeper", !7, i64 0, !7, i64 32, !13, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !14, i64 128, !9, i64 184, !9, i64 192, !9, i64 200, !9, i64 208, !9, i64 216, !9, i64 224, !9, i64 232, !9, i64 240, !9, i64 248, !9, i64 256, !9, i64 264, !9, i64 272, !19, i64 280, !20, i64 320, !21, i64 480, !22, i64 528, !22, i64 1056, !22, i64 1584, !22, i64 2112, !22, i64 2640}
!7 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !8, i64 0, !12, i64 8, !10, i64 16}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!"bool", !10, i64 0}
!14 = !{!"_ZTSSt13unordered_mapIiSt6vectorIiSaIiEESt4hashIiESt8equal_toIiESaISt4pairIKiS2_EEE", !15, i64 0}
!15 = !{!"_ZTSSt10_HashtableIiSt4pairIKiSt6vectorIiSaIiEEESaIS5_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS7_18_Mod_range_hashingENS7_20_Default_ranged_hashENS7_20_Prime_rehash_policyENS7_17_Hashtable_traitsILb0ELb0ELb1EEEE", !9, i64 0, !12, i64 8, !16, i64 16, !12, i64 24, !17, i64 32, !9, i64 48}
!16 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !9, i64 0}
!17 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !18, i64 0, !12, i64 8}
!18 = !{!"float", !10, i64 0}
!19 = !{!"_ZTS16MechanicalParams", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !18, i64 16, !18, i64 20, !18, i64 24, !18, i64 28, !18, i64 32}
!20 = !{!"_ZTS9dataPaths", !7, i64 0, !7, i64 32, !7, i64 64, !7, i64 96, !7, i64 128}
!21 = !{!"_ZTS13WaveletParams", !7, i64 0, !18, i64 32, !18, i64 36, !18, i64 40}
!22 = !{!"_ZTSSt13basic_fstreamIcSt11char_traitsIcEE", !23, i64 0, !26, i64 24}
!23 = !{!"_ZTSSd", !24, i64 0, !25, i64 16}
!24 = !{!"_ZTSSi", !12, i64 8}
!25 = !{!"_ZTSSo"}
!26 = !{!"_ZTSSt13basic_filebufIcSt11char_traitsIcEE", !27, i64 0, !10, i64 64, !29, i64 104, !30, i64 120, !31, i64 124, !31, i64 132, !31, i64 140, !9, i64 152, !12, i64 160, !13, i64 168, !13, i64 169, !13, i64 170, !10, i64 171, !9, i64 176, !9, i64 184, !13, i64 192, !9, i64 200, !9, i64 208, !12, i64 216, !9, i64 224, !9, i64 232}
!27 = !{!"_ZTSSt15basic_streambufIcSt11char_traitsIcEE", !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !9, i64 40, !9, i64 48, !28, i64 56}
!28 = !{!"_ZTSSt6locale", !9, i64 0}
!29 = !{!"_ZTSSt12__basic_fileIcE", !9, i64 0, !13, i64 8}
!30 = !{!"_ZTSSt13_Ios_Openmode", !10, i64 0}
!31 = !{!"_ZTS11__mbstate_t", !32, i64 0, !10, i64 4}
!32 = !{!"int", !10, i64 0}
!33 = !{!6, !12, i64 72}
!34 = !{!6, !9, i64 192}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass