; LLVM IR from Sentdex/NNfSiX :: C++/p006-Softmax-Activation.ll (ZN6numcpp6Random6MatrixEjjddRNS_6MatrixINS_6VectorIdEEEE)

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

%"struct.numcpp::Vector" = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.numcpp::Matrix" = type { %"class.std::vector.0" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<numcpp::Vector<double>, std::allocator<numcpp::Vector<double>>>::_Vector_impl" }
%"struct.std::_Vector_base<numcpp::Vector<double>, std::allocator<numcpp::Vector<double>>>::_Vector_impl" = type { %"struct.std::_Vector_base<numcpp::Vector<double>, std::allocator<numcpp::Vector<double>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<numcpp::Vector<double>, std::allocator<numcpp::Vector<double>>>::_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 uwtable
declare dso_local noundef double @_ZN6numcpp6Random5RangeEdd(ptr noundef nonnull align 8 dereferenceable(5000), double noundef, double noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6numcpp6Random6MatrixEjjddRNS_6MatrixINS_6VectorIdEEEE(ptr noundef nonnull align 8 dereferenceable(5000) %0, i32 noundef %1, i32 noundef %2, double noundef %3, double noundef %4, ptr noundef nonnull align 8 dereferenceable(24) %5) #1 align 2 personality ptr @__gxx_personality_v0 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %"struct.numcpp::Vector", align 8
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store double %3, ptr %10, align 8, !tbaa !11
  store double %4, ptr %11, align 8, !tbaa !11
  store ptr %5, ptr %12, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %50, %6
  %22 = load i32, ptr %13, align 4, !tbaa !9
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = icmp ult i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %58

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #3
  call void @_ZN6numcpp6VectorIdEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %39, %26
  %28 = load i32, ptr %16, align 4, !tbaa !9
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = icmp ult i32 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %46

32:                                               ; preds = %27
  %33 = getelementptr inbounds %"struct.numcpp::Vector", ptr %15, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %34 = load double, ptr %10, align 8, !tbaa !11
  %35 = load double, ptr %11, align 8, !tbaa !11
  %36 = invoke noundef double @_ZN6numcpp6Random5RangeEdd(ptr noundef nonnull align 8 dereferenceable(5000) %20, double noundef %34, double noundef %35)
          to label %37 unwind label %42

37:                                               ; preds = %32
  store double %36, ptr %17, align 8, !tbaa !11
  invoke void @_ZNSt6vectorIdSaIdEE9push_backEOd(ptr noundef nonnull align 8 dereferenceable(24) %33, ptr noundef nonnull align 8 dereferenceable(8) %17)
          to label %38 unwind label %42

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

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

42:                                               ; preds = %37, %32
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %18, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %57

46:                                               ; preds = %31
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.numcpp::Matrix", ptr %47, i32 0, i32 0
  invoke void @_ZNSt6vectorIN6numcpp6VectorIdEESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %48, ptr noundef nonnull align 8 dereferenceable(24) %15)
          to label %49 unwind label %53

49:                                               ; preds = %46
  call void @_ZN6numcpp6VectorIdED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %15) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #3
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = add i32 %51, 1
  store i32 %52, ptr %13, align 4, !tbaa !9
  br label %21, !llvm.loop !15

53:                                               ; preds = %46
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %18, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %19, align 4
  br label %57

57:                                               ; preds = %53, %42
  call void @_ZN6numcpp6VectorIdED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %15) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %59

58:                                               ; preds = %25
  ret void

59:                                               ; preds = %57
  %60 = load ptr, ptr %18, align 8
  %61 = load i32, ptr %19, align 4
  %62 = insertvalue { ptr, i32 } poison, ptr %60, 0
  %63 = insertvalue { ptr, i32 } %62, i32 %61, 1
  resume { ptr, i32 } %63
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6numcpp6VectorIdED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #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 = { inlinehint 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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

%"struct.numcpp::Vector" = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_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 uwtable
declare dso_local noundef double @_ZN6numcpp6Random5RangeEdd(ptr noundef nonnull align 8 dereferenceable(5000), double noundef, double noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6numcpp6Random6MatrixEjjddRNS_6MatrixINS_6VectorIdEEEE(ptr noundef nonnull align 8 dereferenceable(5000) %0, i32 noundef %1, i32 noundef %2, double noundef %3, double noundef %4, ptr noundef nonnull align 8 dereferenceable(24) %5) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %7 = alloca %"struct.numcpp::Vector", align 8
  %8 = alloca double, align 8
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %._crit_edge19, label %.lr.ph18

.lr.ph18:                                         ; preds = %6
  %.not23 = icmp eq i32 %2, 0
  br i1 %.not23, label %.lr.ph18.split, label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph18, %9
  %.01316.us = phi i32 [ %10, %9 ], [ 0, %.lr.ph18 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  call void @_ZN6numcpp6VectorIdEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  br label %11

9:                                                ; preds = %._crit_edge.us
  call void @_ZN6numcpp6VectorIdED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  %10 = add nuw i32 %.01316.us, 1
  %exitcond25.not = icmp eq i32 %10, %1
  br i1 %exitcond25.not, label %._crit_edge19, label %.lr.ph.us, !llvm.loop !5

11:                                               ; preds = %.lr.ph.us, %14
  %.01215.us = phi i32 [ 0, %.lr.ph.us ], [ %15, %14 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  %12 = invoke noundef double @_ZN6numcpp6Random5RangeEdd(ptr noundef nonnull align 8 dereferenceable(5000) %0, double noundef %3, double noundef %4)
          to label %13 unwind label %.split21.us

13:                                               ; preds = %11
  store double %12, ptr %8, align 8, !tbaa !7
  invoke void @_ZNSt6vectorIdSaIdEE9push_backEOd(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %14 unwind label %.split21.us

14:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  %15 = add nuw i32 %.01215.us, 1
  %exitcond.not = icmp eq i32 %15, %2
  br i1 %exitcond.not, label %._crit_edge.us, label %11, !llvm.loop !11

._crit_edge.us:                                   ; preds = %14
  invoke void @_ZNSt6vectorIN6numcpp6VectorIdEESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %7)
          to label %9 unwind label %.split.us

.split.us:                                        ; preds = %._crit_edge.us
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %21

.split21.us:                                      ; preds = %13, %11
  %17 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  br label %21

._crit_edge19:                                    ; preds = %9, %18, %6
  ret void

.lr.ph18.split:                                   ; preds = %.lr.ph18, %18
  %.01316 = phi i32 [ %19, %18 ], [ 0, %.lr.ph18 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  call void @_ZN6numcpp6VectorIdEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  invoke void @_ZNSt6vectorIN6numcpp6VectorIdEESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %7)
          to label %18 unwind label %.split

18:                                               ; preds = %.lr.ph18.split
  call void @_ZN6numcpp6VectorIdED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  %19 = add nuw i32 %.01316, 1
  %exitcond26.not = icmp eq i32 %19, %1
  br i1 %exitcond26.not, label %._crit_edge19, label %.lr.ph18.split, !llvm.loop !5

.split:                                           ; preds = %.lr.ph18.split
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %21

21:                                               ; preds = %.split, %.split.us, %.split21.us
  %.pn = phi { ptr, i32 } [ %17, %.split21.us ], [ %20, %.split ], [ %16, %.split.us ]
  call void @_ZN6numcpp6VectorIdED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  resume { ptr, i32 } %.pn
}

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

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

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

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

attributes #0 = { mustprogress 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 = { inlinehint 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}


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