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

; 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 }
%struct.SplitDepth = type <{ double, i32, [4 x i8] }>

; 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 uwtable
define dso_local noundef i32 @_ZN3Cga17CalculateNetDepthERK7CGenome(ptr noundef nonnull align 8 dereferenceable(265) %0, ptr noundef nonnull align 8 dereferenceable(108) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %56, %2
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call noundef i32 @_ZNK7CGenome10NumNeuronsEv(ptr noundef nonnull align 8 dereferenceable(108) %12)
  %14 = icmp slt i32 %11, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %10
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %59

16:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %52, %16
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds %class.Cga, ptr %9, i32 0, i32 16
  %21 = call noundef i64 @_ZNKSt6vectorI10SplitDepthSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %20) #3
  %22 = icmp ult i64 %19, %21
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %17
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = call noundef double @_ZNK7CGenome6SplitYEi(ptr noundef nonnull align 8 dereferenceable(108) %25, i32 noundef %26)
  %28 = getelementptr inbounds %class.Cga, ptr %9, i32 0, i32 16
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt6vectorI10SplitDepthSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %30) #3
  %32 = getelementptr inbounds %struct.SplitDepth, ptr %31, i32 0, i32 0
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = fcmp oeq double %27, %33
  br i1 %34, label %35, label %51

35:                                               ; preds = %24
  %36 = getelementptr inbounds %class.Cga, ptr %9, i32 0, i32 16
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt6vectorI10SplitDepthSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %36, i64 noundef %38) #3
  %40 = getelementptr inbounds %struct.SplitDepth, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !14
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = icmp sgt i32 %41, %42
  br i1 %43, label %44, label %51

44:                                               ; preds = %35
  %45 = getelementptr inbounds %class.Cga, ptr %9, i32 0, i32 16
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt6vectorI10SplitDepthSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %45, i64 noundef %47) #3
  %49 = getelementptr inbounds %struct.SplitDepth, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !14
  store i32 %50, ptr %5, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %44, %35, %24
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %8, align 4, !tbaa !9
  br label %17, !llvm.loop !15

55:                                               ; preds = %23
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %6, align 4, !tbaa !9
  br label %10, !llvm.loop !17

59:                                               ; preds = %15
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = add nsw i32 %60, 2
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %61
}

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 = !{!12, !13, i64 0}
!12 = !{!"_ZTS10SplitDepth", !13, i64 0, !10, i64 8}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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
define dso_local noundef range(i32 -2147483646, -2147483648) i32 @_ZN3Cga17CalculateNetDepthERK7CGenome(ptr noundef nonnull align 8 dereferenceable(265) %0, ptr noundef nonnull align 8 dereferenceable(108) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i32 @_ZNK7CGenome10NumNeuronsEv(ptr noundef nonnull align 8 dereferenceable(108) %1)
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.preheader.lr.ph, label %._crit_edge19

.preheader.lr.ph:                                 ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 200
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %.01218 = phi i32 [ 0, %.preheader.lr.ph ], [ %8, %._crit_edge ]
  %.01317 = phi i32 [ 0, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %6 = tail call noundef i64 @_ZNKSt6vectorI10SplitDepthSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #1
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge19.loopexit:                           ; preds = %._crit_edge
  %7 = add nsw i32 %.1.lcssa, 2
  br label %._crit_edge19

._crit_edge19:                                    ; preds = %._crit_edge19.loopexit, %2
  %.013.lcssa = phi i32 [ 2, %2 ], [ %7, %._crit_edge19.loopexit ]
  ret i32 %.013.lcssa

._crit_edge:                                      ; preds = %24, %.preheader
  %.1.lcssa = phi i32 [ %.01317, %.preheader ], [ %.2, %24 ]
  %8 = add nuw nsw i32 %.01218, 1
  %9 = tail call noundef i32 @_ZNK7CGenome10NumNeuronsEv(ptr noundef nonnull align 8 dereferenceable(108) %1)
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %.preheader, label %._crit_edge19.loopexit, !llvm.loop !5

.lr.ph:                                           ; preds = %.preheader, %24
  %indvars.iv = phi i64 [ %indvars.iv.next, %24 ], [ 0, %.preheader ]
  %.115 = phi i32 [ %.2, %24 ], [ %.01317, %.preheader ]
  %11 = tail call noundef double @_ZNK7CGenome6SplitYEi(ptr noundef nonnull align 8 dereferenceable(108) %1, i32 noundef %.01218)
  %12 = tail call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt6vectorI10SplitDepthSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv) #1
  %13 = load double, ptr %12, align 8, !tbaa !7
  %14 = fcmp oeq double %11, %13
  br i1 %14, label %15, label %24

15:                                               ; preds = %.lr.ph
  %16 = tail call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt6vectorI10SplitDepthSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv) #1
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = icmp sgt i32 %18, %.115
  br i1 %19, label %20, label %24

20:                                               ; preds = %15
  %21 = tail call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt6vectorI10SplitDepthSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv) #1
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load i32, ptr %22, align 8, !tbaa !13
  br label %24

24:                                               ; preds = %.lr.ph, %15, %20
  %.2 = phi i32 [ %23, %20 ], [ %.115, %15 ], [ %.115, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = tail call noundef i64 @_ZNKSt6vectorI10SplitDepthSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #1
  %26 = icmp ugt i64 %25, %indvars.iv.next
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !14
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt6vectorI10SplitDepthSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !9, i64 0}
!8 = !{!"_ZTS10SplitDepth", !9, i64 0, !12, i64 8}
!9 = !{!"double", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!8, !12, i64 8}
!14 = distinct !{!14, !6}


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