; LLVM IR from SoloGameDevGitHub/AIEngine :: NeuralNetwork/MLP/MLP.ll (ZNK13NeuralNetwork20MultiLayerPerceptron16randomizeWeightsERS0_)

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

; 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

declare noundef i32 @_ZNK13NeuralNetwork5Layer16getNeuronsLengthEv(ptr noundef nonnull align 8 dereferenceable(32)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK13NeuralNetwork20MultiLayerPerceptron8getLayerEi(ptr noundef nonnull align 8 dereferenceable(64), i32 noundef) #2 align 2

declare noundef nonnull align 8 dereferenceable(40) ptr @_ZNK13NeuralNetwork5Layer9getNeuronEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #1

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

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

11:                                               ; preds = %36, %2
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call noundef i32 @_ZNK13NeuralNetwork20MultiLayerPerceptron15getLayersLengthEv(ptr noundef nonnull align 8 dereferenceable(64) %13)
  %15 = icmp slt i32 %12, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %39

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK13NeuralNetwork20MultiLayerPerceptron8getLayerEi(ptr noundef nonnull align 8 dereferenceable(64) %18, i32 noundef %19)
  store ptr %20, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %32, %17
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = call noundef i32 @_ZNK13NeuralNetwork5Layer16getNeuronsLengthEv(ptr noundef nonnull align 8 dereferenceable(32) %23)
  %25 = icmp slt i32 %22, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %21
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %35

27:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNK13NeuralNetwork5Layer9getNeuronEi(ptr noundef nonnull align 8 dereferenceable(32) %28, i32 noundef %29)
  store ptr %30, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN13NeuralNetwork6Neuron16randomizeWeightsEv(ptr noundef nonnull align 8 dereferenceable(40) %31)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %8, align 4, !tbaa !9
  br label %21, !llvm.loop !11

35:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %36

36:                                               ; preds = %35
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %5, align 4, !tbaa !9
  br label %11, !llvm.loop !13

39:                                               ; preds = %16
  ret void
}

declare void @_ZN13NeuralNetwork6Neuron16randomizeWeightsEv(ptr noundef nonnull align 8 dereferenceable(40)) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

declare noundef i32 @_ZNK13NeuralNetwork5Layer16getNeuronsLengthEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0

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

declare noundef nonnull align 8 dereferenceable(40) ptr @_ZNK13NeuralNetwork5Layer9getNeuronEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK13NeuralNetwork20MultiLayerPerceptron15getLayersLengthEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK13NeuralNetwork20MultiLayerPerceptron16randomizeWeightsERS0_(ptr nocapture noundef nonnull readnone align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(64) %1) local_unnamed_addr #2 align 2 {
  %3 = tail call noundef i32 @_ZNK13NeuralNetwork20MultiLayerPerceptron15getLayersLengthEv(ptr noundef nonnull align 8 dereferenceable(64) %1)
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph15, label %._crit_edge16

._crit_edge16:                                    ; preds = %._crit_edge, %2
  ret void

.lr.ph15:                                         ; preds = %2, %._crit_edge
  %.013 = phi i32 [ %8, %._crit_edge ], [ 0, %2 ]
  %5 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK13NeuralNetwork20MultiLayerPerceptron8getLayerEi(ptr noundef nonnull align 8 dereferenceable(64) %1, i32 noundef %.013)
  %6 = tail call noundef i32 @_ZNK13NeuralNetwork5Layer16getNeuronsLengthEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph15
  %8 = add nuw nsw i32 %.013, 1
  %9 = tail call noundef i32 @_ZNK13NeuralNetwork20MultiLayerPerceptron15getLayersLengthEv(ptr noundef nonnull align 8 dereferenceable(64) %1)
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %.lr.ph15, label %._crit_edge16, !llvm.loop !5

.lr.ph:                                           ; preds = %.lr.ph15, %.lr.ph
  %.01112 = phi i32 [ %12, %.lr.ph ], [ 0, %.lr.ph15 ]
  %11 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNK13NeuralNetwork5Layer9getNeuronEi(ptr noundef nonnull align 8 dereferenceable(32) %5, i32 noundef %.01112)
  tail call void @_ZN13NeuralNetwork6Neuron16randomizeWeightsEv(ptr noundef nonnull align 8 dereferenceable(40) %11)
  %12 = add nuw nsw i32 %.01112, 1
  %13 = tail call noundef i32 @_ZNK13NeuralNetwork5Layer16getNeuronsLengthEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %.lr.ph, label %._crit_edge, !llvm.loop !7
}

declare void @_ZN13NeuralNetwork6Neuron16randomizeWeightsEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0

attributes #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 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" }

!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 = distinct !{!7, !6}


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