; LLVM IR from CerebusOSS/CereLink :: Central/Instrument.ll (ZN10InstrumentC2Ev)

; 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.Instrument = type <{ ptr, %class.UDPSocket, [6 x %"class.Instrument::CachedPacket"], i32, i32, i32, [4 x i8], ptr, ptr, i32, [4 x i8] }>
%class.UDPSocket = type <{ ptr, i32, %struct.sockaddr_in, i32, i32, i8, i8, [2 x i8] }>
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%"class.Instrument::CachedPacket" = type { i32, i32, i32, i32, i32, [2048 x i8], i32 }

@_ZTV10Instrument = external dso_local unnamed_addr constant { [4 x ptr] }, align 8
@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10InstrumentC2Ev(ptr noundef nonnull align 8 dereferenceable(12516) %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
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV10Instrument, i32 0, i32 0, i32 2), ptr %5, align 8, !tbaa !9
  %6 = getelementptr inbounds %class.Instrument, ptr %5, i32 0, i32 1
  call void @_ZN9UDPSocketC1Ev(ptr noundef nonnull align 8 dereferenceable(38) %6)
  %7 = getelementptr inbounds %class.Instrument, ptr %5, i32 0, i32 2
  %8 = getelementptr inbounds [6 x %"class.Instrument::CachedPacket"], ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds %"class.Instrument::CachedPacket", ptr %8, i64 6
  br label %10

10:                                               ; preds = %12, %1
  %11 = phi ptr [ %8, %1 ], [ %13, %12 ]
  invoke void @_ZN10Instrument12CachedPacketC1Ev(ptr noundef nonnull align 4 dereferenceable(2072) %11)
          to label %12 unwind label %21

12:                                               ; preds = %10
  %13 = getelementptr inbounds %"class.Instrument::CachedPacket", ptr %11, i64 1
  %14 = icmp eq ptr %13, %9
  br i1 %14, label %15, label %10

15:                                               ; preds = %12
  %16 = getelementptr inbounds %class.Instrument, ptr %5, i32 0, i32 4
  store i32 51002, ptr %16, align 4, !tbaa !11
  %17 = getelementptr inbounds %class.Instrument, ptr %5, i32 0, i32 5
  store i32 51001, ptr %17, align 8, !tbaa !20
  %18 = getelementptr inbounds %class.Instrument, ptr %5, i32 0, i32 7
  store ptr @.str, ptr %18, align 8, !tbaa !21
  %19 = getelementptr inbounds %class.Instrument, ptr %5, i32 0, i32 8
  store ptr @.str.1, ptr %19, align 8, !tbaa !22
  %20 = getelementptr inbounds %class.Instrument, ptr %5, i32 0, i32 9
  store i32 16, ptr %20, align 8, !tbaa !23
  ret void

21:                                               ; preds = %10
  %22 = landingpad { ptr, i32 }
          cleanup
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %3, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %4, align 4
  call void @_ZN9UDPSocketD1Ev(ptr noundef nonnull align 8 dereferenceable(38) %6) #3
  br label %25

25:                                               ; preds = %21
  %26 = load ptr, ptr %3, align 8
  %27 = load i32, ptr %4, align 4
  %28 = insertvalue { ptr, i32 } poison, ptr %26, 0
  %29 = insertvalue { ptr, i32 } %28, i32 %27, 1
  resume { ptr, i32 } %29
}

declare void @_ZN9UDPSocketC1Ev(ptr noundef nonnull align 8 dereferenceable(38)) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN9UDPSocketD1Ev(ptr noundef nonnull align 8 dereferenceable(38)) unnamed_addr #2

declare void @_ZN10Instrument12CachedPacketC1Ev(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 = { "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 "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, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !14, i64 12484}
!12 = !{!"_ZTS10Instrument", !13, i64 8, !7, i64 48, !14, i64 12480, !14, i64 12484, !14, i64 12488, !6, i64 12496, !6, i64 12504, !14, i64 12512}
!13 = !{!"_ZTS9UDPSocket", !14, i64 8, !15, i64 12, !18, i64 28, !14, i64 32, !19, i64 36, !19, i64 37}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTS11sockaddr_in", !16, i64 0, !16, i64 2, !17, i64 4, !7, i64 8}
!16 = !{!"short", !7, i64 0}
!17 = !{!"_ZTS7in_addr", !14, i64 0}
!18 = !{!"_ZTS15STARTUP_OPTIONS", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!12, !14, i64 12488}
!21 = !{!12, !6, i64 12496}
!22 = !{!12, !6, i64 12504}
!23 = !{!12, !14, i64 12512}


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

@_ZTV10Instrument = external dso_local unnamed_addr constant { [4 x ptr] }, align 8
@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10InstrumentC2Ev(ptr noundef nonnull align 8 dereferenceable(12516) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV10Instrument, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN9UDPSocketC1Ev(ptr noundef nonnull align 8 dereferenceable(38) %2)
  %.ptr = getelementptr inbounds i8, ptr %0, i64 48
  invoke void @_ZN10Instrument12CachedPacketC1Ev(ptr noundef nonnull align 4 dereferenceable(2072) %.ptr)
          to label %3 unwind label %14

3:                                                ; preds = %1
  %.ptr.1 = getelementptr inbounds i8, ptr %0, i64 2120
  invoke void @_ZN10Instrument12CachedPacketC1Ev(ptr noundef nonnull align 4 dereferenceable(2072) %.ptr.1)
          to label %4 unwind label %14

4:                                                ; preds = %3
  %.ptr.2 = getelementptr inbounds i8, ptr %0, i64 4192
  invoke void @_ZN10Instrument12CachedPacketC1Ev(ptr noundef nonnull align 4 dereferenceable(2072) %.ptr.2)
          to label %5 unwind label %14

5:                                                ; preds = %4
  %.ptr.3 = getelementptr inbounds i8, ptr %0, i64 6264
  invoke void @_ZN10Instrument12CachedPacketC1Ev(ptr noundef nonnull align 4 dereferenceable(2072) %.ptr.3)
          to label %6 unwind label %14

6:                                                ; preds = %5
  %.ptr.4 = getelementptr inbounds i8, ptr %0, i64 8336
  invoke void @_ZN10Instrument12CachedPacketC1Ev(ptr noundef nonnull align 4 dereferenceable(2072) %.ptr.4)
          to label %7 unwind label %14

7:                                                ; preds = %6
  %.ptr.5 = getelementptr inbounds i8, ptr %0, i64 10408
  invoke void @_ZN10Instrument12CachedPacketC1Ev(ptr noundef nonnull align 4 dereferenceable(2072) %.ptr.5)
          to label %8 unwind label %14

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %0, i64 12484
  store i32 51002, ptr %9, align 4, !tbaa !8
  %10 = getelementptr inbounds i8, ptr %0, i64 12488
  store i32 51001, ptr %10, align 8, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 12496
  store ptr @.str, ptr %11, align 8, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %0, i64 12504
  store ptr @.str.1, ptr %12, align 8, !tbaa !21
  %13 = getelementptr inbounds i8, ptr %0, i64 12512
  store i32 16, ptr %13, align 8, !tbaa !22
  ret void

14:                                               ; preds = %7, %6, %5, %4, %3, %1
  %15 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN9UDPSocketD1Ev(ptr noundef nonnull align 8 dereferenceable(38) %2) #3
  resume { ptr, i32 } %15
}

declare void @_ZN9UDPSocketC1Ev(ptr noundef nonnull align 8 dereferenceable(38)) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN9UDPSocketD1Ev(ptr noundef nonnull align 8 dereferenceable(38)) unnamed_addr #2

declare void @_ZN10Instrument12CachedPacketC1Ev(ptr) local_unnamed_addr

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 = { "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 "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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 12484}
!9 = !{!"_ZTS10Instrument", !10, i64 8, !12, i64 48, !11, i64 12480, !11, i64 12484, !11, i64 12488, !18, i64 12496, !18, i64 12504, !11, i64 12512}
!10 = !{!"_ZTS9UDPSocket", !11, i64 8, !13, i64 12, !16, i64 28, !11, i64 32, !17, i64 36, !17, i64 37}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"_ZTS11sockaddr_in", !14, i64 0, !14, i64 2, !15, i64 4, !12, i64 8}
!14 = !{!"short", !12, i64 0}
!15 = !{!"_ZTS7in_addr", !11, i64 0}
!16 = !{!"_ZTS15STARTUP_OPTIONS", !12, i64 0}
!17 = !{!"bool", !12, i64 0}
!18 = !{!"any pointer", !12, i64 0}
!19 = !{!9, !11, i64 12488}
!20 = !{!9, !18, i64 12496}
!21 = !{!9, !18, i64 12504}
!22 = !{!9, !11, i64 12512}


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