; LLVM IR from hoodoer/ENNEoS :: enneosEncoder/Cga.ll (ZN3Cga16StoreBestGenomesEv)

; 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.Cga = type <{ %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector.0", ptr, i32, i32, i32, i32, double, double, i32, [4 x i8], double, %"class.std::vector.5", %"class.std::vector.5", double, i8, i8, [2 x i8], i32, i8, [7 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<CGenome, std::allocator<CGenome>>::_Vector_impl" }
%"struct.std::_Vector_base<CGenome, std::allocator<CGenome>>::_Vector_impl" = type { %"struct.std::_Vector_base<CGenome, std::allocator<CGenome>>::_Vector_impl_data" }
%"struct.std::_Vector_base<CGenome, std::allocator<CGenome>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<CSpecies, std::allocator<CSpecies>>::_Vector_impl" }
%"struct.std::_Vector_base<CSpecies, std::allocator<CSpecies>>::_Vector_impl" = type { %"struct.std::_Vector_base<CSpecies, std::allocator<CSpecies>>::_Vector_impl_data" }
%"struct.std::_Vector_base<CSpecies, std::allocator<CSpecies>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<SplitDepth, std::allocator<SplitDepth>>::_Vector_impl" }
%"struct.std::_Vector_base<SplitDepth, std::allocator<SplitDepth>>::_Vector_impl" = type { %"struct.std::_Vector_base<SplitDepth, std::allocator<SplitDepth>>::_Vector_impl_data" }
%"struct.std::_Vector_base<SplitDepth, std::allocator<SplitDepth>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3Cga16StoreBestGenomesEv(ptr noundef nonnull align 8 dereferenceable(265) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %class.Cga, ptr %4, i32 0, i32 1
  call void @_ZNSt6vectorI7CGenomeSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %16, %1
  %7 = load i32, ptr %3, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 3000
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %6
  %11 = getelementptr inbounds %class.Cga, ptr %4, i32 0, i32 1
  %12 = getelementptr inbounds %class.Cga, ptr %4, i32 0, i32 0
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %14) #3
  call void @_ZNSt6vectorI7CGenomeSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %11, ptr noundef nonnull align 8 dereferenceable(108) %15)
  br label %16

16:                                               ; preds = %10
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !11

19:                                               ; preds = %9
  %20 = getelementptr inbounds %class.Cga, ptr %4, i32 0, i32 23
  %21 = load i8, ptr %20, align 8, !tbaa !13, !range !30, !noundef !31
  %22 = trunc i8 %21 to i1
  br i1 %22, label %27, label %23

23:                                               ; preds = %19
  %24 = getelementptr inbounds %class.Cga, ptr %4, i32 0, i32 2
  %25 = getelementptr inbounds %class.Cga, ptr %4, i32 0, i32 1
  %26 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef 0) #3
  call void @_ZNSt6vectorI7CGenomeSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %24, ptr noundef nonnull align 8 dereferenceable(108) %26)
  br label %27

27:                                               ; preds = %23, %19
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !28, i64 264}
!14 = !{!"_ZTS3Cga", !15, i64 0, !15, i64 24, !15, i64 48, !15, i64 72, !15, i64 96, !19, i64 120, !6, i64 144, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !23, i64 168, !23, i64 176, !10, i64 184, !23, i64 192, !24, i64 200, !24, i64 224, !23, i64 248, !28, i64 256, !28, i64 257, !29, i64 260, !28, i64 264}
!15 = !{!"_ZTSSt6vectorI7CGenomeSaIS0_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseI7CGenomeSaIS0_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseI7CGenomeSaIS0_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseI7CGenomeSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"_ZTSSt6vectorI8CSpeciesSaIS0_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseI8CSpeciesSaIS0_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseI8CSpeciesSaIS0_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseI8CSpeciesSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!"double", !7, i64 0}
!24 = !{!"_ZTSSt6vectorI10SplitDepthSaIS0_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseI10SplitDepthSaIS0_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseI10SplitDepthSaIS0_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseI10SplitDepthSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!"bool", !7, i64 0}
!29 = !{!"_ZTS13UnderFlowMode", !7, i64 0}
!30 = !{i8 0, i8 2}
!31 = !{}


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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3Cga16StoreBestGenomesEv(ptr noundef nonnull align 8 dereferenceable(265) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZNSt6vectorI7CGenomeSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  br label %7

3:                                                ; preds = %7
  %4 = getelementptr inbounds i8, ptr %0, i64 264
  %5 = load i8, ptr %4, align 8, !tbaa !5, !range !26, !noundef !27
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %12, label %9

7:                                                ; preds = %1, %7
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next, %7 ]
  %8 = tail call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #2
  tail call void @_ZNSt6vectorI7CGenomeSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(108) %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 3000
  br i1 %exitcond.not, label %3, label %7, !llvm.loop !28

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = tail call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef 0) #2
  tail call void @_ZNSt6vectorI7CGenomeSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 8 dereferenceable(108) %11)
  br label %12

12:                                               ; preds = %9, %3
  ret void
}

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

attributes #0 = { 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 #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 = { 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, !24, i64 264}
!6 = !{!"_ZTS3Cga", !7, i64 0, !7, i64 24, !7, i64 48, !7, i64 72, !7, i64 96, !14, i64 120, !11, i64 144, !18, i64 152, !18, i64 156, !18, i64 160, !18, i64 164, !19, i64 168, !19, i64 176, !18, i64 184, !19, i64 192, !20, i64 200, !20, i64 224, !19, i64 248, !24, i64 256, !24, i64 257, !25, i64 260, !24, i64 264}
!7 = !{!"_ZTSSt6vectorI7CGenomeSaIS0_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseI7CGenomeSaIS0_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseI7CGenomeSaIS0_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseI7CGenomeSaIS0_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"_ZTSSt6vectorI8CSpeciesSaIS0_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseI8CSpeciesSaIS0_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseI8CSpeciesSaIS0_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseI8CSpeciesSaIS0_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!18 = !{!"int", !12, i64 0}
!19 = !{!"double", !12, i64 0}
!20 = !{!"_ZTSSt6vectorI10SplitDepthSaIS0_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseI10SplitDepthSaIS0_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseI10SplitDepthSaIS0_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseI10SplitDepthSaIS0_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!24 = !{!"bool", !12, i64 0}
!25 = !{!"_ZTS13UnderFlowMode", !12, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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