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

; 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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10dataKeeper10ParseNodesEv(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 4
  %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 = call noundef ptr @_ZN6Matrix9setMatrixE11DEVICE_NAMEmm(i32 noundef 0, i64 noundef %6, i64 noundef %8)
  %10 = getelementptr inbounds %class.dataKeeper, ptr %4, i32 0, i32 11
  store ptr %9, ptr %10, 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 %11

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

17:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %28

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

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

28:                                               ; preds = %17
  ret void
}

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

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 80}
!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 184}
!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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10dataKeeper10ParseNodesEv(ptr noundef nonnull align 8 dereferenceable(3168) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 80
  %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 = tail call noundef ptr @_ZN6Matrix9setMatrixE11DEVICE_NAMEmm(i32 noundef 0, i64 noundef %3, i64 noundef %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 184
  store ptr %6, ptr %7, align 8, !tbaa !34
  %8 = tail call noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49) %6)
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

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

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

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

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

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 80}
!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 184}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}


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