; LLVM IR from hoodoer/ENNEoS :: enneosEncoder/CSpecies.ll (ZN8CSpecies15AdjustFitnessesEv)

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8CSpecies15AdjustFitnessesEv(ptr noundef nonnull align 8 dereferenceable(168) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store double 0.000000e+00, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %8

8:                                                ; preds = %50, %1
  %9 = load i32, ptr %4, align 4, !tbaa !11
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds %class.CSpecies, ptr %7, i32 0, i32 1
  %12 = call noundef i64 @_ZNKSt6vectorIP7CGenomeSaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #3
  %13 = icmp ult i64 %10, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %53

15:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %16 = getelementptr inbounds %class.CSpecies, ptr %7, i32 0, i32 1
  %17 = load i32, ptr %4, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7CGenomeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %18) #3
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = call noundef double @_ZNK7CGenome7FitnessEv(ptr noundef nonnull align 8 dereferenceable(108) %20)
  store double %21, ptr %5, align 8, !tbaa !9
  %22 = getelementptr inbounds %class.CSpecies, ptr %7, i32 0, i32 5
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = icmp slt i32 %23, 30
  br i1 %24, label %25, label %28

25:                                               ; preds = %15
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = fmul double %26, 1.300000e+00
  store double %27, ptr %5, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %25, %15
  %29 = getelementptr inbounds %class.CSpecies, ptr %7, i32 0, i32 5
  %30 = load i32, ptr %29, align 4, !tbaa !13
  %31 = icmp sgt i32 %30, 70
  br i1 %31, label %32, label %35

32:                                               ; preds = %28
  %33 = load double, ptr %5, align 8, !tbaa !9
  %34 = fmul double %33, 0x3FE6666666666666
  store double %34, ptr %5, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %32, %28
  %36 = load double, ptr %5, align 8, !tbaa !9
  %37 = load double, ptr %3, align 8, !tbaa !9
  %38 = fadd double %37, %36
  store double %38, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %39 = load double, ptr %5, align 8, !tbaa !9
  %40 = getelementptr inbounds %class.CSpecies, ptr %7, i32 0, i32 1
  %41 = call noundef i64 @_ZNKSt6vectorIP7CGenomeSaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #3
  %42 = uitofp i64 %41 to double
  %43 = fdiv double %39, %42
  store double %43, ptr %6, align 8, !tbaa !9
  %44 = getelementptr inbounds %class.CSpecies, ptr %7, i32 0, i32 1
  %45 = load i32, ptr %4, align 4, !tbaa !11
  %46 = sext i32 %45 to i64
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7CGenomeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %44, i64 noundef %46) #3
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = load double, ptr %6, align 8, !tbaa !9
  call void @_ZN7CGenome13SetAdjFitnessEd(ptr noundef nonnull align 8 dereferenceable(108) %48, double noundef %49)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %50

50:                                               ; preds = %35
  %51 = load i32, ptr %4, align 4, !tbaa !11
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %4, align 4, !tbaa !11
  br label %8, !llvm.loop !28

53:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CGenome13SetAdjFitnessEd(ptr noundef nonnull align 8 dereferenceable(108), double noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 156}
!14 = !{!"_ZTS8CSpecies", !15, i64 0, !24, i64 112, !12, i64 136, !10, i64 144, !12, i64 152, !12, i64 156, !10, i64 160}
!15 = !{!"_ZTS7CGenome", !12, i64 0, !16, i64 8, !20, i64 32, !6, i64 56, !12, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !12, i64 96, !12, i64 100, !12, i64 104}
!16 = !{!"_ZTSSt6vectorI11SNeuronGeneSaIS0_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseI11SNeuronGeneSaIS0_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseI11SNeuronGeneSaIS0_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseI11SNeuronGeneSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"_ZTSSt6vectorI9SLinkGeneSaIS0_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseI9SLinkGeneSaIS0_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseI9SLinkGeneSaIS0_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseI9SLinkGeneSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!"_ZTSSt6vectorIP7CGenomeSaIS1_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIP7CGenomeSaIS1_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIP7CGenomeSaIS1_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIP7CGenomeSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = distinct !{!28, !29}
!29 = !{!"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"

; 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 nounwind uwtable
define dso_local void @_ZN8CSpecies15AdjustFitnessesEv(ptr noundef nonnull align 8 dereferenceable(168) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 112
  %3 = tail call noundef i64 @_ZNKSt6vectorIP7CGenomeSaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 156
  br label %5

._crit_edge:                                      ; preds = %5, %1
  ret void

5:                                                ; preds = %.lr.ph, %5
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %5 ]
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7CGenomeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %indvars.iv) #1
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = tail call noundef double @_ZNK7CGenome7FitnessEv(ptr noundef nonnull align 8 dereferenceable(108) %7)
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 30
  %11 = fmul double %8, 1.300000e+00
  %.010 = select i1 %10, double %11, double %8
  %12 = icmp sgt i32 %9, 70
  %13 = fmul double %.010, 0x3FE6666666666666
  %.1 = select i1 %12, double %13, double %.010
  %14 = tail call noundef i64 @_ZNKSt6vectorIP7CGenomeSaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %15 = uitofp i64 %14 to double
  %16 = fdiv double %.1, %15
  %17 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP7CGenomeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %indvars.iv) #1
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  tail call void @_ZN7CGenome13SetAdjFitnessEd(ptr noundef nonnull align 8 dereferenceable(108) %18, double noundef %16)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = tail call noundef i64 @_ZNKSt6vectorIP7CGenomeSaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %20 = icmp ugt i64 %19, %indvars.iv.next
  br i1 %20, label %5, label %._crit_edge, !llvm.loop !26
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CGenome13SetAdjFitnessEd(ptr noundef nonnull align 8 dereferenceable(108), double noundef) 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 = { 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, !12, i64 156}
!10 = !{!"_ZTS8CSpecies", !11, i64 0, !22, i64 112, !12, i64 136, !21, i64 144, !12, i64 152, !12, i64 156, !21, i64 160}
!11 = !{!"_ZTS7CGenome", !12, i64 0, !13, i64 8, !17, i64 32, !6, i64 56, !12, i64 64, !21, i64 72, !21, i64 80, !21, i64 88, !12, i64 96, !12, i64 100, !12, i64 104}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSSt6vectorI11SNeuronGeneSaIS0_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseI11SNeuronGeneSaIS0_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseI11SNeuronGeneSaIS0_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseI11SNeuronGeneSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"_ZTSSt6vectorI9SLinkGeneSaIS0_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseI9SLinkGeneSaIS0_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseI9SLinkGeneSaIS0_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseI9SLinkGeneSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"double", !7, i64 0}
!22 = !{!"_ZTSSt6vectorIP7CGenomeSaIS1_EE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIP7CGenomeSaIS1_EE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIP7CGenomeSaIS1_EE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIP7CGenomeSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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