; LLVM IR from elfsternberg/SimpleGarbageCollector :: src/collector.ll (Z8perfTestv)

; 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::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"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 }
%"class.std::locale" = type { ptr }
%class.VM = type { i32, [256 x ptr], ptr, i32, i32 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.7 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072), i32 noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8perfTestv() #1 {
  %1 = alloca %class.VM, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.7)
  %7 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.start.p0(i64 2072, ptr %1) #4
  call void @_ZN2VMC2Ev(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %34, %0
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 1000
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %37

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %20, %12
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = icmp slt i32 %14, 20
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %23

17:                                               ; preds = %13
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %18)
  br label %20

20:                                               ; preds = %17
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %4, align 4, !tbaa !5
  br label %13, !llvm.loop !9

23:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %30, %23
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 20
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %33

28:                                               ; preds = %24
  %29 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  br label %30

30:                                               ; preds = %28
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %5, align 4, !tbaa !5
  br label %24, !llvm.loop !11

33:                                               ; preds = %27
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !12

37:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 2072, ptr %1) #4
  ret void
}

attributes #0 = { inlinehint 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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; 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::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"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 }
%"class.std::locale" = type { ptr }
%class.VM = type { i32, [256 x ptr], ptr, i32, i32 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.7 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072), i32 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8perfTestv() local_unnamed_addr #1 {
  %1 = alloca %class.VM, align 8
  %2 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.7)
  %3 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.start.p0(i64 2072, ptr nonnull %1) #4
  call void @_ZN2VMC2Ev(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  br label %.preheader9

.preheader9:                                      ; preds = %0, %.preheader9
  %.0812 = phi i32 [ 0, %0 ], [ %44, %.preheader9 ]
  %4 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %5 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %6 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %7 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %8 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %9 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %10 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %11 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %12 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %13 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %14 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %15 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %16 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %17 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %18 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %19 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %20 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %21 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %22 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %23 = call noundef ptr @_ZN2VM4pushEi(ptr noundef nonnull align 8 dereferenceable(2072) %1, i32 noundef %.0812)
  %24 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %25 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %26 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %27 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %28 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %29 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %30 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %31 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %32 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %33 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %34 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %35 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %36 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %37 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %38 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %39 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %40 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %41 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %42 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %43 = call noundef ptr @_ZN2VM3popEv(ptr noundef nonnull align 8 dereferenceable(2072) %1)
  %44 = add nuw nsw i32 %.0812, 1
  %exitcond.not = icmp eq i32 %44, 1000
  br i1 %exitcond.not, label %45, label %.preheader9, !llvm.loop !5

45:                                               ; preds = %.preheader9
  call void @llvm.lifetime.end.p0(i64 2072, ptr nonnull %1) #4
  ret void
}

attributes #0 = { inlinehint 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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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