; LLVM IR from dennisss/tansa :: src/mocap/optitrack/natnet_client.ll (ZN5tansa9optitrack12NatNetClientC2Ev)

; 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.tansa::Time" = type { %struct.timespec }
%struct.timespec = type { i64, i64 }
%"class.tansa::optitrack::NatNetClient" = type { %"class.tansa::Channel", i32, i8, i32, i64, i32, i64, i32, i32, %struct.sockaddr_in, %struct.sockaddr_in, %"class.tansa::Time", %"class.tansa::Time", [4 x i8], [4 x i8] }
%"class.tansa::Channel" = type { %"class.std::map" }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, std::vector<tansa::Subscription *>>, std::_Select1st<std::pair<const int, std::vector<tansa::Subscription *>>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, std::vector<tansa::Subscription *>>, std::_Select1st<std::pair<const int, std::vector<tansa::Subscription *>>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5tansa9optitrack12NatNetClientC2Ev(ptr noundef nonnull align 8 dereferenceable(168) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.tansa::Time", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @_ZN5tansa7ChannelC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %6) #5
  %7 = getelementptr inbounds %"class.tansa::optitrack::NatNetClient", ptr %6, i32 0, i32 9
  %8 = getelementptr inbounds %"class.tansa::optitrack::NatNetClient", ptr %6, i32 0, i32 10
  %9 = getelementptr inbounds %"class.tansa::optitrack::NatNetClient", ptr %6, i32 0, i32 11
  invoke void @_ZN5tansa4TimeC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %9, i32 noundef 0, i32 noundef 0)
          to label %10 unwind label %24

10:                                               ; preds = %1
  %11 = getelementptr inbounds %"class.tansa::optitrack::NatNetClient", ptr %6, i32 0, i32 12
  invoke void @_ZN5tansa4TimeC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %11)
          to label %12 unwind label %24

12:                                               ; preds = %10
  %13 = getelementptr inbounds %"class.tansa::optitrack::NatNetClient", ptr %6, i32 0, i32 13
  store i8 0, ptr %13, align 1, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %13, i64 1
  store i8 0, ptr %14, align 1, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %13, i64 2
  store i8 0, ptr %15, align 1, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %13, i64 3
  store i8 0, ptr %16, align 1, !tbaa !9
  %17 = getelementptr inbounds %"class.tansa::optitrack::NatNetClient", ptr %6, i32 0, i32 14
  store i8 0, ptr %17, align 1, !tbaa !9
  %18 = getelementptr inbounds i8, ptr %17, i64 1
  store i8 0, ptr %18, align 1, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %17, i64 2
  store i8 0, ptr %19, align 1, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %17, i64 3
  store i8 0, ptr %20, align 1, !tbaa !9
  %21 = getelementptr inbounds %"class.tansa::optitrack::NatNetClient", ptr %6, i32 0, i32 2
  store i8 0, ptr %21, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #5
  invoke void @_ZN5tansa4TimeC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef 0, i32 noundef 0)
          to label %22 unwind label %28

22:                                               ; preds = %12
  %23 = getelementptr inbounds %"class.tansa::optitrack::NatNetClient", ptr %6, i32 0, i32 12
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %23, ptr align 8 %5, i64 16, i1 false), !tbaa.struct !30
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #5
  ret void

24:                                               ; preds = %10, %1
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %3, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %4, align 4
  br label %32

28:                                               ; preds = %12
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %3, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #5
  br label %32

32:                                               ; preds = %28, %24
  call void @_ZN5tansa7ChannelD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %6) #5
  br label %33

33:                                               ; preds = %32
  %34 = load ptr, ptr %3, align 8
  %35 = load i32, ptr %4, align 4
  %36 = insertvalue { ptr, i32 } poison, ptr %34, 0
  %37 = insertvalue { ptr, i32 } %36, i32 %35, 1
  resume { ptr, i32 } %37
}

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

declare void @_ZN5tansa4TimeC1Eii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5tansa4TimeC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5tansa7ChannelD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1 align 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 = { inlinehint 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !23, i64 52}
!11 = !{!"_ZTSN5tansa9optitrack12NatNetClientE", !12, i64 0, !22, i64 48, !23, i64 52, !24, i64 56, !21, i64 64, !24, i64 72, !21, i64 80, !24, i64 88, !24, i64 92, !25, i64 96, !25, i64 112, !28, i64 128, !28, i64 144, !7, i64 160, !7, i64 164}
!12 = !{!"_ZTSN5tansa7ChannelE", !13, i64 0}
!13 = !{!"_ZTSSt3mapIiSt6vectorIPN5tansa12SubscriptionESaIS3_EESt4lessIiESaISt4pairIKiS5_EEE", !14, i64 0}
!14 = !{!"_ZTSSt8_Rb_treeIiSt4pairIKiSt6vectorIPN5tansa12SubscriptionESaIS5_EEESt10_Select1stIS8_ESt4lessIiESaIS8_EE", !15, i64 0}
!15 = !{!"_ZTSNSt8_Rb_treeIiSt4pairIKiSt6vectorIPN5tansa12SubscriptionESaIS5_EEESt10_Select1stIS8_ESt4lessIiESaIS8_EE13_Rb_tree_implISC_Lb1EEE", !16, i64 0, !18, i64 8}
!16 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIiEE", !17, i64 0}
!17 = !{!"_ZTSSt4lessIiE"}
!18 = !{!"_ZTSSt15_Rb_tree_header", !19, i64 0, !21, i64 32}
!19 = !{!"_ZTSSt18_Rb_tree_node_base", !20, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSN5tansa9optitrack20NatNetConnectionTypeE", !7, i64 0}
!23 = !{!"bool", !7, i64 0}
!24 = !{!"int", !7, i64 0}
!25 = !{!"_ZTS11sockaddr_in", !26, i64 0, !26, i64 2, !27, i64 4, !7, i64 8}
!26 = !{!"short", !7, i64 0}
!27 = !{!"_ZTS7in_addr", !24, i64 0}
!28 = !{!"_ZTSN5tansa4TimeE", !29, i64 0}
!29 = !{!"_ZTS8timespec", !21, i64 0, !21, i64 8}
!30 = !{i64 0, i64 8, !31, i64 8, i64 8, !31}
!31 = !{!21, !21, 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"

%"class.tansa::Time" = type { %struct.timespec }
%struct.timespec = type { i64, i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5tansa9optitrack12NatNetClientC2Ev(ptr noundef nonnull align 8 dereferenceable(168) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.tansa::Time", align 8
  tail call void @_ZN5tansa7ChannelC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %0) #5
  %3 = getelementptr inbounds i8, ptr %0, i64 128
  invoke void @_ZN5tansa4TimeC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef 0, i32 noundef 0)
          to label %4 unwind label %10

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 144
  invoke void @_ZN5tansa4TimeC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %6 unwind label %10

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 160
  %8 = getelementptr inbounds i8, ptr %0, i64 52
  store i8 0, ptr %8, align 4, !tbaa !5
  store i64 0, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  invoke void @_ZN5tansa4TimeC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef 0, i32 noundef 0)
          to label %9 unwind label %12

9:                                                ; preds = %6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %2, i64 16, i1 false), !tbaa.struct !28
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  ret void

10:                                               ; preds = %4, %1
  %11 = landingpad { ptr, i32 }
          cleanup
  br label %14

12:                                               ; preds = %6
  %13 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  br label %14

14:                                               ; preds = %12, %10
  %.pn = phi { ptr, i32 } [ %13, %12 ], [ %11, %10 ]
  call void @_ZN5tansa7ChannelD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %0) #5
  resume { ptr, i32 } %.pn
}

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

declare void @_ZN5tansa4TimeC1Eii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5tansa4TimeC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5tansa7ChannelD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1 align 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 = { inlinehint 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 = { "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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, !21, i64 52}
!6 = !{!"_ZTSN5tansa9optitrack12NatNetClientE", !7, i64 0, !20, i64 48, !21, i64 52, !22, i64 56, !19, i64 64, !22, i64 72, !19, i64 80, !22, i64 88, !22, i64 92, !23, i64 96, !23, i64 112, !26, i64 128, !26, i64 144, !16, i64 160, !16, i64 164}
!7 = !{!"_ZTSN5tansa7ChannelE", !8, i64 0}
!8 = !{!"_ZTSSt3mapIiSt6vectorIPN5tansa12SubscriptionESaIS3_EESt4lessIiESaISt4pairIKiS5_EEE", !9, i64 0}
!9 = !{!"_ZTSSt8_Rb_treeIiSt4pairIKiSt6vectorIPN5tansa12SubscriptionESaIS5_EEESt10_Select1stIS8_ESt4lessIiESaIS8_EE", !10, i64 0}
!10 = !{!"_ZTSNSt8_Rb_treeIiSt4pairIKiSt6vectorIPN5tansa12SubscriptionESaIS5_EEESt10_Select1stIS8_ESt4lessIiESaIS8_EE13_Rb_tree_implISC_Lb1EEE", !11, i64 0, !13, i64 8}
!11 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIiEE", !12, i64 0}
!12 = !{!"_ZTSSt4lessIiE"}
!13 = !{!"_ZTSSt15_Rb_tree_header", !14, i64 0, !19, i64 32}
!14 = !{!"_ZTSSt18_Rb_tree_node_base", !15, i64 0, !18, i64 8, !18, i64 16, !18, i64 24}
!15 = !{!"_ZTSSt14_Rb_tree_color", !16, i64 0}
!16 = !{!"omnipotent char", !17, i64 0}
!17 = !{!"Simple C++ TBAA"}
!18 = !{!"any pointer", !16, i64 0}
!19 = !{!"long", !16, i64 0}
!20 = !{!"_ZTSN5tansa9optitrack20NatNetConnectionTypeE", !16, i64 0}
!21 = !{!"bool", !16, i64 0}
!22 = !{!"int", !16, i64 0}
!23 = !{!"_ZTS11sockaddr_in", !24, i64 0, !24, i64 2, !25, i64 4, !16, i64 8}
!24 = !{!"short", !16, i64 0}
!25 = !{!"_ZTS7in_addr", !22, i64 0}
!26 = !{!"_ZTSN5tansa4TimeE", !27, i64 0}
!27 = !{!"_ZTS8timespec", !19, i64 0, !19, i64 8}
!28 = !{i64 0, i64 8, !29, i64 8, i64 8, !29}
!29 = !{!19, !19, i64 0}


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