; LLVM IR from NervanaSystems/ngraph :: src/ngraph/op/stack.ll (ZN6ngraph2op2v05Stack28pre_validate_and_infer_typesEv)

; 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::PartialShape" = type { i8, %"class.std::vector.81" }
%"class.std::vector.81" = type { %"struct.std::_Vector_base.82" }
%"struct.std::_Vector_base.82" = type { %"struct.std::_Vector_base<ngraph::Dimension, std::allocator<ngraph::Dimension>>::_Vector_impl" }
%"struct.std::_Vector_base<ngraph::Dimension, std::allocator<ngraph::Dimension>>::_Vector_impl" = type { %"struct.std::_Vector_base<ngraph::Dimension, std::allocator<ngraph::Dimension>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ngraph::Dimension, std::allocator<ngraph::Dimension>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.ngraph::Dimension" = type { %"class.ngraph::Interval" }
%"class.ngraph::Interval" = type { i64, i64 }

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

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZN6ngraph2op2v05Stack28pre_validate_and_infer_typesEv(ptr noundef nonnull align 8 dereferenceable(688) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"class.ngraph::PartialShape", align 8
  %7 = alloca %"class.ngraph::Dimension", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #5
  store i8 0, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 0, ptr %4, align 8, !tbaa !11
  br label %11

11:                                               ; preds = %22, %1
  %12 = load i64, ptr %4, align 8, !tbaa !11
  %13 = call noundef i64 @_ZNK6ngraph4Node14get_input_sizeEv(ptr noundef nonnull align 8 dereferenceable(680) %10)
  %14 = icmp ult i64 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 2, ptr %5, align 4
  br label %25

16:                                               ; preds = %11
  %17 = load i64, ptr %4, align 8, !tbaa !11
  %18 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6ngraph4Node23get_input_partial_shapeEm(ptr noundef nonnull align 8 dereferenceable(680) %10, i64 noundef %17)
  %19 = call noundef zeroext i1 @_ZNK6ngraph12PartialShape10is_dynamicEv(ptr noundef nonnull align 8 dereferenceable(32) %18)
  br i1 %19, label %20, label %21

20:                                               ; preds = %16
  store i8 1, ptr %3, align 1, !tbaa !9
  store i32 2, ptr %5, align 4
  br label %25

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21
  %23 = load i64, ptr %4, align 8, !tbaa !11
  %24 = add i64 %23, 1
  store i64 %24, ptr %4, align 8, !tbaa !11
  br label %11, !llvm.loop !13

25:                                               ; preds = %20, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %26

26:                                               ; preds = %25
  %27 = load i8, ptr %3, align 1, !tbaa !9, !range !15, !noundef !16
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %46

29:                                               ; preds = %26
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK6ngraph4Node22get_input_element_typeEm(ptr noundef nonnull align 8 dereferenceable(680) %10, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #5
  %31 = call { i64, i64 } @_ZN6ngraph9Dimension7dynamicEv()
  %32 = getelementptr inbounds %"class.ngraph::Dimension", ptr %7, i32 0, i32 0
  %33 = getelementptr inbounds { i64, i64 }, ptr %32, i32 0, i32 0
  %34 = extractvalue { i64, i64 } %31, 0
  store i64 %34, ptr %33, align 8
  %35 = getelementptr inbounds { i64, i64 }, ptr %32, i32 0, i32 1
  %36 = extractvalue { i64, i64 } %31, 1
  store i64 %36, ptr %35, align 8
  %37 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  %38 = load i64, ptr %37, align 8
  %39 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  %40 = load i64, ptr %39, align 8
  call void @_ZN6ngraph12PartialShape7dynamicENS_9DimensionE(ptr dead_on_unwind writable sret(%"class.ngraph::PartialShape") align 8 %6, i64 %38, i64 %40)
  invoke void @_ZN6ngraph4Node15set_output_typeEmRKNS_7element4TypeERKNS_12PartialShapeE(ptr noundef nonnull align 8 dereferenceable(680) %10, i64 noundef 0, ptr noundef nonnull align 4 dereferenceable(4) %30, ptr noundef nonnull align 8 dereferenceable(32) %6)
          to label %41 unwind label %42

41:                                               ; preds = %29
  call void @_ZN6ngraph12PartialShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #5
  br label %46

42:                                               ; preds = %29
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %8, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %9, align 4
  call void @_ZN6ngraph12PartialShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #5
  br label %47

46:                                               ; preds = %41, %26
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #5
  ret void

47:                                               ; preds = %42
  %48 = load ptr, ptr %8, align 8
  %49 = load i32, ptr %9, align 4
  %50 = insertvalue { ptr, i32 } poison, ptr %48, 0
  %51 = insertvalue { ptr, i32 } %50, i32 %49, 1
  resume { ptr, i32 } %51
}

declare noundef i64 @_ZNK6ngraph4Node14get_input_sizeEv(ptr noundef nonnull align 8 dereferenceable(680)) #2

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6ngraph4Node23get_input_partial_shapeEm(ptr noundef nonnull align 8 dereferenceable(680), i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK6ngraph12PartialShape10is_dynamicEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

declare void @_ZN6ngraph4Node15set_output_typeEmRKNS_7element4TypeERKNS_12PartialShapeE(ptr noundef nonnull align 8 dereferenceable(680), i64 noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(32)) #2

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZNK6ngraph4Node22get_input_element_typeEm(ptr noundef nonnull align 8 dereferenceable(680), i64 noundef) #2

declare void @_ZN6ngraph12PartialShape7dynamicENS_9DimensionE(ptr dead_on_unwind writable sret(%"class.ngraph::PartialShape") align 8, i64, i64) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i64, i64 } @_ZN6ngraph9Dimension7dynamicEv() #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6ngraph12PartialShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 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 = { "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 = { 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 #4 = { 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 #5 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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.ngraph::PartialShape" = type { i8, %"class.std::vector.81" }
%"class.std::vector.81" = type { %"struct.std::_Vector_base.82" }
%"struct.std::_Vector_base.82" = type { %"struct.std::_Vector_base<ngraph::Dimension, std::allocator<ngraph::Dimension>>::_Vector_impl" }
%"struct.std::_Vector_base<ngraph::Dimension, std::allocator<ngraph::Dimension>>::_Vector_impl" = type { %"struct.std::_Vector_base<ngraph::Dimension, std::allocator<ngraph::Dimension>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ngraph::Dimension, std::allocator<ngraph::Dimension>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZN6ngraph2op2v05Stack28pre_validate_and_infer_typesEv(ptr noundef nonnull align 8 dereferenceable(688) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.ngraph::PartialShape", align 8
  %3 = tail call noundef i64 @_ZNK6ngraph4Node14get_input_sizeEv(ptr noundef nonnull align 8 dereferenceable(680) %0)
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %.critedge, label %.lr.ph

4:                                                ; preds = %.lr.ph
  %5 = add nuw i64 %.067, 1
  %6 = tail call noundef i64 @_ZNK6ngraph4Node14get_input_sizeEv(ptr noundef nonnull align 8 dereferenceable(680) %0)
  %7 = icmp ult i64 %5, %6
  br i1 %7, label %.lr.ph, label %.critedge, !llvm.loop !5

.lr.ph:                                           ; preds = %1, %4
  %.067 = phi i64 [ %5, %4 ], [ 0, %1 ]
  %8 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6ngraph4Node23get_input_partial_shapeEm(ptr noundef nonnull align 8 dereferenceable(680) %0, i64 noundef %.067)
  %9 = tail call noundef zeroext i1 @_ZNK6ngraph12PartialShape10is_dynamicEv(ptr noundef nonnull align 8 dereferenceable(32) %8)
  br i1 %9, label %10, label %4

10:                                               ; preds = %.lr.ph
  %11 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK6ngraph4Node22get_input_element_typeEm(ptr noundef nonnull align 8 dereferenceable(680) %0, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #5
  %12 = tail call { i64, i64 } @_ZN6ngraph9Dimension7dynamicEv()
  %13 = extractvalue { i64, i64 } %12, 0
  %14 = extractvalue { i64, i64 } %12, 1
  call void @_ZN6ngraph12PartialShape7dynamicENS_9DimensionE(ptr dead_on_unwind nonnull writable sret(%"class.ngraph::PartialShape") align 8 %2, i64 %13, i64 %14)
  invoke void @_ZN6ngraph4Node15set_output_typeEmRKNS_7element4TypeERKNS_12PartialShapeE(ptr noundef nonnull align 8 dereferenceable(680) %0, i64 noundef 0, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 8 dereferenceable(32) %2)
          to label %15 unwind label %16

15:                                               ; preds = %10
  call void @_ZN6ngraph12PartialShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %2) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #5
  br label %.critedge

16:                                               ; preds = %10
  %17 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN6ngraph12PartialShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %2) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #5
  resume { ptr, i32 } %17

.critedge:                                        ; preds = %4, %1, %15
  ret void
}

declare noundef i64 @_ZNK6ngraph4Node14get_input_sizeEv(ptr noundef nonnull align 8 dereferenceable(680)) local_unnamed_addr #2

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6ngraph4Node23get_input_partial_shapeEm(ptr noundef nonnull align 8 dereferenceable(680), i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK6ngraph12PartialShape10is_dynamicEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

declare void @_ZN6ngraph4Node15set_output_typeEmRKNS_7element4TypeERKNS_12PartialShapeE(ptr noundef nonnull align 8 dereferenceable(680), i64 noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZNK6ngraph4Node22get_input_element_typeEm(ptr noundef nonnull align 8 dereferenceable(680), i64 noundef) local_unnamed_addr #2

declare void @_ZN6ngraph12PartialShape7dynamicENS_9DimensionE(ptr dead_on_unwind writable sret(%"class.ngraph::PartialShape") align 8, i64, i64) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i64, i64 } @_ZN6ngraph9Dimension7dynamicEv() local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6ngraph12PartialShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 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 = { "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 = { 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 #4 = { 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 #5 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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