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

; 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.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.ngraph::CoordinateTransform::Iterator" = type <{ %"class.ngraph::Shape", %"class.ngraph::Shape", %"class.ngraph::Coordinate", i8, i8, [6 x i8] }>
%"class.ngraph::Shape" = 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::Coordinate" = type { %"class.std::vector" }

; 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 i64 @_ZNKSt6vectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6ngraph19CoordinateTransform8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(74) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  %9 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 3
  %10 = load i8, ptr %9, align 8, !tbaa !9, !range !18, !noundef !19
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %28

12:                                               ; preds = %1
  %13 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 2
  %14 = call ptr @_ZNSt6vectorImSaImEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #4
  %15 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %3, i32 0, i32 0
  store ptr %14, ptr %15, align 8
  %16 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 2
  %17 = call ptr @_ZNSt6vectorImSaImEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #4
  %18 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  store ptr %17, ptr %18, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !20
  %19 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %3, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8
  %21 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8
  call void @_ZSt4fillIN9__gnu_cxx17__normal_iteratorIPmSt6vectorImSaImEEEEiEvT_S7_RKT0_(ptr %20, ptr %22, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %23 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 4
  %24 = load i8, ptr %23, align 1, !tbaa !22, !range !18, !noundef !19
  %25 = trunc i8 %24 to i1
  %26 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 3
  %27 = zext i1 %25 to i8
  store i8 %27, ptr %26, align 8, !tbaa !9
  br label %61

28:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %29 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 0
  %30 = call noundef i64 @_ZNKSt6vectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %29) #4
  store i64 %30, ptr %6, align 8, !tbaa !23
  br label %31

31:                                               ; preds = %56, %28
  %32 = load i64, ptr %6, align 8, !tbaa !23
  %33 = add i64 %32, -1
  store i64 %33, ptr %6, align 8, !tbaa !23
  %34 = icmp ugt i64 %32, 0
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 2, ptr %7, align 4
  br label %57

36:                                               ; preds = %31
  %37 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 2
  %38 = load i64, ptr %6, align 8, !tbaa !23
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %38) #4
  %40 = load i64, ptr %39, align 8, !tbaa !23
  %41 = add i64 %40, 1
  store i64 %41, ptr %39, align 8, !tbaa !23
  %42 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 2
  %43 = load i64, ptr %6, align 8, !tbaa !23
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %42, i64 noundef %43) #4
  %45 = load i64, ptr %44, align 8, !tbaa !23
  %46 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 0
  %47 = load i64, ptr %6, align 8, !tbaa !23
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %46, i64 noundef %47) #4
  %49 = load i64, ptr %48, align 8, !tbaa !23
  %50 = icmp ult i64 %45, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %36
  store i32 1, ptr %7, align 4
  br label %57

52:                                               ; preds = %36
  %53 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 2
  %54 = load i64, ptr %6, align 8, !tbaa !23
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %53, i64 noundef %54) #4
  store i64 0, ptr %55, align 8, !tbaa !23
  br label %56

56:                                               ; preds = %52
  br label %31, !llvm.loop !25

57:                                               ; preds = %51, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %58 = load i32, ptr %7, align 4
  switch i32 %58, label %62 [
    i32 2, label %59
    i32 1, label %61
  ]

59:                                               ; preds = %57
  %60 = getelementptr inbounds %"class.ngraph::CoordinateTransform::Iterator", ptr %8, i32 0, i32 3
  store i8 1, ptr %60, align 8, !tbaa !9
  br label %61

61:                                               ; preds = %59, %57, %12
  ret void

62:                                               ; preds = %57
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIN9__gnu_cxx17__normal_iteratorIPmSt6vectorImSaImEEEEiEvT_S7_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(4)) #3

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 = { 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 #3 = { inlinehint 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 #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, !17, i64 72}
!10 = !{!"_ZTSN6ngraph19CoordinateTransform8IteratorE", !11, i64 0, !11, i64 24, !16, i64 48, !17, i64 72, !17, i64 73}
!11 = !{!"_ZTSN6ngraph5ShapeE", !12, i64 0}
!12 = !{!"_ZTSSt6vectorImSaImEE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseImSaImEE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseImSaImEE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseImSaImEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!"_ZTSN6ngraph10CoordinateE", !12, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!21, !21, i64 0}
!21 = !{!"int", !7, i64 0}
!22 = !{!10, !17, i64 73}
!23 = !{!24, !24, i64 0}
!24 = !{!"long", !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6ngraph19CoordinateTransform8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(74) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca i32, align 4
  %3 = getelementptr inbounds i8, ptr %0, i64 72
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !17, !noundef !18
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %6, label %12

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = tail call ptr @_ZNSt6vectorImSaImEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %9 = tail call ptr @_ZNSt6vectorImSaImEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  store i32 0, ptr %2, align 4, !tbaa !19
  call void @_ZSt4fillIN9__gnu_cxx17__normal_iteratorIPmSt6vectorImSaImEEEEiEvT_S7_RKT0_(ptr %8, ptr %9, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  %10 = getelementptr inbounds i8, ptr %0, i64 73
  %11 = load i8, ptr %10, align 1, !tbaa !21, !range !17, !noundef !18
  br label %.loopexit.sink.split

12:                                               ; preds = %1
  %13 = tail call noundef i64 @_ZNKSt6vectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %.not11 = icmp eq i64 %13, 0
  br i1 %.not11, label %.loopexit.sink.split, label %.lr.ph

.lr.ph:                                           ; preds = %12
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  br label %15

15:                                               ; preds = %.lr.ph, %25
  %.in = phi i64 [ %13, %.lr.ph ], [ %16, %25 ]
  %16 = add i64 %.in, -1
  %17 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %16) #4
  %18 = load i64, ptr %17, align 8, !tbaa !22
  %19 = add i64 %18, 1
  store i64 %19, ptr %17, align 8, !tbaa !22
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %16) #4
  %21 = load i64, ptr %20, align 8, !tbaa !22
  %22 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %16) #4
  %23 = load i64, ptr %22, align 8, !tbaa !22
  %24 = icmp ult i64 %21, %23
  br i1 %24, label %.loopexit, label %25

25:                                               ; preds = %15
  %26 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %16) #4
  store i64 0, ptr %26, align 8, !tbaa !22
  %.not = icmp eq i64 %16, 0
  br i1 %.not, label %.loopexit.sink.split, label %15, !llvm.loop !24

.loopexit.sink.split:                             ; preds = %25, %12, %6
  %.sink = phi i8 [ %11, %6 ], [ 1, %12 ], [ 1, %25 ]
  store i8 %.sink, ptr %3, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %15, %.loopexit.sink.split
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIN9__gnu_cxx17__normal_iteratorIPmSt6vectorImSaImEEEEiEvT_S7_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { 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 #3 = { inlinehint 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 #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, !16, i64 72}
!6 = !{!"_ZTSN6ngraph19CoordinateTransform8IteratorE", !7, i64 0, !7, i64 24, !15, i64 48, !16, i64 72, !16, i64 73}
!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 = !{!"bool", !13, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!20, !20, i64 0}
!20 = !{!"int", !13, i64 0}
!21 = !{!6, !16, i64 73}
!22 = !{!23, !23, i64 0}
!23 = !{!"long", !13, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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