; LLVM IR from NervanaSystems/ngraph :: src/ngraph (coordinate_transform)

; 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.ngraph::CoordinateTransform" = type { %"class.ngraph::Shape", %"class.ngraph::Coordinate", %"class.ngraph::Coordinate", %"class.ngraph::Strides", %"class.ngraph::AxisVector", %"class.ngraph::CoordinateDiff", %"class.ngraph::CoordinateDiff", %"class.ngraph::Strides", %"class.ngraph::Shape", i64, %"class.ngraph::CoordinateTransform::Iterator" }
%"class.ngraph::Coordinate" = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.ngraph::AxisVector" = type { %"class.std::vector" }
%"class.ngraph::CoordinateDiff" = 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<long, std::allocator<long>>::_Vector_impl" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.ngraph::Strides" = type { %"class.std::vector" }
%"class.ngraph::Shape" = type { %"class.std::vector" }
%"class.ngraph::CoordinateTransform::Iterator" = type <{ %"class.ngraph::Shape", %"class.ngraph::Shape", %"class.ngraph::Coordinate", i8, i8, [6 x i8] }>

; 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

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

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

11:                                               ; preds = %16, %2
  %12 = load i64, ptr %7, align 8, !tbaa !9
  %13 = add i64 %12, -1
  store i64 %13, ptr %7, align 8, !tbaa !9
  %14 = icmp ugt i64 %12, 0
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %31

16:                                               ; preds = %11
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load i64, ptr %7, align 8, !tbaa !9
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %18) #2
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = load i64, ptr %6, align 8, !tbaa !9
  %22 = mul i64 %20, %21
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = add i64 %23, %22
  store i64 %24, ptr %5, align 8, !tbaa !9
  %25 = getelementptr inbounds %"class.ngraph::CoordinateTransform", ptr %8, i32 0, i32 0
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %26) #2
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = mul i64 %29, %28
  store i64 %30, ptr %6, align 8, !tbaa !9
  br label %11, !llvm.loop !28

31:                                               ; preds = %15
  %32 = load i64, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret i64 %32
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 216}
!12 = !{!"_ZTSN6ngraph19CoordinateTransformE", !13, i64 0, !18, i64 24, !18, i64 48, !19, i64 72, !20, i64 96, !21, i64 120, !21, i64 144, !19, i64 168, !13, i64 192, !10, i64 216, !26, i64 224}
!13 = !{!"_ZTSN6ngraph5ShapeE", !14, i64 0}
!14 = !{!"_ZTSSt6vectorImSaImEE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseImSaImEE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseImSaImEE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseImSaImEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"_ZTSN6ngraph10CoordinateE", !14, i64 0}
!19 = !{!"_ZTSN6ngraph7StridesE", !14, i64 0}
!20 = !{!"_ZTSN6ngraph10AxisVectorE", !14, i64 0}
!21 = !{!"_ZTSN6ngraph14CoordinateDiffE", !22, i64 0}
!22 = !{!"_ZTSSt6vectorIlSaIlEE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIlSaIlEE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIlSaIlEE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIlSaIlEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!26 = !{!"_ZTSN6ngraph19CoordinateTransform8IteratorE", !13, i64 0, !13, i64 24, !18, i64 48, !27, i64 72, !27, i64 73}
!27 = !{!"bool", !7, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"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 nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZNK6ngraph19CoordinateTransform12index_sourceERKNS_10CoordinateE(ptr noundef nonnull align 8 dereferenceable(304) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 216
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %.not10 = icmp eq i64 %4, 0
  br i1 %.not10, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.09.lcssa = phi i64 [ 0, %2 ], [ %9, %.lr.ph ]
  ret i64 %.09.lcssa

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.013 = phi i64 [ %5, %.lr.ph ], [ %4, %2 ]
  %.0812 = phi i64 [ %12, %.lr.ph ], [ 1, %2 ]
  %.0911 = phi i64 [ %9, %.lr.ph ], [ 0, %2 ]
  %5 = add i64 %.013, -1
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %5) #1
  %7 = load i64, ptr %6, align 8, !tbaa !26
  %8 = mul i64 %7, %.0812
  %9 = add i64 %8, %.0911
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5) #1
  %11 = load i64, ptr %10, align 8, !tbaa !26
  %12 = mul i64 %11, %.0812
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !27
}

attributes #0 = { 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 #1 = { 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, !23, i64 216}
!6 = !{!"_ZTSN6ngraph19CoordinateTransformE", !7, i64 0, !15, i64 24, !15, i64 48, !16, i64 72, !17, i64 96, !18, i64 120, !18, i64 144, !16, i64 168, !7, i64 192, !23, i64 216, !24, i64 224}
!7 = !{!"_ZTSN6ngraph5ShapeE", !8, i64 0}
!8 = !{!"_ZTSSt6vectorImSaImEE", !9, i64 0}
!9 = !{!"_ZTSSt12_Vector_baseImSaImEE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseImSaImEE12_Vector_implE", !11, i64 0}
!11 = !{!"_ZTSNSt12_Vector_baseImSaImEE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"_ZTSN6ngraph10CoordinateE", !8, i64 0}
!16 = !{!"_ZTSN6ngraph7StridesE", !8, i64 0}
!17 = !{!"_ZTSN6ngraph10AxisVectorE", !8, i64 0}
!18 = !{!"_ZTSN6ngraph14CoordinateDiffE", !19, i64 0}
!19 = !{!"_ZTSSt6vectorIlSaIlEE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIlSaIlEE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIlSaIlEE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIlSaIlEE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!23 = !{!"long", !13, i64 0}
!24 = !{!"_ZTSN6ngraph19CoordinateTransform8IteratorE", !7, i64 0, !7, i64 24, !15, i64 48, !25, i64 72, !25, i64 73}
!25 = !{!"bool", !13, i64 0}
!26 = !{!23, !23, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass