; LLVM IR from Bousk/Net :: NetworkLib/src/UDP/AckHandler.ll (ZNK5Bousk7Network3UDP10AckHandler10getNewAcksEv)

; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Bousk::Network::UDP::AckHandler" = type <{ i64, i64, %"class.std::vector", i16, i8, [5 x i8] }>

; 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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5Bousk5Utils6HasBitEmh(i64 noundef, i8 noundef zeroext) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorItSaItEE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 2 dereferenceable(2)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK5Bousk7Network3UDP10AckHandler10getNewAcksEv(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8 %0, ptr noundef nonnull align 8 dereferenceable(43) %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i16, align 2
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  store i1 false, ptr %5, align 1
  call void @_ZNSt6vectorItSaItEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  invoke void @_ZNSt6vectorItSaItEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 65)
          to label %12 unwind label %18

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  store i8 64, ptr %8, align 1, !tbaa !9
  br label %13

13:                                               ; preds = %50, %12
  %14 = load i8, ptr %8, align 1, !tbaa !9
  %15 = zext i8 %14 to i32
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %22, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  br label %54

18:                                               ; preds = %58, %2
  %19 = landingpad { ptr, i32 }
          cleanup
  %20 = extractvalue { ptr, i32 } %19, 0
  store ptr %20, ptr %6, align 8
  %21 = extractvalue { ptr, i32 } %19, 1
  store i32 %21, ptr %7, align 4
  br label %65

22:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  %23 = load i8, ptr %8, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = sub nsw i32 %24, 1
  %26 = trunc i32 %25 to i8
  store i8 %26, ptr %9, align 1, !tbaa !9
  %27 = getelementptr inbounds %"class.Bousk::Network::UDP::AckHandler", ptr %11, i32 0, i32 1
  %28 = load i64, ptr %27, align 8, !tbaa !10
  %29 = load i8, ptr %9, align 1, !tbaa !9
  %30 = invoke noundef zeroext i1 @_ZN5Bousk5Utils6HasBitEmh(i64 noundef %28, i8 noundef zeroext %29)
          to label %31 unwind label %41

31:                                               ; preds = %22
  br i1 %30, label %32, label %49

32:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #4
  %33 = getelementptr inbounds %"class.Bousk::Network::UDP::AckHandler", ptr %11, i32 0, i32 3
  %34 = load i16, ptr %33, align 8, !tbaa !19
  %35 = zext i16 %34 to i32
  %36 = load i8, ptr %8, align 1, !tbaa !9
  %37 = zext i8 %36 to i32
  %38 = sub nsw i32 %35, %37
  %39 = trunc i32 %38 to i16
  store i16 %39, ptr %10, align 2, !tbaa !20
  invoke void @_ZNSt6vectorItSaItEE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 2 dereferenceable(2) %10)
          to label %40 unwind label %45

40:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #4
  br label %49

41:                                               ; preds = %22
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %6, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %7, align 4
  br label %53

45:                                               ; preds = %32
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %6, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #4
  br label %53

49:                                               ; preds = %40, %31
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  br label %50

50:                                               ; preds = %49
  %51 = load i8, ptr %8, align 1, !tbaa !9
  %52 = add i8 %51, -1
  store i8 %52, ptr %8, align 1, !tbaa !9
  br label %13, !llvm.loop !21

53:                                               ; preds = %45, %41
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  br label %65

54:                                               ; preds = %17
  %55 = getelementptr inbounds %"class.Bousk::Network::UDP::AckHandler", ptr %11, i32 0, i32 4
  %56 = load i8, ptr %55, align 2, !tbaa !23, !range !24, !noundef !25
  %57 = trunc i8 %56 to i1
  br i1 %57, label %58, label %61

58:                                               ; preds = %54
  %59 = getelementptr inbounds %"class.Bousk::Network::UDP::AckHandler", ptr %11, i32 0, i32 3
  invoke void @_ZNSt6vectorItSaItEE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 2 dereferenceable(2) %59)
          to label %60 unwind label %18

60:                                               ; preds = %58
  br label %61

61:                                               ; preds = %60, %54
  store i1 true, ptr %5, align 1
  %62 = load i1, ptr %5, align 1
  br i1 %62, label %64, label %63

63:                                               ; preds = %61
  call void @_ZNSt6vectorItSaItEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %64

64:                                               ; preds = %63, %61
  ret void

65:                                               ; preds = %53, %18
  call void @_ZNSt6vectorItSaItEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %66

66:                                               ; preds = %65
  %67 = load ptr, ptr %6, align 8
  %68 = load i32, ptr %7, align 4
  %69 = insertvalue { ptr, i32 } poison, ptr %67, 0
  %70 = insertvalue { ptr, i32 } %69, i32 %68, 1
  resume { ptr, i32 } %70
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorItSaItEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

declare i32 @__gxx_personality_v0(...)

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 #4 = { 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, !12, i64 8}
!11 = !{!"_ZTSN5Bousk7Network3UDP10AckHandlerE", !12, i64 0, !12, i64 8, !13, i64 16, !17, i64 40, !18, i64 42}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_ZTSSt6vectorItSaItEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseItSaItEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseItSaItEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseItSaItEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"short", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!11, !17, i64 40}
!20 = !{!17, !17, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!11, !18, i64 42}
!24 = !{i8 0, i8 2}
!25 = !{}


; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned short, std::allocator<unsigned short>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5Bousk5Utils6HasBitEmh(i64 noundef, i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorItSaItEE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 2 dereferenceable(2)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK5Bousk7Network3UDP10AckHandler10getNewAcksEv(ptr dead_on_unwind noalias nonnull writable sret(%"class.std::vector") align 8 %0, ptr noundef nonnull align 8 dereferenceable(43) %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i16, align 2
  tail call void @_ZNSt6vectorItSaItEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  invoke void @_ZNSt6vectorItSaItEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 65)
          to label %.preheader unwind label %10

.preheader:                                       ; preds = %2
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = getelementptr inbounds i8, ptr %1, i64 40
  br label %12

6:                                                ; preds = %22
  %7 = getelementptr inbounds i8, ptr %1, i64 42
  %8 = load i8, ptr %7, align 2, !tbaa !5, !range !17, !noundef !18
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %23, label %24

10:                                               ; preds = %23, %2
  %11 = landingpad { ptr, i32 }
          cleanup
  br label %25

12:                                               ; preds = %.preheader, %22
  %indvars.iv = phi i16 [ 64, %.preheader ], [ %indvars.iv.next, %22 ]
  %indvars.iv.next = add nsw i16 %indvars.iv, -1
  %13 = load i64, ptr %4, align 8, !tbaa !19
  %14 = trunc nuw nsw i16 %indvars.iv.next to i8
  %15 = call noundef zeroext i1 @_ZN5Bousk5Utils6HasBitEmh(i64 noundef %13, i8 noundef zeroext %14)
  br i1 %15, label %16, label %22

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %3) #4
  %17 = load i16, ptr %5, align 8, !tbaa !20
  %18 = sub i16 %17, %indvars.iv
  store i16 %18, ptr %3, align 2, !tbaa !21
  invoke void @_ZNSt6vectorItSaItEE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 2 dereferenceable(2) %3)
          to label %19 unwind label %20

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #4
  br label %22

20:                                               ; preds = %16
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #4
  br label %25

22:                                               ; preds = %19, %12
  %.not = icmp eq i16 %indvars.iv.next, 0
  br i1 %.not, label %6, label %12, !llvm.loop !22

23:                                               ; preds = %6
  invoke void @_ZNSt6vectorItSaItEE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 2 dereferenceable(2) %5)
          to label %24 unwind label %10

24:                                               ; preds = %6, %23
  ret void

25:                                               ; preds = %20, %10
  %.pn = phi { ptr, i32 } [ %21, %20 ], [ %11, %10 ]
  call void @_ZNSt6vectorItSaItEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  resume { ptr, i32 } %.pn
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorItSaItEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 #4 = { 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, !16, i64 42}
!6 = !{!"_ZTSN5Bousk7Network3UDP10AckHandlerE", !7, i64 0, !7, i64 8, !10, i64 16, !15, i64 40, !16, i64 42}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorItSaItEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseItSaItEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseItSaItEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseItSaItEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"short", !8, i64 0}
!16 = !{!"bool", !8, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!6, !7, i64 8}
!20 = !{!6, !15, i64 40}
!21 = !{!15, !15, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass