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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z10forwardCPURKSt13unordered_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) #0 {
  %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 i32, 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
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef 0)
  %14 = call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %13)
  store ptr %14, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %15 = load ptr, ptr %7, 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 %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %46, %4
  %19 = load i32, ptr %11, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef 0)
  %23 = call noundef i64 @_ZNK5mxnet3ext8MXTensor4sizeEv(ptr noundef nonnull align 8 dereferenceable(140) %22)
  %24 = icmp slt i64 %20, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %49

26:                                               ; preds = %18
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds float, ptr %27, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !11
  %32 = fcmp ogt float %31, 0.000000e+00
  br i1 %32, label %33, label %39

33:                                               ; preds = %26
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i32, ptr %11, 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
  br label %40

39:                                               ; preds = %26
  br label %40

40:                                               ; preds = %39, %33
  %41 = phi float [ %38, %33 ], [ 0.000000e+00, %39 ]
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds float, ptr %42, i64 %44
  store float %41, ptr %45, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %40
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %11, align 4, !tbaa !9
  br label %18, !llvm.loop !13

49:                                               ; preds = %25
  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
}

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

; 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) #0 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) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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"

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z10forwardCPURKSt13unordered_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 nocapture noundef nonnull readnone align 8 dereferenceable(72) %3) local_unnamed_addr #0 {
  %5 = tail call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0)
  %6 = tail call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %5)
  %7 = tail call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef 0)
  %8 = tail call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %7)
  %9 = tail call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0)
  %10 = tail call noundef i64 @_ZNK5mxnet3ext8MXTensor4sizeEv(ptr noundef nonnull align 8 dereferenceable(140) %9)
  %11 = icmp sgt i64 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %4
  ret i32 1

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

; 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 #0 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 #1 align 2

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

attributes #0 = { 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 #1 = { 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 #2 = { "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 = !{!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,SROAPass,SimplifyCFGPass,TailCallElimPass