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

; 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.__gnu_cxx::__normal_iterator.45" = type { ptr }
%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
define dso_local void @_ZN3Cga13SortAndRecordEv(ptr noundef nonnull align 8 dereferenceable(265) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca %"class.__gnu_cxx::__normal_iterator.45", align 8
  %5 = alloca %"class.__gnu_cxx::__normal_iterator.45", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  %7 = getelementptr inbounds %class.Cga, ptr %6, i32 0, i32 19
  %8 = load i8, ptr %7, align 8, !tbaa !9, !range !27, !noundef !28
  %9 = trunc i8 %8 to i1
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store i8 0, ptr %3, align 1, !tbaa !29
  br label %12

11:                                               ; preds = %1
  store i8 1, ptr %3, align 1, !tbaa !29
  br label %12

12:                                               ; preds = %11, %10
  %13 = getelementptr inbounds %class.Cga, ptr %6, i32 0, i32 0
  %14 = call ptr @_ZNSt6vectorI7CGenomeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #4
  %15 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.45", ptr %4, i32 0, i32 0
  store ptr %14, ptr %15, align 8
  %16 = getelementptr inbounds %class.Cga, ptr %6, i32 0, i32 0
  %17 = call ptr @_ZNSt6vectorI7CGenomeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #4
  %18 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.45", ptr %5, i32 0, i32 0
  store ptr %17, ptr %18, align 8
  %19 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.45", ptr %4, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8
  %21 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.45", ptr %5, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIP7CGenomeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr %20, ptr %22)
  %23 = load i8, ptr %3, align 1, !tbaa !29, !range !27, !noundef !28
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %30

25:                                               ; preds = %12
  %26 = getelementptr inbounds %class.Cga, ptr %6, i32 0, i32 0
  %27 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef 0) #4
  %28 = call noundef double @_ZNK7CGenome7FitnessEv(ptr noundef nonnull align 8 dereferenceable(108) %27)
  %29 = getelementptr inbounds %class.Cga, ptr %6, i32 0, i32 15
  store double %28, ptr %29, align 8, !tbaa !30
  br label %43

30:                                               ; preds = %12
  %31 = getelementptr inbounds %class.Cga, ptr %6, i32 0, i32 0
  %32 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %31, i64 noundef 0) #4
  %33 = call noundef double @_ZNK7CGenome7FitnessEv(ptr noundef nonnull align 8 dereferenceable(108) %32)
  %34 = getelementptr inbounds %class.Cga, ptr %6, i32 0, i32 15
  %35 = load double, ptr %34, align 8, !tbaa !30
  %36 = fcmp ogt double %33, %35
  br i1 %36, label %37, label %42

37:                                               ; preds = %30
  %38 = getelementptr inbounds %class.Cga, ptr %6, i32 0, i32 0
  %39 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %38, i64 noundef 0) #4
  %40 = call noundef double @_ZNK7CGenome7FitnessEv(ptr noundef nonnull align 8 dereferenceable(108) %39)
  %41 = getelementptr inbounds %class.Cga, ptr %6, i32 0, i32 15
  store double %40, ptr %41, align 8, !tbaa !30
  br label %42

42:                                               ; preds = %37, %30
  br label %43

43:                                               ; preds = %42, %25
  call void @_ZN3Cga16StoreBestGenomesEv(ptr noundef nonnull align 8 dereferenceable(265) %6)
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIP7CGenomeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr, ptr) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK7CGenome7FitnessEv(ptr noundef nonnull align 8 dereferenceable(108)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3Cga16StoreBestGenomesEv(ptr noundef nonnull align 8 dereferenceable(265)) #2 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 = { 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 #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 = !{!10, !25, i64 256}
!10 = !{!"_ZTS3Cga", !11, i64 0, !11, i64 24, !11, i64 48, !11, i64 72, !11, i64 96, !15, i64 120, !6, i64 144, !19, i64 152, !19, i64 156, !19, i64 160, !19, i64 164, !20, i64 168, !20, i64 176, !19, i64 184, !20, i64 192, !21, i64 200, !21, i64 224, !20, i64 248, !25, i64 256, !25, i64 257, !26, i64 260, !25, i64 264}
!11 = !{!"_ZTSSt6vectorI7CGenomeSaIS0_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseI7CGenomeSaIS0_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseI7CGenomeSaIS0_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseI7CGenomeSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"_ZTSSt6vectorI8CSpeciesSaIS0_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseI8CSpeciesSaIS0_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseI8CSpeciesSaIS0_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseI8CSpeciesSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"int", !7, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = !{!"_ZTSSt6vectorI10SplitDepthSaIS0_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseI10SplitDepthSaIS0_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseI10SplitDepthSaIS0_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseI10SplitDepthSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!"bool", !7, i64 0}
!26 = !{!"_ZTS13UnderFlowMode", !7, i64 0}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = !{!25, !25, i64 0}
!30 = !{!10, !20, i64 192}


; 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
define dso_local void @_ZN3Cga13SortAndRecordEv(ptr noundef nonnull align 8 dereferenceable(265) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 256
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !26, !noundef !27
  %4 = trunc nuw i8 %3 to i1
  %5 = tail call ptr @_ZNSt6vectorI7CGenomeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  %6 = tail call ptr @_ZNSt6vectorI7CGenomeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  tail call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIP7CGenomeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr %5, ptr %6)
  %7 = tail call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #3
  %8 = tail call noundef double @_ZNK7CGenome7FitnessEv(ptr noundef nonnull align 8 dereferenceable(108) %7)
  %9 = getelementptr inbounds i8, ptr %0, i64 192
  br i1 %4, label %10, label %.sink.split

10:                                               ; preds = %1
  %11 = load double, ptr %9, align 8, !tbaa !28
  %12 = fcmp ogt double %8, %11
  br i1 %12, label %13, label %16

13:                                               ; preds = %10
  %14 = tail call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #3
  %15 = tail call noundef double @_ZNK7CGenome7FitnessEv(ptr noundef nonnull align 8 dereferenceable(108) %14)
  br label %.sink.split

.sink.split:                                      ; preds = %1, %13
  %.sink = phi double [ %15, %13 ], [ %8, %1 ]
  store double %.sink, ptr %9, align 8, !tbaa !28
  br label %16

16:                                               ; preds = %.sink.split, %10
  tail call void @_ZN3Cga16StoreBestGenomesEv(ptr noundef nonnull align 8 dereferenceable(265) %0)
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIP7CGenomeSt6vectorIS2_SaIS2_EEEEEvT_S8_(ptr, ptr) local_unnamed_addr #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK7CGenome7FitnessEv(ptr noundef nonnull align 8 dereferenceable(108)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3Cga16StoreBestGenomesEv(ptr noundef nonnull align 8 dereferenceable(265)) local_unnamed_addr #1 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 = { 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 #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, !24, i64 256}
!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 = !{!6, !19, i64 192}


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