; 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: 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 @_Z11backwardCPURKSt13unordered_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 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
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef 0)
  %15 = call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %14)
  store ptr %15, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef 1)
  %18 = call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %17)
  store ptr %18, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef 0)
  %21 = call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %20)
  store ptr %21, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %22

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

29:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %54

30:                                               ; preds = %22
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load i32, ptr %12, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds float, ptr %31, i64 %33
  %35 = load float, ptr %34, align 4, !tbaa !11
  %36 = fcmp ogt float %35, 0.000000e+00
  br i1 %36, label %37, label %44

37:                                               ; preds = %30
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds float, ptr %38, i64 %40
  %42 = load float, ptr %41, align 4, !tbaa !11
  %43 = fmul float 1.000000e+00, %42
  br label %45

44:                                               ; preds = %30
  br label %45

45:                                               ; preds = %44, %37
  %46 = phi float [ %43, %37 ], [ 0.000000e+00, %44 ]
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %47, i64 %49
  store float %46, ptr %50, align 4, !tbaa !11
  br label %51

51:                                               ; preds = %45
  %52 = load i32, ptr %12, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %12, align 4, !tbaa !9
  br label %22, !llvm.loop !13

54:                                               ; preds = %29
  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
}

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"

; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z11backwardCPURKSt13unordered_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) %1, i64 noundef 1)
  %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) %2, i64 noundef 0)
  %10 = tail call noundef ptr @_ZN5mxnet3ext8MXTensor4dataIfEEPT_v(ptr noundef nonnull align 8 dereferenceable(140) %9)
  %11 = tail call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 1)
  %12 = tail 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 = %20, %4
  ret i32 1

.lr.ph:                                           ; preds = %4, %20
  %indvars.iv = phi i64 [ %indvars.iv.next, %20 ], [ 0, %4 ]
  %14 = getelementptr inbounds float, ptr %8, i64 %indvars.iv
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = fcmp ogt float %15, 0.000000e+00
  br i1 %16, label %17, label %20

17:                                               ; preds = %.lr.ph
  %18 = getelementptr inbounds float, ptr %6, i64 %indvars.iv
  %19 = load float, ptr %18, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %.lr.ph, %17
  %21 = phi float [ %19, %17 ], [ 0.000000e+00, %.lr.ph ]
  %22 = getelementptr inbounds float, ptr %10, i64 %indvars.iv
  store float %21, ptr %22, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = tail call noundef nonnull align 8 dereferenceable(140) ptr @_ZNSt6vectorIN5mxnet3ext8MXTensorESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 1)
  %24 = tail call noundef i64 @_ZNK5mxnet3ext8MXTensor4sizeEv(ptr noundef nonnull align 8 dereferenceable(140) %23)
  %25 = icmp sgt i64 %24, %indvars.iv.next
  br i1 %25, label %.lr.ph, label %._crit_edge, !llvm.loop !9
}

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