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

; 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.25" = type { %"struct.std::_Vector_base.26" }
%"struct.std::_Vector_base.26" = type { %"struct.std::_Vector_base<CNeuralNet *, std::allocator<CNeuralNet *>>::_Vector_impl" }
%"struct.std::_Vector_base<CNeuralNet *, std::allocator<CNeuralNet *>>::_Vector_impl" = type { %"struct.std::_Vector_base<CNeuralNet *, std::allocator<CNeuralNet *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<CNeuralNet *, std::allocator<CNeuralNet *>>::_Vector_impl_data" = type { ptr, ptr, 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

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZNSt6vectorIP10CNeuralNetSaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3Cga17CalculateNetDepthERK7CGenome(ptr noundef nonnull align 8 dereferenceable(265), ptr noundef nonnull align 8 dereferenceable(108)) #2 align 2

; 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 nounwind uwtable
declare dso_local void @_ZN7CGenome8SetDepthEi(ptr noundef nonnull align 8 dereferenceable(108), i32 noundef) #1 align 2

declare noundef ptr @_ZN7CGenome15CreatePhenotypeEv(ptr noundef nonnull align 8 dereferenceable(108)) #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3Cga35GetBestPhenotypesFromLastGenerationEi(ptr dead_on_unwind noalias writable sret(%"class.std::vector.25") align 8 %0, ptr noundef nonnull align 8 dereferenceable(265) %1, i32 noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i1, align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8
  store i1 false, ptr %7, align 1
  call void @_ZNSt6vectorIP10CNeuralNetSaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %39, %3
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %51

19:                                               ; preds = %14
  %20 = getelementptr inbounds %class.Cga, ptr %13, i32 0, i32 1
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %20, i64 noundef %22) #4
  %24 = invoke noundef i32 @_ZN3Cga17CalculateNetDepthERK7CGenome(ptr noundef nonnull align 8 dereferenceable(265) %13, ptr noundef nonnull align 8 dereferenceable(108) %23)
          to label %25 unwind label %42

25:                                               ; preds = %19
  store i32 %24, ptr %8, align 4, !tbaa !9
  %26 = getelementptr inbounds %class.Cga, ptr %13, i32 0, i32 1
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef %28) #4
  %30 = load i32, ptr %8, align 4, !tbaa !9
  invoke void @_ZN7CGenome8SetDepthEi(ptr noundef nonnull align 8 dereferenceable(108) %29, i32 noundef %30)
          to label %31 unwind label %42

31:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %32 = getelementptr inbounds %class.Cga, ptr %13, i32 0, i32 1
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %34) #4
  %36 = invoke noundef ptr @_ZN7CGenome15CreatePhenotypeEv(ptr noundef nonnull align 8 dereferenceable(108) %35)
          to label %37 unwind label %46

37:                                               ; preds = %31
  store ptr %36, ptr %12, align 8, !tbaa !5
  invoke void @_ZNSt6vectorIP10CNeuralNetSaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(8) %12)
          to label %38 unwind label %46

38:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %9, align 4, !tbaa !9
  br label %14, !llvm.loop !11

42:                                               ; preds = %25, %19
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %10, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %11, align 4
  br label %50

46:                                               ; preds = %37, %31
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %10, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %50

50:                                               ; preds = %46, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @_ZNSt6vectorIP10CNeuralNetSaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %55

51:                                               ; preds = %18
  store i1 true, ptr %7, align 1
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %52 = load i1, ptr %7, align 1
  br i1 %52, label %54, label %53

53:                                               ; preds = %51
  call void @_ZNSt6vectorIP10CNeuralNetSaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %54

54:                                               ; preds = %53, %51
  ret void

55:                                               ; preds = %50
  %56 = load ptr, ptr %10, align 8
  %57 = load i32, ptr %11, align 4
  %58 = insertvalue { ptr, i32 } poison, ptr %56, 0
  %59 = insertvalue { ptr, i32 } %58, i32 %57, 1
  resume { ptr, i32 } %59
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIP10CNeuralNetSaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #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 = { "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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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.25" = type { %"struct.std::_Vector_base.26" }
%"struct.std::_Vector_base.26" = type { %"struct.std::_Vector_base<CNeuralNet *, std::allocator<CNeuralNet *>>::_Vector_impl" }
%"struct.std::_Vector_base<CNeuralNet *, std::allocator<CNeuralNet *>>::_Vector_impl" = type { %"struct.std::_Vector_base<CNeuralNet *, std::allocator<CNeuralNet *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<CNeuralNet *, std::allocator<CNeuralNet *>>::_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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress 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 void @_ZNSt6vectorIP10CNeuralNetSaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3Cga17CalculateNetDepthERK7CGenome(ptr noundef nonnull align 8 dereferenceable(265), ptr noundef nonnull align 8 dereferenceable(108)) local_unnamed_addr #2 align 2

; 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 #1 align 2

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

declare noundef ptr @_ZN7CGenome15CreatePhenotypeEv(ptr noundef nonnull align 8 dereferenceable(108)) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3Cga35GetBestPhenotypesFromLastGenerationEi(ptr dead_on_unwind noalias nonnull writable sret(%"class.std::vector.25") align 8 %0, ptr noundef nonnull align 8 dereferenceable(265) %1, i32 noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  tail call void @_ZNSt6vectorIP10CNeuralNetSaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %5 = icmp sgt i32 %2, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %6 = getelementptr inbounds i8, ptr %1, i64 24
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %7

7:                                                ; preds = %.lr.ph, %15
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %15 ]
  %8 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %indvars.iv) #4
  %9 = invoke noundef i32 @_ZN3Cga17CalculateNetDepthERK7CGenome(ptr noundef nonnull align 8 dereferenceable(265) %1, ptr noundef nonnull align 8 dereferenceable(108) %8)
          to label %10 unwind label %16

10:                                               ; preds = %7
  %11 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %indvars.iv) #4
  call void @_ZN7CGenome8SetDepthEi(ptr noundef nonnull align 8 dereferenceable(108) %11, i32 noundef %9)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %12 = call noundef nonnull align 8 dereferenceable(108) ptr @_ZNSt6vectorI7CGenomeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %indvars.iv) #4
  %13 = invoke noundef ptr @_ZN7CGenome15CreatePhenotypeEv(ptr noundef nonnull align 8 dereferenceable(108) %12)
          to label %14 unwind label %18

14:                                               ; preds = %10
  store ptr %13, ptr %4, align 8, !tbaa !5
  invoke void @_ZNSt6vectorIP10CNeuralNetSaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %15 unwind label %18

15:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %7, !llvm.loop !9

16:                                               ; preds = %7
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %20

18:                                               ; preds = %14, %10
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %20

20:                                               ; preds = %18, %16
  %.pn = phi { ptr, i32 } [ %19, %18 ], [ %17, %16 ]
  call void @_ZNSt6vectorIP10CNeuralNetSaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  resume { ptr, i32 } %.pn

._crit_edge:                                      ; preds = %15, %3
  ret void
}

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

attributes #0 = { mustprogress 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 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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