; LLVM IR from apache/mxnet :: example/extensions/lib_custom_op (relu_lib)

; 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::normal_distribution" = type <{ %"struct.std::normal_distribution<float>::param_type", float, i8, [3 x i8] }>
%"struct.std::normal_distribution<float>::param_type" = type { float, float }

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140)) #2 align 2

declare noundef i64 @_ZNK5mxnet3ext8MXTensor4sizeEv(ptr noundef nonnull align 8 dereferenceable(140)) #3

; 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 @_Z15noisyForwardCPURKSt13unordered_mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_St4hashIS5_ESt8equal_toIS5_ESaISt4pairIKS5_S5_EEEPSt6vectorIN5mxnet3ext8MXTensorESaISK_EESN_RKNSJ_10OpResourceE(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(72) %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %"class.std::normal_distribution", align 4
  %13 = alloca i32, align 4
  %14 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef 0)
  %17 = call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %16)
  store ptr %17, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef 0)
  %20 = call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %19)
  store ptr %20, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = call noundef ptr @_ZNK5mxnet3ext10OpResource19get_cpu_rand_statesEv(ptr noundef nonnull align 8 dereferenceable(72) %21)
  store ptr %22, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  call void @_ZNSt19normal_distributionIfEC2Ev(ptr noundef nonnull align 4 dereferenceable(13) %12)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %57, %4
  %24 = load i32, ptr %13, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef 0)
  %28 = call noundef i64 @_ZNK5mxnet3ext8MXTensor4sizeEv(ptr noundef nonnull align 8 dereferenceable(140) %27)
  %29 = icmp slt i64 %25, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %60

31:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = call noundef float @_ZNSt19normal_distributionIfEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEfRT_(ptr noundef nonnull align 4 dereferenceable(13) %12, ptr noundef nonnull align 8 dereferenceable(5000) %32)
  store float %33, ptr %14, align 4, !tbaa !11
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %34, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !11
  %39 = load float, ptr %14, align 4, !tbaa !11
  %40 = fadd float %38, %39
  %41 = fcmp ogt float %40, 0.000000e+00
  br i1 %41, label %42, label %50

42:                                               ; preds = %31
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = load i32, ptr %13, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds float, ptr %43, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !11
  %48 = load float, ptr %14, align 4, !tbaa !11
  %49 = fadd float %47, %48
  br label %51

50:                                               ; preds = %31
  br label %51

51:                                               ; preds = %50, %42
  %52 = phi float [ %49, %42 ], [ 0.000000e+00, %50 ]
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = load i32, ptr %13, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds float, ptr %53, i64 %55
  store float %52, ptr %56, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %57

57:                                               ; preds = %51
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %13, align 4, !tbaa !9
  br label %23, !llvm.loop !13

60:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret i32 1
}

declare noundef ptr @_ZNK5mxnet3ext10OpResource19get_cpu_rand_statesEv(ptr noundef nonnull align 8 dereferenceable(72)) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt19normal_distributionIfEC2Ev(ptr noundef nonnull align 4 dereferenceable(13)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZNSt19normal_distributionIfEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEfRT_(ptr noundef nonnull align 4 dereferenceable(13), ptr noundef nonnull align 8 dereferenceable(5000)) #1 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 = { "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 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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::normal_distribution" = type <{ %"struct.std::normal_distribution<float>::param_type", float, i8, [3 x i8] }>
%"struct.std::normal_distribution<float>::param_type" = type { float, float }

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140)) local_unnamed_addr #2 align 2

declare noundef i64 @_ZNK5mxnet3ext8MXTensor4sizeEv(ptr noundef nonnull align 8 dereferenceable(140)) local_unnamed_addr #3

; 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
define dso_local noundef i32 @_Z15noisyForwardCPURKSt13unordered_mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_St4hashIS5_ESt8equal_toIS5_ESaISt4pairIKS5_S5_EEEPSt6vectorIN5mxnet3ext8MXTensorESaISK_EESN_RKNSJ_10OpResourceE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(56) %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(72) %3) local_unnamed_addr #1 {
  %5 = alloca %"class.std::normal_distribution", align 4
  %6 = tail call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0)
  %7 = tail call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %6)
  %8 = tail call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef 0)
  %9 = tail call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %8)
  %10 = tail call noundef ptr @_ZNK5mxnet3ext10OpResource19get_cpu_rand_statesEv(ptr noundef nonnull align 8 dereferenceable(72) %3)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @_ZNSt19normal_distributionIfEC2Ev(ptr noundef nonnull align 4 dereferenceable(13) %5)
  %11 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0)
  %12 = call noundef i64 @_ZNK5mxnet3ext8MXTensor4sizeEv(ptr noundef nonnull align 8 dereferenceable(140) %11)
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  ret i32 1

.lr.ph:                                           ; preds = %4, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %4 ]
  %14 = call noundef float @_ZNSt19normal_distributionIfEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEfRT_(ptr noundef nonnull align 4 dereferenceable(13) %5, ptr noundef nonnull align 8 dereferenceable(5000) %10)
  %15 = getelementptr inbounds float, ptr %7, i64 %indvars.iv
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = fadd float %14, %16
  %18 = fcmp ogt float %17, 0.000000e+00
  %19 = select i1 %18, float %17, float 0.000000e+00
  %20 = getelementptr inbounds float, ptr %9, i64 %indvars.iv
  store float %19, ptr %20, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0)
  %22 = call noundef i64 @_ZNK5mxnet3ext8MXTensor4sizeEv(ptr noundef nonnull align 8 dereferenceable(140) %21)
  %23 = icmp sgt i64 %22, %indvars.iv.next
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !9
}

declare noundef ptr @_ZNK5mxnet3ext10OpResource19get_cpu_rand_statesEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt19normal_distributionIfEC2Ev(ptr noundef nonnull align 4 dereferenceable(13)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZNSt19normal_distributionIfEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEfRT_(ptr noundef nonnull align 4 dereferenceable(13), ptr noundef nonnull align 8 dereferenceable(5000)) local_unnamed_addr #1 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 = { "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 = !{!"float", !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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass