; LLVM IR from ardiloot/NonlinearTMM :: NonlinearTMM/src/eigen-3.4.0/test/dynalloc.ll (Z25check_aligned_stack_allocv)

; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Eigen::internal::aligned_stack_memory_handler" = type <{ ptr, i64, i8, [7 x i8] }>

@_ZN5EigenL12g_test_stackB5cxx11E = external hidden global %"class.std::vector", align 8
@.str.28 = external hidden unnamed_addr constant [102 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [27 x i8], align 1

; 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: inlinehint mustprogress uwtable
declare dso_local void @_Z11verify_implbPKcS0_iS0_(i1 noundef zeroext, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN5Eigen8internal14aligned_mallocEm(i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z25check_aligned_stack_allocv() #3 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca %"class.Eigen::internal::aligned_stack_memory_handler", align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 16, ptr %1, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %70, %0
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 400
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  br label %73

12:                                               ; preds = %8
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  call void @_ZN5Eigen8internal23check_size_for_overflowIfEEvm(i64 noundef %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = mul i64 4, %16
  %18 = icmp ule i64 %17, 131072
  br i1 %18, label %19, label %31

19:                                               ; preds = %12
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = mul i64 4, %21
  %23 = add i64 %22, 16
  %24 = sub i64 %23, 1
  %25 = alloca i8, i64 %24, align 16
  %26 = ptrtoint ptr %25 to i64
  %27 = add i64 %26, 16
  %28 = sub i64 %27, 1
  %29 = and i64 %28, -16
  %30 = inttoptr i64 %29 to ptr
  br label %36

31:                                               ; preds = %12
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = mul i64 4, %33
  %35 = call noundef ptr @_ZN5Eigen8internal14aligned_mallocEm(i64 noundef %34)
  br label %36

36:                                               ; preds = %31, %19
  %37 = phi ptr [ %30, %19 ], [ %35, %31 ]
  store ptr %37, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #5
  %38 = load ptr, ptr %3, align 8, !tbaa !9
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = load i32, ptr %1, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = mul i64 4, %42
  %44 = icmp ugt i64 %43, 131072
  call void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfEC2EPfmb(ptr noundef nonnull align 8 dereferenceable(17) %4, ptr noundef %38, i64 noundef %40, i1 noundef zeroext %44)
  %45 = load ptr, ptr %3, align 8, !tbaa !9
  %46 = ptrtoint ptr %45 to i64
  %47 = urem i64 %46, 16
  %48 = icmp eq i64 %47, 0
  %49 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN5EigenL12g_test_stackB5cxx11E) #5
  %50 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %49) #5
  invoke void @_Z11verify_implbPKcS0_iS0_(i1 noundef zeroext %48, ptr noundef %50, ptr noundef @.str.28, i32 noundef 62, ptr noundef @.str.29)
          to label %51 unwind label %57

51:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %66, %51
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = load i32, ptr %1, align 4, !tbaa !5
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %61, label %56

56:                                               ; preds = %52
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %69

57:                                               ; preds = %36
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %5, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %6, align 4
  call void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfED2Ev(ptr noundef nonnull align 8 dereferenceable(17) %4) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  br label %74

61:                                               ; preds = %52
  %62 = load ptr, ptr %3, align 8, !tbaa !9
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds float, ptr %62, i64 %64
  store float 0.000000e+00, ptr %65, align 4, !tbaa !11
  br label %66

66:                                               ; preds = %61
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %7, align 4, !tbaa !5
  br label %52, !llvm.loop !13

69:                                               ; preds = %56
  call void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfED2Ev(ptr noundef nonnull align 8 dereferenceable(17) %4) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %1, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %1, align 4, !tbaa !5
  br label %8, !llvm.loop !15

73:                                               ; preds = %11
  ret void

74:                                               ; preds = %57
  %75 = load ptr, ptr %5, align 8
  %76 = load i32, ptr %6, align 4
  %77 = insertvalue { ptr, i32 } poison, ptr %75, 0
  %78 = insertvalue { ptr, i32 } %77, i32 %76, 1
  resume { ptr, i32 } %78
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN5Eigen8internal23check_size_for_overflowIfEEvm(i64 noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfEC2EPfmb(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef, i64 noundef, i1 noundef zeroext) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfED2Ev(ptr noundef nonnull align 8 dereferenceable(17)) unnamed_addr #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { 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 = { alwaysinline 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Eigen::internal::aligned_stack_memory_handler" = type <{ ptr, i64, i8, [7 x i8] }>

@_ZN5EigenL12g_test_stackB5cxx11E = external hidden global %"class.std::vector", align 8
@.str.28 = external hidden unnamed_addr constant [102 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [27 x i8], align 1

; 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: inlinehint mustprogress uwtable
declare dso_local void @_Z11verify_implbPKcS0_iS0_(i1 noundef zeroext, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z25check_aligned_stack_allocv() local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.Eigen::internal::aligned_stack_memory_handler", align 8
  br label %3

2:                                                ; preds = %.preheader.preheader
  ret void

3:                                                ; preds = %0, %.preheader.preheader
  %indvars.iv = phi i64 [ 16, %0 ], [ %indvars.iv.next, %.preheader.preheader ]
  %indvar = phi i64 [ 0, %0 ], [ %indvar.next, %.preheader.preheader ]
  call void @_ZN5Eigen8internal23check_size_for_overflowIfEEvm(i64 noundef %indvars.iv)
  %4 = shl nuw nsw i64 %indvars.iv, 2
  %5 = add nuw nsw i64 %4, 15
  %6 = alloca i8, i64 %5, align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #6
  call void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfEC2EPfmb(ptr noundef nonnull align 8 dereferenceable(17) %1, ptr noundef nonnull %6, i64 noundef %indvars.iv, i1 noundef zeroext false)
  %7 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN5EigenL12g_test_stackB5cxx11E) #6
  %8 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %7) #6
  invoke void @_Z11verify_implbPKcS0_iS0_(i1 noundef zeroext true, ptr noundef %8, ptr noundef nonnull @.str.28, i32 noundef 62, ptr noundef nonnull @.str.29)
          to label %.preheader.preheader unwind label %11

.preheader.preheader:                             ; preds = %3
  %9 = shl nuw nsw i64 %indvar, 2
  %10 = add nuw nsw i64 %9, 64
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %6, i8 0, i64 %10, i1 false), !tbaa !5
  call void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfED2Ev(ptr noundef nonnull align 8 dereferenceable(17) %1) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %indvar.next = add nuw nsw i64 %indvar, 1
  %exitcond.not = icmp eq i64 %indvar.next, 384
  br i1 %exitcond.not, label %2, label %3, !llvm.loop !9

11:                                               ; preds = %3
  %12 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfED2Ev(ptr noundef nonnull align 8 dereferenceable(17) %1) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #6
  resume { ptr, i32 } %12
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN5Eigen8internal23check_size_for_overflowIfEEvm(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfEC2EPfmb(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef, i64 noundef, i1 noundef zeroext) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5Eigen8internal28aligned_stack_memory_handlerIfED2Ev(ptr noundef nonnull align 8 dereferenceable(17)) unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { 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 = { alwaysinline 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 = !{!"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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass